2 # Copyright (C) 2001-2009, Parrot Foundation.
7 t/pmc/undef.t - Undef PMC
15 Tests mainly morphing undef to other types.
20 .include 'test_more.pir'
26 undef_pmc_is_not_defined()
27 undef_pmc_morph_to_string()
28 undef_pmc_morph_to_integer()
29 undef_pmc_morph_to_float()
30 string_pmc_morph_to_undef()
31 undef_pmc_set_to_integer_native()
32 undef_pmc_isa_after_assignment()
33 check_whether_interface_is_done()
44 is( $P1, 'foofoo', 'morphed to string' )
47 .sub undef_pmc_is_false
51 ok( 1, 'PMC Undef created by new is false' )
54 ok( 0, 'PMC Undef created by new is false' )
57 unless pmc1 goto logical_not_passed
58 ok( 0, 'logical_not of PMC Undef created by new is false' )
61 ok( 1, 'logical_not of PMC Undef created by new is true' )
66 .sub undef_pmc_is_not_defined
70 is_defined = defined pmc1
71 if is_defined goto PMC1_IS_DEFINED
72 ok( 1, 'PMC Undef created by new is not defined' )
75 ok( 0, 'PMC Undef created by new is not defined' )
78 .sub undef_pmc_morph_to_string
82 is( $S1, '', 'PMC Undef is empty string' )
85 .sub undef_pmc_morph_to_integer
90 is( int1, 0, 'PMC Undef as integer is zero' )
95 is( int2, -7777777, 'PMC Undef in addition is zero' )
98 .sub undef_pmc_morph_to_float
106 is( float1, -7777.777000, 'PMC Undef morph to int then float' )
109 .sub string_pmc_morph_to_undef
111 pmc1 = new ['String']
112 $P0 = get_class 'Undef'
115 is( $S1, 'Undef', 'PMC String morph to undef' )
118 .sub undef_pmc_set_to_integer_native
122 is( pmc1, -88888888, 'PMC Undef set to int gives int' )
125 pmc1_is_a = isa pmc1, "Integer"
126 ok( pmc1_is_a, 'PMC Undef set to int isa Integer' )
129 .sub undef_pmc_isa_after_assignment
134 pmc1_is_a = isa pmc1, "Undef"
135 ok( pmc1_is_a, 'PMC Undef isa Undef' )
137 pmc1_is_a = isa pmc1, "default"
138 is( pmc1_is_a, 0, 'PMC Undef is not default' )
140 pmc1_is_a = isa pmc1, "Default"
141 is( pmc1_is_a, 0, 'PMC Undef is not Default' )
143 pmc1_is_a = isa pmc1, "scalar"
144 is( pmc1_is_a, 0, 'PMC Undef is not scalar' )
146 pmc1_is_a = isa pmc1, "Scalar"
147 is( pmc1_is_a, 0, 'PMC Undef is not Scalar' )
150 .sub check_whether_interface_is_done
155 does bool1, pmc1, "scalar"
156 is( bool1, 1, 'PMC Undef does scalar' )
158 does bool1, pmc1, "no_interface"
159 is( bool1, 0, 'PMC Undef does not do no_interface' )
162 .sub verify_clone_works
166 is( $S0, 'Undef', 'PMC Undef clone is an Undef' )
169 .sub undef_equals_undef
172 if $P1 == $P2 goto ok
173 ok( 0, 'Undef == Undef (RT #33603)' )
176 ok( 1, 'Undef == Undef (RT #33603)' )
179 .sub set_undef_to_object
181 $P1 = get_class 'Integer'
185 ok( $I0, 'Assign Integer to Undef' )
192 ok( $I0, 'Assign Object to Undef' )
195 is( $S0, 'A string', '... and the right object' )
198 $P1 = subclass 'ResizablePMCArray', 'FooRPA'
202 ok( $I0, 'Assign Object with PMC parent to Undef' )
204 # TODO: Needs tests to verify that the values and metadata are preserved
205 # across the assignment
210 .sub get_string :vtable :method
211 .return( 'A string' )
218 # vim: expandtab shiftwidth=4 ft=pir: