2 # Copyright (C) 2001-2005, The Perl Foundation.
7 use lib qw( . lib ../lib ../../lib );
9 use Parrot::Test tests => 11;
13 t/pmc/coroutines.t - Coroutines
17 % prove t/pmc/coroutines.t
21 Tests the C<Coroutine> PMC.
25 pasm_output_is( <<'CODE', <<'OUTPUT', "Coroutine 1" );
26 .include "interpinfo.pasm"
28 .const .Sub P0 = "_coro"
52 pir_output_is( <<'CODE', <<'OUTPUT', "Coroutines - M. Wallace yield example" );
57 .const .Sub itr = "_iterator"
63 new return, 'Continuation'
64 set_addr return, return_here
109 pasm_output_is( <<'CODE', <<'OUTPUT', "Coroutine - exception in main" );
110 .include "interpinfo.pasm"
112 .const .Sub P0 = "_coro"
128 get_results '0, 0' , P5, S0
140 get_results '0, 0' , P5, S0
148 pasm_output_is( <<'CODE', <<'OUTPUT', "Coroutine - exception in coro" );
149 .include "interpinfo.pasm"
151 .const .Sub P0 = "_coro"
165 get_results '0, 0' , P5, S0
179 get_results '0, 0' , P5, S0
187 pasm_output_is( <<'CODE', <<'OUTPUT', "Coroutine - exception in coro no handler" );
188 .include "interpinfo.pasm"
190 .const .Sub P0 = "_coro"
204 get_results '0, 0' , P5, S0
223 pasm_output_is( <<'CODE', <<'OUTPUT', "Coroutine - exception in coro rethrow" );
224 .include "interpinfo.pasm"
226 .const .Sub P0 = "_coro"
240 get_results '0, 0' , P5, S0
254 get_results '0, 0' , P5, S0
264 pir_output_is( <<'CODE', 'Coroutine', "Coro new - type" );
283 pir_output_is( <<'CODE', '01234', "Coro new - yield" );
291 .result $P0 :optional
292 .result $I0 :opt_flag
311 <<'CODE', <<'OUTPUT', "Call an exited coroutine", todo => 'goes one iteration too far.' );
330 /\A01234Cannot resume dead coroutine/
333 pir_output_is( << 'CODE', << 'OUTPUT', "check whether interface is done" );
337 pmc1 = new 'Coroutine'
339 does bool1, pmc1, "scalar" # XXX WTF
342 does bool1, pmc1, "no_interface"
352 pir_output_is( <<'CODE', <<'OUTPUT', "re-entering coro from another sub" );
356 .const .Sub corou = "_coroufn"
360 unless z < 4 goto end
375 print "coroutine: first call "
388 coroutine: first call from main
398 # cperl-indent-level: 4
401 # vim: expandtab shiftwidth=4: