2 # Copyright (C) 2006-2008, Parrot Foundation.
7 use lib qw( . lib ../lib ../../lib );
9 use Parrot::Test tests => 11;
13 t/pmc/parrotobject.t - test the Object PMC
18 % prove t/pmc/parrotobject.t
26 pir_error_output_like( <<'CODE', <<'OUT', 'new' );
32 /Object must be created by a class./
37 pir_output_is( <<'CODE', <<'OUT', ':vtable override' );
39 $P0 = newclass [ "Test" ]
48 .sub get_integer_keyed_int :method :vtable
58 pir_output_is( <<'CODE', <<'OUT', ':vtable("...") override' );
60 $P0 = newclass [ "Test" ]
69 .sub monkey :method :vtable("get_string_keyed_int")
79 pir_error_output_like( <<'CODE', <<'OUT', ':vtable with bad name' );
82 .sub monkey :method :vtable("not_in_the_vtable")
87 /'not_in_the_vtable' is not a vtable, but was used with :vtable/
92 pir_output_is( <<'CODE', <<'OUT', ':vtable and init' );
94 $P0 = newclass [ "Test" ]
101 .sub init :method :vtable
111 pir_output_is( <<'CODE', <<'OUT', ':vtable inheritance' );
113 $P0 = newclass [ "Test" ]
114 $P1 = newclass [ "Test2" ]
116 $P2 = new [ "Test2" ]
121 .namespace [ "Test" ]
123 .sub clone :method :vtable
127 .namespace [ "Test2" ]
135 pir_output_is( <<'CODE', <<'OUT', ':vtable inheritance from core classes' );
137 $P0 = subclass 'Hash', 'Foo'
138 $P0 = subclass 'Hash', 'Bar'
152 .sub 'get_string' :vtable :method
153 .return('Foo::get_string')
159 .sub 'get_string' :vtable :method
160 .return('Bar::get_string')
167 # assign opcode in inherited classes
169 <<'CODE', <<'OUT', 'assign opcode in inherited classes' );
171 $P1 = new ['ResizablePMCArray']
173 $P2 = new ['ResizablePMCArray']
179 $P99 = subclass 'ResizablePMCArray', 'Perl6List'
180 $P1 = new 'Perl6List'
182 $P2 = new 'Perl6List'
193 pir_output_is( <<'CODE', <<'OUT', 'Execution ends after returning from invoke' );
197 say "you invoked me!"
204 $P1($P1) # pass the object it"self"
212 pir_output_is( <<'CODE', <<'OUT', 'params/returns from overridden invoke' );
226 $I0 = $P1($P1, 2) # pass the object it"self"
235 pir_error_output_like( <<'CODE', <<'OUT', 'handle too few positional arguments' );
249 /too few positional arguments/
256 # cperl-indent-level: 4
259 # vim: expandtab shiftwidth=4: