1 // If y is NaN, the result is NaN.
2 function testIntegerBaseWithNaNExponentStatic() {
3 for (var i
= 0; i
< 10000; ++i
) {
4 var result
= Math
.pow(5, NaN
);
6 throw "Error: bad result, Math.pow(5, NaN) = " + result
;
8 for (var i
= 0; i
< 10000; ++i
) {
9 var result
= Math
.pow(i
, NaN
);
11 throw "Error: bad result, Math.pow(i, NaN) = " + result
+ " with i = " + i
;
14 noInline(testIntegerBaseWithNaNExponentStatic
);
15 testIntegerBaseWithNaNExponentStatic();
17 function mathPowIntegerBaseWithNaNExponentDynamic(x
, y
) {
18 return Math
.pow(x
, y
);
20 noInline(mathPowIntegerBaseWithNaNExponentDynamic
);
21 function testIntegerBaseWithNaNExponentDynamic() {
22 // Warm up with 2 integers.
23 for (var i
= 0; i
< 10000; ++i
) {
24 var result
= mathPowIntegerBaseWithNaNExponentDynamic(2, 5);
26 throw "Error: bad result, mathPowIntegerBaseWithNaNExponentDynamic(2, 5) = " + result
+ ", expected 32."
29 for (var i
= 0; i
< 10000; ++i
) {
30 var result
= mathPowIntegerBaseWithNaNExponentDynamic(i
, NaN
);
32 throw "Error: bad result, mathPowIntegerBaseWithNaNExponentDynamic(i, NaN) = " + result
+ " with i = " + i
+ ", expected NaN";
35 noInline(testIntegerBaseWithNaNExponentDynamic
);
36 testIntegerBaseWithNaNExponentDynamic();
38 function testFloatingPointBaseWithNaNExponentStatic() {
39 for (var i
= 0; i
< 10000; ++i
) {
40 var result
= Math
.pow(5.5, NaN
);
42 throw "Error: bad result, Math.pow(5.5, NaN) = " + result
;
44 for (var i
= 0; i
< 10000; ++i
) {
45 var result
= Math
.pow(i
+ 0.5, NaN
);
47 throw "Error: bad result, Math.pow(i + 0.5, NaN) = " + result
+ " with i = " + i
;
50 noInline(testFloatingPointBaseWithNaNExponentStatic
);
51 testFloatingPointBaseWithNaNExponentStatic();
53 function mathPowFloatingPointBaseWithNaNExponentDynamic(x
, y
) {
54 return Math
.pow(x
, y
);
56 noInline(mathPowFloatingPointBaseWithNaNExponentDynamic
);
57 function testFloatingPointBaseWithNaNExponentDynamic() {
58 // Warm up with 2 double.
59 for (var i
= 0; i
< 10000; ++i
) {
60 var result
= mathPowFloatingPointBaseWithNaNExponentDynamic(2.5, 5.1);
61 if (result
!== 107.02717054543135)
62 throw "Error: bad result, mathPowFloatingPointBaseWithNaNExponentDynamic(2.5, 5.1) = " + result
+ ", expected 107.02717054543135."
65 for (var i
= 0; i
< 10000; ++i
) {
66 var result
= mathPowFloatingPointBaseWithNaNExponentDynamic(i
+ 0.5, NaN
);
68 throw "Error: bad result, mathPowFloatingPointBaseWithNaNExponentDynamic(i + 0.5, NaN) = " + result
+ " with i = " + i
+ ", expected NaN";
71 noInline(testFloatingPointBaseWithNaNExponentDynamic
);
72 testFloatingPointBaseWithNaNExponentDynamic();
74 // If y is +0, the result is 1, even if x is NaN.
75 // If y is −0, the result is 1, even if x is NaN.
76 // If x is NaN and y is nonzero, the result is NaN.
77 function testNaNBaseStatic() {
78 for (var i
= 0; i
< 10000; ++i
) {
79 var result
= Math
.pow(NaN
, i
+ 1);
81 throw "Error: bad result, Math.pow(NaN, i + 1) = " + result
+ " with i = " + i
;
83 for (var i
= 0; i
< 10000; ++i
) {
84 var result
= Math
.pow(NaN
, i
+ 1.5);
86 throw "Error: bad result, Math.pow(NaN, i + 1.5) = " + result
+ " with i = " + i
;
88 for (var i
= 0; i
< 10000; ++i
) {
89 var result
= Math
.pow(NaN
, 0);
91 throw "Error: bad result, Math.pow(NaN, 0) = " + result
;
93 for (var i
= 0; i
< 10000; ++i
) {
94 var result
= Math
.pow(NaN
, -0);
96 throw "Error: bad result, Math.pow(NaN, -0) = " + result
;
99 noInline(testNaNBaseStatic
);
102 function mathPowNaNBaseDynamic1(x
, y
) {
103 return Math
.pow(x
, y
);
105 function mathPowNaNBaseDynamic2(x
, y
) {
106 return Math
.pow(x
, y
);
108 function mathPowNaNBaseDynamic3(x
, y
) {
109 return Math
.pow(x
, y
);
111 function mathPowNaNBaseDynamic4(x
, y
) {
112 return Math
.pow(x
, y
);
114 noInline(mathPowNaNBaseDynamic1
);
115 noInline(mathPowNaNBaseDynamic2
);
116 noInline(mathPowNaNBaseDynamic3
);
117 noInline(mathPowNaNBaseDynamic4
);
118 function testNaNBaseDynamic() {
119 for (var i
= 0; i
< 10000; ++i
) {
120 var result
= mathPowNaNBaseDynamic1(NaN
, i
+ 1);
122 throw "Error: bad result, mathPowNaNBaseDynamic1(NaN, i + 1) = " + result
+ " with i = " + i
;
124 for (var i
= 0; i
< 10000; ++i
) {
125 var result
= mathPowNaNBaseDynamic2(NaN
, i
+ 1.5);
127 throw "Error: bad result, mathPowNaNBaseDynamic2(NaN, i + 1.5) = " + result
+ " with i = " + i
;
129 for (var i
= 0; i
< 10000; ++i
) {
130 var result
= mathPowNaNBaseDynamic3(NaN
, 0);
132 throw "Error: bad result, mathPowNaNBaseDynamic3(NaN, 0) = " + result
;
134 for (var i
= 0; i
< 10000; ++i
) {
135 var result
= mathPowNaNBaseDynamic4(NaN
, -0);
137 throw "Error: bad result, mathPowNaNBaseDynamic4(NaN, -0) = " + result
;
140 noInline(testNaNBaseDynamic
);
141 testNaNBaseDynamic();
143 // If abs(x) is 1 and y is +∞, the result is NaN.
144 // If abs(x) is 1 and y is −∞, the result is NaN.
145 function infiniteExponentsStatic() {
146 for (var i
= 0; i
< 10000; ++i
) {
147 var result
= Math
.pow(1, Number
.POSITIVE_INFINITY
);
149 throw "Error: bad result, Math.pow(1, Number.POSITIVE_INFINITY) = " + result
;
151 for (var i
= 0; i
< 10000; ++i
) {
152 var result
= Math
.pow(-1, Number
.POSITIVE_INFINITY
);
154 throw "Error: bad result, Math.pow(-1, Number.POSITIVE_INFINITY) = " + result
;
156 for (var i
= 0; i
< 10000; ++i
) {
157 var result
= Math
.pow(1, Number
.NEGATIVE_INFINITY
);
159 throw "Error: bad result, Math.pow(1, Number.NEGATIVE_INFINITY) = " + result
;
161 for (var i
= 0; i
< 10000; ++i
) {
162 var result
= Math
.pow(-1, Number
.NEGATIVE_INFINITY
);
164 throw "Error: bad result, Math.pow(-1, Number.NEGATIVE_INFINITY) = " + result
;
167 noInline(infiniteExponentsStatic
);
168 infiniteExponentsStatic();
170 function mathPowInfiniteExponentsDynamic1(x
, y
) {
171 return Math
.pow(x
, y
);
173 function mathPowInfiniteExponentsDynamic2(x
, y
) {
174 return Math
.pow(x
, y
);
176 function mathPowInfiniteExponentsDynamic3(x
, y
) {
177 return Math
.pow(x
, y
);
179 function mathPowInfiniteExponentsDynamic4(x
, y
) {
180 return Math
.pow(x
, y
);
182 noInline(mathPowInfiniteExponentsDynamic1
);
183 noInline(mathPowInfiniteExponentsDynamic2
);
184 noInline(mathPowInfiniteExponentsDynamic3
);
185 noInline(mathPowInfiniteExponentsDynamic4
);
186 function infiniteExponentsDynamic() {
187 for (var i
= 0; i
< 10000; ++i
) {
188 var result
= mathPowInfiniteExponentsDynamic1(1, Number
.POSITIVE_INFINITY
);
190 throw "Error: bad result, mathPowInfiniteExponentsDynamic1(1, Number.POSITIVE_INFINITY) = " + result
;
192 for (var i
= 0; i
< 10000; ++i
) {
193 var result
= mathPowInfiniteExponentsDynamic2(-1, Number
.POSITIVE_INFINITY
);
195 throw "Error: bad result, mathPowInfiniteExponentsDynamic2(-1, Number.POSITIVE_INFINITY) = " + result
;
197 for (var i
= 0; i
< 10000; ++i
) {
198 var result
= mathPowInfiniteExponentsDynamic3(1, Number
.NEGATIVE_INFINITY
);
200 throw "Error: bad result, mathPowInfiniteExponentsDynamic3(1, Number.NEGATIVE_INFINITY) = " + result
;
202 for (var i
= 0; i
< 10000; ++i
) {
203 var result
= mathPowInfiniteExponentsDynamic4(-1, Number
.NEGATIVE_INFINITY
);
205 throw "Error: bad result, mathPowInfiniteExponentsDynamic4(-1, Number.NEGATIVE_INFINITY) = " + result
;
208 noInline(infiniteExponentsDynamic
);
209 infiniteExponentsDynamic();