1 function exponentIsZero(x
) {
4 noInline(exponentIsZero
);
6 function testExponentIsZero() {
7 for (var i
= 0; i
< 10000; ++i
) {
8 var result
= exponentIsZero(5);
10 throw "Error: zeroExponent(5) should be 1, was = " + result
;
12 for (var i
= 0; i
< 10000; ++i
) {
13 var result
= exponentIsZero(5.5);
15 throw "Error: zeroExponent(5.5) should be 1, was = " + result
;
21 function exponentIsOne(x
) {
22 return Math
.pow(x
, 1);
24 noInline(exponentIsOne
);
26 function testExponentIsOne() {
27 for (var i
= 0; i
< 10000; ++i
) {
28 var result
= exponentIsOne(5);
30 throw "Error: exponentIsOne(5) should be 5, was = " + result
;
32 for (var i
= 0; i
< 10000; ++i
) {
33 var result
= exponentIsOne(5.5);
35 throw "Error: exponentIsOne(5.5) should be 5.5, was = " + result
;
41 function powUsedAsSqrt(x
) {
42 return Math
.pow(x
, 0.5);
44 noInline(powUsedAsSqrt
);
46 function testPowUsedAsSqrt() {
47 for (var i
= 0; i
< 10000; ++i
) {
48 var result
= powUsedAsSqrt(4);
49 if (result
!== Math
.sqrt(4))
50 throw "Error: powUsedAsSqrt(4) should be 2, was = " + result
;
52 for (var i
= 0; i
< 10000; ++i
) {
53 var result
= powUsedAsSqrt(4.4);
54 if (result
!== Math
.sqrt(4.4))
55 throw "Error: powUsedAsSqrt(4) should be " + Math
.sqrt(4.4) + ", was = " + result
;
62 function intIntConstantsSmallNumbers() {
63 return Math
.pow(42, 3);
65 function intIntConstantsLargeNumbers() {
66 // The result does not fit in a integer.
67 return Math
.pow(42, 42);
69 function intIntSmallConstants() {
70 return Math
.pow(42, 3);
72 function intDoubleConstants() {
73 return Math
.pow(14, 42.5);
75 function doubleDoubleConstants() {
76 return Math
.pow(13.5, 42.5);
78 function doubleIntConstants() {
79 return Math
.pow(13.5, 52);
81 noInline(intIntConstantsSmallNumbers
);
82 noInline(intIntConstantsLargeNumbers
);
83 noInline(intDoubleConstants
);
84 noInline(doubleDoubleConstants
);
85 noInline(doubleIntConstants
);
87 function testBaseAndExponentConstantLiterals()
89 for (var i
= 0; i
< 10000; ++i
) {
90 var result
= intIntConstantsSmallNumbers();
92 throw "Error: intIntConstantsSmallNumbers() should be 74088, was = " + result
;
94 for (var i
= 0; i
< 10000; ++i
) {
95 var result
= intIntConstantsLargeNumbers();
96 if (result
!== 1.5013093754529656e+68)
97 throw "Error: intIntConstantsLargeNumbers() should be 1.5013093754529656e+68, was = " + result
;
99 for (var i
= 0; i
< 10000; ++i
) {
100 var result
= intDoubleConstants();
101 if (result
!== 5.1338303882015765e+48)
102 throw "Error: intDoubleConstants() should be 5.1338303882015765e+48, was = " + result
;
104 for (var i
= 0; i
< 10000; ++i
) {
105 var result
= doubleDoubleConstants();
106 if (result
!== 1.0944228729647829e+48)
107 throw "Error: doubleDoubleConstants() should be 1.0944228729647829e+48, was = " + result
;
109 for (var i
= 0; i
< 10000; ++i
) {
110 var result
= doubleIntConstants();
111 if (result
!== 5.989022735311158e+58)
112 throw "Error: doubleIntConstants() should be 5.989022735311158e+58, was = " + result
;
115 testBaseAndExponentConstantLiterals();
118 function exponentIsIntegerConstant(x
) {
119 return Math
.pow(x
, 42);
121 noInline(exponentIsIntegerConstant
);
123 function testExponentIsIntegerConstant() {
124 for (var i
= 0; i
< 1000; ++i
) {
125 var result
= exponentIsIntegerConstant(2);
126 if (result
!== 4398046511104)
127 throw "Error: exponentIsIntegerConstant(2) should be 4398046511104, was = " + result
;
129 for (var i
= 0; i
< 1000; ++i
) {
130 var result
= exponentIsIntegerConstant(5);
131 if (result
!== 2.2737367544323207e+29)
132 throw "Error: exponentIsIntegerConstant(5) should be 2.2737367544323207e+29, was = " + result
;
134 for (var i
= 0; i
< 1000; ++i
) {
135 var result
= exponentIsIntegerConstant(2.1);
136 if (result
!== 34135823067412.42)
137 throw "Error: exponentIsIntegerConstant(2.1) should be 34135823067412.42, was = " + result
;
140 testExponentIsIntegerConstant();
143 function exponentIsDoubleConstant(x
) {
144 return Math
.pow(x
, 42.5);
146 noInline(exponentIsDoubleConstant
);
148 function testExponentIsDoubleConstant() {
149 for (var i
= 0; i
< 1000; ++i
) {
150 var result
= exponentIsDoubleConstant(2);
151 if (result
!== 6219777023950.95)
152 throw "Error: exponentIsDoubleConstant(2) should be 6219777023950.95, was = " + result
;
154 for (var i
= 0; i
< 1000; ++i
) {
155 var result
= exponentIsDoubleConstant(5);
156 if (result
!== 5.084229945850415e+29)
157 throw "Error: exponentIsDoubleConstant(5) should be 5.084229945850415e+29, was = " + result
;
159 for (var i
= 0; i
< 1000; ++i
) {
160 var result
= exponentIsDoubleConstant(2.1);
161 if (result
!== 49467507261113.805)
162 throw "Error: exponentIsDoubleConstant(2.1) should be 49467507261113.805, was = " + result
;
165 testExponentIsDoubleConstant();
168 function exponentIsInfinityConstant(x
) {
169 return Math
.pow(x
, Infinity
);
171 noInline(exponentIsInfinityConstant
);
173 function testExponentIsInfinityConstant() {
174 for (var i
= 0; i
< 1000; ++i
) {
175 var result
= exponentIsInfinityConstant(2);
176 if (result
!== Infinity
)
177 throw "Error: exponentIsInfinityConstant(2) should be Infinity, was = " + result
;
179 for (var i
= 0; i
< 1000; ++i
) {
180 var result
= exponentIsInfinityConstant(5);
181 if (result
!== Infinity
)
182 throw "Error: exponentIsInfinityConstant(5) should be Infinity, was = " + result
;
184 for (var i
= 0; i
< 1000; ++i
) {
185 var result
= exponentIsInfinityConstant(2.1);
186 if (result
!== Infinity
)
187 throw "Error: exponentIsInfinityConstant(2.1) should be Infinity, was = " + result
;
190 testExponentIsInfinityConstant();
193 function exponentIsNegativeInfinityConstant(x
) {
194 return Math
.pow(x
, -Infinity
);
196 noInline(exponentIsNegativeInfinityConstant
);
198 function testExponentIsNegativeInfinityConstant() {
199 for (var i
= 0; i
< 1000; ++i
) {
200 var result
= exponentIsNegativeInfinityConstant(2);
202 throw "Error: exponentIsNegativeInfinityConstant(2) should be zero, was = " + result
;
204 for (var i
= 0; i
< 1000; ++i
) {
205 var result
= exponentIsNegativeInfinityConstant(5);
207 throw "Error: exponentIsNegativeInfinityConstant(5) should be zero, was = " + result
;
209 for (var i
= 0; i
< 1000; ++i
) {
210 var result
= exponentIsNegativeInfinityConstant(2.1);
212 throw "Error: exponentIsNegativeInfinityConstant(2.1) should be zero, was = " + result
;
215 testExponentIsNegativeInfinityConstant();