2 # Copyright (C) 2001-2005, The Perl Foundation.
7 use lib qw( . lib ../lib ../../lib );
9 use Parrot::Test tests => 20;
13 t/pmc/n_arithmetics.t - n_* Arithmetic Ops
17 % prove t/pmc/n_arithmetics.t
21 Tests basic arithmetic ops that construct a new return value on
22 various combinations of Parrot integer and number types.
27 ### Operations on a single INTVAL
29 pir_output_is( <<'CODE', <<OUTPUT, "take the negative of an Integer" );
38 ## negate a positive number.
43 ## check that we are not reusing P1.
44 ne_addr P30, P1, not_broken
47 ## negate a negative number.
59 pir_output_is( <<'CODE', <<OUTPUT, "take the absolute value of an Integer" );
62 ## find absolute zero (so to speak).
68 ## find the absolute value of a positive Integer.
73 ## check that we are not reusing P1.
74 ne_addr P30, P1, not_broken
77 ## find the absolute value of a negative number.
90 ### first arg is Integer, second arg is Integer
92 pir_output_is( <<'CODE', <<OUTPUT, "add Integer to Integer" );
107 ## check that we are not reusing P2.
108 ne_addr P30, P2, not_broken
111 ## check adding constants.
126 pir_output_is( <<'CODE', <<OUTPUT, "subtract Integer from Integer" );
141 ## check that we are not reusing P2.
142 ne_addr P30, P2, not_broken
145 ## check subtracting constants.
160 pir_output_is( <<'CODE', <<OUTPUT, "multiply Integer with Integer" );
174 ## check multiplying constants.
189 pir_output_is( <<'CODE', <<OUTPUT, "divide Integer by Integer" );
203 ## check dividing by constants.
219 ### Operations on a single NUMVAL
221 pir_output_is( <<'CODE', <<OUTPUT, "negate a Float" );
248 pir_output_is( <<'CODE', <<OUTPUT, "take the absolute value of a Float" );
263 set P0, -123.45678901
276 ### FLOATVAL and INTVAL tests
278 pir_output_is( <<'CODE', <<OUTPUT, "add Integer to Float" );
291 ## check that we are not reusing P1.
292 ne_addr P30, P1, not_broken
309 pir_output_is( <<'CODE', <<OUTPUT, "subtract Integer from Float" );
322 ## check that we are not reusing P1.
323 ne_addr P30, P1, not_broken
340 pir_output_is( <<'CODE', <<OUTPUT, "multiply Float with Integer" );
353 ## check that we are not reusing P1.
354 ne_addr P30, P1, not_broken
371 pir_output_is( <<'CODE', <<OUTPUT, "divide Float by Integer" );
384 ## check that we are not reusing P1.
385 ne_addr P30, P1, not_broken
408 ### FLOATVAL and FLOATVAL tests
410 pir_output_is( <<'CODE', <<OUTPUT, "add Float to Float" );
425 ## check that we are not reusing P2.
426 ne_addr P30, P2, not_broken
435 ## This tests n_infix_ic_p_p_nc for n_add, n_sub, n_mul, and n_div. Note that
436 ## there is no n_infix_ic_p_nc_p op; the PMC argument always comes first.
437 pir_output_is( <<'CODE', <<OUTPUT, "add/sub/mul/div of Float with constants" );
463 pir_output_is( <<'CODE', <<OUTPUT, "subtract Float from Float" );
478 ## check that we are not reusing P2.
479 ne_addr P30, P2, not_broken
488 pir_output_is( <<'CODE', <<OUTPUT, "multiply Float with Float" );
503 ## check that we are not reusing P2.
504 ne_addr P30, P2, not_broken
513 pir_output_is( <<'CODE', <<OUTPUT, "divide Float by Float" );
528 ## check that we are not reusing P2.
529 ne_addr P30, P2, not_broken
538 pir_output_is( <<'CODE', <<'OUTPUT', "verify new PMC" );
556 pir_output_is( <<'CODE', <<'OUTPUT', ".pragma n_operators" );
557 .pragma n_operators 1
576 pir_output_is( <<'CODE', <<'OUTPUT', ".pragma n_operators - inplace" );
577 .pragma n_operators 1
592 # cperl-indent-level: 4
595 # vim: expandtab shiftwidth=4: