2 # Copyright (C) 2001-2005, The Perl Foundation.
7 use lib qw( . lib ../lib ../../lib );
9 use Parrot::Test tests => 22;
10 use Math::Trig qw( tan sec atan asin acos asec cosh sinh tanh sech );
14 t/op/trans.t - Transcendental Mathematical Ops
22 Tests the transcendental mathematical operations.
26 # This defines two macros:
29 # which will conditionally branch
30 # to LABEL if abs(n,n) < epsilon
32 my $fp_equality_macro = <<'ENDOFMACRO';
42 gt N2, 0.000001, .$FPEQNOK
53 .macro fp_ne ( J,K,L )
62 lt N2, 0.000001, $FPNENOK
75 pasm_output_is( <<"CODE", <<OUTPUT, "sin" );
76 @{[ $fp_equality_macro ]}
79 .fp_eq (N2, 0.841471, EQ1)
85 .fp_eq (N2, 0.841471, EQ2)
95 pasm_output_is( <<"CODE", <<OUTPUT, "cos" );
96 @{[ $fp_equality_macro ]}
99 .fp_eq (N2, 0.540302, EQ1)
105 .fp_eq (N2, 0.540302, EQ2)
114 pasm_output_is( <<"CODE", <<OUTPUT, "tan" );
115 @{[ $fp_equality_macro ]}
118 .fp_eq (N2, 1.557408, EQ1)
124 .fp_eq (N2, 1.557408, EQ2)
133 pasm_output_is( <<"CODE", <<OUTPUT, "sec" );
134 @{[ $fp_equality_macro ]}
137 .fp_eq (N2, 1.850816, EQ1)
143 .fp_eq (N2, 1.850816, EQ2)
152 pasm_output_is( <<"CODE", <<OUTPUT, "atan" );
153 @{[ $fp_equality_macro ]}
156 .fp_eq (N2, 0.785398, EQ1)
162 .fp_eq (N2,0.785398 , EQ2)
171 pasm_output_is( <<"CODE", <<OUTPUT, "asin" );
172 @{[ $fp_equality_macro ]}
175 .fp_eq (N2, 1.570796, EQ1)
181 .fp_eq (N2, 1.570796 , EQ2)
191 pasm_output_is( <<"CODE", <<OUTPUT, "acos" );
192 @{[ $fp_equality_macro ]}
195 .fp_eq (N2, 0.000000, EQ1)
201 .fp_eq (N2, 0.000000, EQ2)
211 pasm_output_is( <<"CODE", <<OUTPUT, "asec" );
212 @{[ $fp_equality_macro ]}
215 .fp_eq (N2, 0.000000, EQ1)
221 .fp_eq (N2, 0.000000, EQ2)
231 pasm_output_is( <<"CODE", <<OUTPUT, "cosh" );
232 @{[ $fp_equality_macro ]}
235 .fp_eq (N2, 1.543081, EQ1)
241 .fp_eq (N2, 1.543081, EQ2)
251 pasm_output_is( <<"CODE", <<OUTPUT, "sinh" );
252 @{[ $fp_equality_macro ]}
255 .fp_eq (N2, 1.175201, EQ1)
261 .fp_eq (N2, 1.175201, EQ2)
271 pasm_output_is( <<"CODE", <<OUTPUT, "tanh" );
272 @{[ $fp_equality_macro ]}
275 .fp_eq (N2, 0.761594, EQ1)
281 .fp_eq (N2, 0.761594, EQ2)
291 pasm_output_is( <<"CODE", <<OUTPUT, "sech" );
292 @{[ $fp_equality_macro ]}
295 .fp_eq (N2, 0.648054, EQ1)
301 .fp_eq (N2, 0.648054, EQ2)
311 pasm_output_is( <<"CODE", <<OUTPUT, "atan2" );
312 @{[ $fp_equality_macro]}
323 .fp_eq (N4, 0.785398, EQ1)
328 .fp_eq (N4, 0.785398, EQ2)
333 .fp_eq (N4, 0.785398, EQ3)
338 .fp_eq (N4, 0.785398, EQ4)
343 .fp_eq (N4, -0.785398, EQ5)
348 .fp_eq (N4, 1.570796, EQ6)
353 .fp_eq (N4, -1.570796, EQ7)
358 .fp_eq (N4, -2.356194, EQ8)
363 .fp_eq (N4, 2.356194, EQ9)
368 .fp_eq (N4, 1.570796, EQ10)
370 EQ10: print "ok 10\\n"
373 .fp_eq (N4, 0.785398, EQ11)
375 EQ11: print "ok 11\\n"
378 .fp_eq (N4, 0.785398, EQ12)
380 EQ12: print "ok 12\\n"
383 .fp_eq (N4, 0.000000, EQ13)
385 EQ13: print "ok 13\\n"
388 .fp_eq (N4, -1.570796, EQ14)
390 EQ14: print "ok 14\\n"
393 .fp_eq (N4, 2.356194, EQ15)
395 EQ15: print "ok 15\\n"
398 .fp_eq (N4, 0.000000, EQ16)
400 EQ16: print "ok 16\\n"
421 pasm_output_is( <<"CODE", <<'OUTPUT', 'atan, part 2' );
422 @{[ $fp_equality_macro ]}
424 .fp_eq (N4, -3.1415926, EQ1)
433 pasm_output_is( <<"CODE", <<OUTPUT, "log2" );
434 @{[ $fp_equality_macro ]}
437 .fp_eq (N2, 3.321928, EQ1)
443 .fp_eq (N2, 3.321928, EQ2)
453 pasm_output_is( <<"CODE", <<OUTPUT, "log10" );
454 @{[ $fp_equality_macro ]}
457 .fp_eq (N2, 1.176091, EQ1)
463 .fp_eq (N2, 1.176091, EQ2)
473 pasm_output_is( <<"CODE", <<OUTPUT, "ln" );
474 @{[ $fp_equality_macro ]}
477 .fp_eq (N2, 2.302585, EQ1)
483 .fp_eq (N2, 2.302585, EQ2)
492 pasm_output_is( <<"CODE", <<OUTPUT, "exp" );
493 @{[ $fp_equality_macro ]}
496 .fp_eq (N2, 22026.465795, EQ1)
502 .fp_eq (N2, 22026.465795, EQ2)
511 pasm_output_is( <<"CODE", <<OUTPUT, "pow" );
512 @{[ $fp_equality_macro ]}
518 .fp_eq (N3, 243.0, EQ1)
523 .fp_eq (N3, 243.0, EQ2)
528 .fp_eq (N3, 243.0, EQ3)
533 .fp_eq (N3, 243.0, EQ4)
544 .fp_eq (N3, 32.0, EQ5)
549 .fp_eq (N3, 0.0625, EQ6)
554 .fp_eq (N3, 2.0, EQ7)
559 .fp_eq (N3, 1.0, EQ8)
564 .fp_eq (N3, 0.0, EQ9)
569 .fp_eq (N3, 1.0, EQ10)
571 EQ10: print "ok 10\\n"
574 .fp_eq (N3, 39.0625, EQ11)
576 EQ11: print "ok 11\\n"
579 .fp_eq (N3, 0.0625, EQ12)
581 EQ12: print "ok 12\\n"
584 .fp_eq (N3, 0.0, EQ13)
586 EQ13: print "ok 13\\n"
589 .fp_eq (N3, 0.5, EQ14)
591 EQ14: print "ok 14\\n"
594 .fp_eq (N3, 256.0, EQ15)
596 EQ15: print "ok 15\\n"
599 .fp_eq (N3, 0.25, EQ16)
601 EQ16: print "ok 16\\n"
622 pasm_output_is( <<"CODE", <<OUTPUT, "sqrt" );
623 @{[ $fp_equality_macro ]}
626 .fp_eq (N2, 3.0, EQ1)
632 .fp_eq (N2, 3.0, EQ2)
642 pasm_output_is( <<'CODE', <<OUTPUT, "pow_n_n_ic" );
697 pasm_output_is( <<'CODE', <<OUTPUT, "pow_n_n_i" );
770 # cperl-indent-level: 4
773 # vim: expandtab shiftwidth=4: