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 v-table method, 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 # :vtable inheritance; RT #40626
136 pir_output_is( <<'CODE', <<'OUT', ':vtable inheritance from core classes' );
138 $P0 = subclass 'Hash', 'Foo'
139 $P0 = subclass 'Hash', 'Bar'
153 .sub 'get_string' :vtable :method
154 .return('Foo::get_string')
160 .sub 'get_string' :vtable :method
161 .return('Bar::get_string')
168 # assign opcode in inherited classes
170 <<'CODE', <<'OUT', 'assign opcode in inherited classes' );
172 $P1 = new ['ResizablePMCArray']
174 $P2 = new ['ResizablePMCArray']
180 $P99 = subclass 'ResizablePMCArray', 'Perl6List'
181 $P1 = new 'Perl6List'
183 $P2 = new 'Perl6List'
194 pir_output_is( <<'CODE', <<'OUT', 'RT #41733 - Execution ends after returning from invoke' );
198 say "you invoked me!"
205 $P1($P1) # pass the object it"self"
213 pir_output_is( <<'CODE', <<'OUT', 'params/returns from overridden invoke' );
227 $I0 = $P1($P1, 2) # pass the object it"self"
236 pir_error_output_like( <<'CODE', <<'OUT', 'RT #41732' );
250 /too few positional arguments/
257 # cperl-indent-level: 4
260 # vim: expandtab shiftwidth=4: