2 # Copyright (C) 2009-2010, Parrot Foundation.
7 t/op/inf_nan.t - Test math properties of Inf and NaN
11 % prove t/op/inf_nan.t
15 Tests for mathematical operations with Inf and Nan.
20 .include 'test_more.pir'
30 test_fdiv_integer_pmc_nan()
31 test_fdiv_float_pmc_nan()
32 test_fdiv_float_integer_pmc_nan()
33 test_mod_float_integer_pmc_nan()
39 is($N0, 'Inf', 'basic arithmetic: =')
41 is($N0, 'NaN', '... -=')
43 is($N0, 'NaN', '... *= -1')
45 is($N0, 'NaN', '... *= 0')
47 is($N0, 'NaN', '... += 5')
49 is($N0, 'NaN', '... -= 42')
51 is($N0, 'NaN', '... inc')
53 is($N0, 'NaN', '... dec')
55 is($N2, 'NaN', '... abs NaN')
58 is($N3, 'Inf', '... abs Inf')
61 is($N3, 'Inf', '... abs -Inf')
67 is($N1, 'Inf', 'sqrt: assignment')
70 is($N1, 'NaN', '... sqrt -Inf')
73 is($N1, 'NaN', '... sqrt NaN')
76 is($N1, 'NaN', '... sqrt -1')
82 is($N1, '-Inf', 'negative: neg Inf')
85 is($N1, 'Inf', '... neg -Inf')
88 is($N1, 'NaN', '... neg NaN')
95 is($N0, 'NaN', 'mixing NaN and Inf: NaN * Inf')
97 is($N0, 'NaN', '... NaN / Inf')
99 is($N0, 'NaN', '... NaN - Inf')
101 is($N0, 'NaN', '... NaN + Inf')
107 is($N1, 'NaN', 'rounding n: floor NaN')
109 is($N2, 'NaN', '... ceil NaN')
112 is($N1, 'Inf', '... floor Inf')
114 is($N2, 'Inf', '... ceil Inf')
117 is($N1, '-Inf', '... floor -Inf')
119 is($N2, '-Inf', '... ceil -Inf')
122 #pir_output_is(<<'CODE',<<OUTPUT, "TT #370 Rounding inf/nan");
126 #is($I0, 'Inf', 'floor Inf')
127 skip(1, 'rounding nan/inf gives something like -2147483648')
130 #is($I0, 'NaN', 'floor Inf')
131 skip(1, 'rounding nan/inf gives something like -2147483648')
134 #is($I0, 'Inf', 'floor Inf')
135 skip(1, 'rounding nan/inf gives something like -2147483648')
138 #is($I0, 'NaN', 'floor Inf')
139 skip(1, 'rounding nan/inf gives something like -2147483648')
142 .sub test_nan_complex
143 $P1 = new ["Complex"]
147 #is($P1, 'NaN', '1+i + NaN')
148 skip(1, '1+i + NaN should be NaN')
151 .sub test_fdiv_integer_pmc_nan
157 #is($P1, 'NaN', 'fdiv with Integer PMCs and NaN')
158 skip(1, 'fdiv/mod do not play nicely with PMCs and NaN')
161 .sub test_fdiv_float_pmc_nan
167 #is($P1, 'NaN','fdiv with Float PMCs and NaN')
168 skip(1, 'fdiv/mod do not play nicely with PMCs and NaN')
171 .sub test_fdiv_float_integer_pmc_nan
177 #is($P1, 'NaN', 'fdiv with Float and Integer PMCs and NaN')
178 skip(1, 'fdiv/mod do not play nicely with PMCs and NaN')
181 .sub test_mod_float_integer_pmc_nan
187 #is($P1, 'NaN', 'mod with Float and Integer PMCs and NaN')
188 skip(1, 'fdiv/mod do not play nicely with PMCs and NaN')
195 # vim: expandtab shiftwidth=4 ft=pir: