2 # Copyright (C) 2001-2005, Parrot Foundation.
7 use lib qw( . lib ../lib ../../lib );
9 use Parrot::Test tests => 11;
13 t/pmc/coroutines.t - Coroutines
17 % prove t/pmc/coroutine.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"
60 zero = new ['Integer']
63 return = new ['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"
148 pasm_output_is( <<'CODE', <<'OUTPUT', "Coroutine - exception in coro" );
149 .include "interpinfo.pasm"
151 .const 'Sub' P0 = "_coro"
187 pasm_output_is( <<'CODE', <<'OUTPUT', "Coroutine - exception in coro no handler" );
188 .include "interpinfo.pasm"
190 .const 'Sub' P0 = "_coro"
223 pasm_output_is( <<'CODE', <<'OUTPUT', "Coroutine - exception in coro rethrow" );
224 .include "interpinfo.pasm"
226 .const 'Sub' P0 = "_coro"
264 pir_output_is( <<'CODE', 'Coroutine', "Coro new - type" );
268 c = get_global "coro"
283 pir_output_is( <<'CODE', '01234', "Coro new - yield" );
287 c = get_global "coro"
291 .get_result $P0 :optional
292 .get_result $I0 :opt_flag
311 <<'CODE', <<'OUTPUT', "Call an exited coroutine", todo => 'goes one iteration too far TT #1003' );
314 c = get_global "coro"
330 /\A01234Cannot resume dead coroutine/
333 pir_output_is( << 'CODE', << 'OUTPUT', "check whether interface is done" );
337 pmc1 = new ['Coroutine']
339 does bool1, pmc1, "invokable"
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: