2 # Copyright (C) 2001-2009, Parrot Foundation.
7 use lib qw( . lib ../lib ../../lib );
10 use Parrot::Test tests => 15;
11 use Parrot::PMC '%pmc_types';
23 Contains a lot of PMC related tests.
27 pir_output_is( <<'CODE', <<'OUTPUT', "newpmc" );
38 pir_output_is( <<'CODE', <<'OUTPUT', 'typeof' );
42 eq $S0, "Integer", OK_1
52 my %types_we_cant_test
53 = map { $_ => 1; } ( # These require initializers.
54 qw(default Null Iterator ArrayIterator HashIterator StringIterator
55 OrderedHashIterator Enumerate ParrotObject ParrotThread BigInt LexInfo
56 LexPad Object Handle Opcode OpLib),
58 # Instances of these appear to have other types.
60 while ( my ( $type, $id ) = each %pmc_types ) {
62 if $types_we_cant_test{$type};
63 my $set_ro = ( $type =~ /^Const\w+/ ) ? <<'PIR' : '';
66 setprop $P0, "_ro", $P10
68 $checkTypes .= qq{ new \$P0, '$type'\n$set_ro\n};
69 $checkTypes .= qq{ set \$S1, "$type"\n};
70 $checkTypes .= <<'CHECK';
72 ne $S0, $S1, L_BadName
76 pir_output_like( <<"CODE", qr/All names ok/, "PMC type check" );
85 print " PMCs have incorrect name \\""
91 pir_error_output_like( <<'CODE', <<'OUTPUT', 'find_method' );
94 find_method $P0, $P1, "no_such_meth"
97 /Method 'no_such_meth' not found for invocant of class 'Integer'/
100 pir_output_is( <<'CODE', <<'OUTPUT', "eq_addr same" );
104 eq_addr $P0, $P1, OK1
107 ne_addr $P0, $P1, BAD2
117 pir_output_is( <<'CODE', <<'OUTPUT', "eq_addr diff" );
121 ne_addr $P0, $P1, OK1
124 eq_addr $P0, $P1, BAD2
134 pir_output_is( <<'CODE', <<'OUTPUT', "if_null" );
151 pir_output_is( <<'CODE', <<'OUTPUT', "Env PMCs are singletons" );
156 print "not the same "
163 pir_output_is( <<'CODE', <<'OUTPUT', "issame" );
170 isntsame $I0, $P0, $P1
175 isntsame $I0, $P0, $P2
182 pir_output_is( <<'CODE', <<'OUT', ".const - Sub constant" );
185 .const 'Sub' $P0 = "foo"
199 pir_output_is( <<'CODE', <<'OUT', "Integer pmc constant " );
201 .const 'Integer' i = "42"
208 pir_output_is( <<'CODE', <<'OUT', "Float pmc constant " );
210 .const 'Float' j = "4.2"
217 pir_output_is( <<'CODE', <<'OUT', "pmc constant" );
219 .const 'Integer' $P0 = "42"
226 pir_output_is( <<'CODE', <<'OUT', "logical or, and, xor" );
232 eq_addr $P2, $P0, ok1
237 eq_addr $P2, $P1, ok2
242 eq_addr $P2, $P0, ok3
253 pir_output_is( <<'CODE', <<'OUTPUT', "new_p_s" );
271 # cperl-indent-level: 4
274 # vim: expandtab shiftwidth=4: