2 # Copyright (C) 2001-2010, Parrot Foundation.
7 t/pmc/integer.t - Integer basic type
11 % prove t/pmc/integer.t
15 Tests the Integer PMC.
20 .include 'test_more.pir'
25 test_truthiness_and_definedness()
26 test_set_string_native()
38 test_get_as_base_various()
39 test_get_as_base_bounds_check()
47 is(i1, 0, "Default value of Integer is 0")
49 i2 = new ['Integer'], i1
50 is(i2, 42, "Initialize with argument set correct value")
53 .sub test_get_as_base_bounds_check
54 throws_substring(<<'CODE', 'get_as_base: base out of bounds', 'get_as_base lower bound check')
58 $S0 = $P0.'get_as_base'(1)
62 throws_substring(<<'CODE', 'get_as_base: base out of bounds', 'get_as_base upper bound check')
66 $S0 = $P0.'get_as_base'(37)
74 int_1 = new ['Integer']
95 .sub test_truthiness_and_definedness
97 int_1 = new ['Integer']
99 nok(int_1, "A newly created Integer is not true")
101 .local int is_defined
103 is_defined = defined int_1
105 nok(int_1, "A newly created Integer is not defined")
109 ok(int_1, "-999999999 is true")
111 is_defined = defined int_1
113 ok(int_1, "-999999999 is defined")
118 .sub test_set_string_native
120 pmc1 = new ['Integer']
128 pmc1 = new ['Integer']
131 pmc1_is_a = isa pmc1, "Integer"
132 isa_ok(pmc1, "Integer")
137 pmc1 = new ['Integer']
139 does bool1, pmc1, "scalar"
141 does bool1, pmc1, "integer"
143 does bool1, pmc1, "no_interface"
149 pmc1 = new ['Integer']
175 pmc1 = new ['Integer']
209 pmc1 = new ['Integer']
239 .sub test_istrue_isfalse
241 pmc1 = new ['Integer']
307 $P0 = new ['Integer']
308 $P1 = new ['Integer']
327 .sub test_get_as_base
328 $P0 = new ['Integer']
330 $I0 = can $P0, 'get_as_base'
331 ok($I0,'Integers can get_as_base')
334 .sub test_get_as_base10
335 $P0 = new ['Integer']
338 $S0 = $P0.'get_as_base'(10)
342 .sub test_get_as_base_various
343 $P0 = new ['Integer']
346 $S0 = $P0.'get_as_base'(2)
349 $S0 = $P0.'get_as_base'(3)
352 $S0 = $P0.'get_as_base'(5)
355 $S0 = $P0.'get_as_base'(7)
358 $S0 = $P0.'get_as_base'(11)
361 $S0 = $P0.'get_as_base'(13)
364 $S0 = $P0.'get_as_base'(17)
367 $S0 = $P0.'get_as_base'(19)
370 $S0 = $P0.'get_as_base'(23)
373 $S0 = $P0.'get_as_base'(29)
376 $S0 = $P0.'get_as_base'(31)
380 .sub test_cmp_subclass
381 $P0 = subclass 'Integer', 'Int'
396 .sub test_cmp_RT59336
397 $P0 = new ['Integer']
401 if $P0 > -10 goto pass
408 if $P0 > -1000 goto pass2
420 # vim: expandtab shiftwidth=4 ft=pir: