2 # Copyright (C) 2001-2005, The Perl Foundation.
7 use lib qw( . lib ../lib ../../lib );
9 use Parrot::Test tests => 24;
13 t/op/stacks.t - Stacks
21 Tests for stack operations, currently C<push*>, C<push_*_c> and C<pop*>
22 where C<*> is not C<p>.
26 # Tests for stack operations, currently push*, push_*_c and pop*
29 # Assembler code is partially generated by subs at bottom of file
31 # This defines two macros:
34 # which will conditionally branch
35 # to LABEL if abs(n,n) < epsilon
37 my $fp_equality_macro = <<'ENDOFMACRO';
47 gt N2, 0.000001, .$FPEQNOK
67 lt N2, 0.000001, .$FPNENOK
80 ############### Tests ##################
82 # Test proper stack chunk handling
83 pasm_output_is( <<CODE, <<'OUTPUT', 'save_i & restore_i' );
102 ne I3, 769, testloop # At least 3 stack chunks
111 pasm_output_is( <<"CODE", <<'OUTPUT', 'rotate 0' );
125 pasm_output_is( <<"CODE", <<'OUTPUT', 'rotate 1' );
139 pasm_output_is( <<"CODE", <<'OUTPUT', 'rotate 2' );
153 pasm_output_is( <<"CODE", <<'OUTPUT', 'rotate 3' );
173 pasm_output_is( <<"CODE", <<'OUTPUT', 'rotate -1' );
193 pasm_output_is( <<"CODE", <<'OUTPUT', 'rotate -2' );
213 pasm_output_is( <<"CODE", <<'OUTPUT', 'rotate -3' );
233 pasm_output_is( <<'CODE', <<'OUTPUT', 'rotate with a full stack chunk' );
249 pasm_output_is( <<'CODE', <<'OUTPUT', 'rotate across stack chunk boundary' );
265 pasm_output_is( <<'CODE', <<'OUTPUT', 'rotate by stack chunk size' );
281 pasm_output_is( <<'CODE', <<'OUTPUT', 'rotate by more than stack chunk size' );
297 pasm_output_is( <<"CODE", <<'OUTPUT', 'rotate up by more than stack size' );
308 pasm_output_is( <<"CODE", <<'OUTPUT', 'rotate down by more than stack size' );
319 pasm_output_is( <<'CODE', <<'OUTPUT', 'save/savec for strings' );
345 pasm_output_is( <<CODE, <<OUTPUT, "save, restore" );
346 @{[ $fp_equality_macro ]}
359 .fp_eq (N0, 2.0, EQ1)
361 EQ1: print "equal to 2.0\\n"
363 .fp_eq (N0, 1.0, EQ2)
365 EQ2: print "equal to 1.0\\n"
369 set S0, "HONK HONK\\n"
381 .fp_eq (N0, 3.14159, EQ3)
382 print "<kansas> not "
383 EQ3: print "equal to PI\\n"
385 save "All the world's people\\n"
390 set P0, "never to escape\\n"
393 set P0, "find themselves caught in a loop\\n"
408 All the world's people
409 find themselves caught in a loop
413 pasm_output_is( <<CODE, <<OUTPUT, "entrytype" );
416 set S0, "Difference Engine #2"
418 set P0, "Shalmaneser"
431 LOOP: entrytype I0, I1
451 pasm_output_is( <<CODE, <<OUTPUT, "entrytype, beyond stack depth" );
462 pasm_output_is( <<'CODE', <<'OUTPUT', "depth op" );
488 pasm_output_is( <<'CODE', <<'OUTPUT', "saveall/restoreall" );
510 pasm_output_is( <<CODE, <<'OUTPUT', "lookback" );
511 @{[ $fp_equality_macro ]}
517 set P12["Apple"], "Banana"
534 .fp_eq (N0, 1.0, OK3)
551 .fp_eq (N0, 1.0, OK6)
577 skip( "no stack limit currently", 3 );
578 pasm_output_is( <<CODE, <<'OUTPUT', "check limit - User" );
584 Stack 'User' too deep
587 pasm_output_is( <<CODE, <<'OUTPUT', "check limit - Pad" );
596 pasm_output_is( <<CODE, <<'OUTPUT', "check limit - Control" );
601 Stack 'Control' too deep
604 ##############################
608 # cperl-indent-level: 4
611 # vim: expandtab shiftwidth=4: