2 function arithMulIdentityWrittenAsInteger(x
) {
5 if (!(isNaN(x
) && isNaN(a
) && isNaN(b
)) && a
!== b
)
6 throw "Internal error on arithMulIdentityWrittenAsInteger, a = " + a
+ " b = " + b
;
9 noInline(arithMulIdentityWrittenAsInteger
);
11 function testArithMulIdentityWrittenAsInteger() {
12 for (var i
= 0; i
< 1e4
; ++i
) {
13 var result
= arithMulIdentityWrittenAsInteger(i
);
15 throw "arithMulIdentityWrittenAsInteger(i) = " + result
+ ", expected " + i
;
19 for (var i
= 0; i
< 1e4
; ++i
) {
20 var result
= arithMulIdentityWrittenAsInteger(-0);
22 throw "arithMulIdentityWrittenAsInteger(-0) = " + result
+ ", expected -0";
26 for (var i
= 0; i
< 1e4
; ++i
) {
27 var testValue
= i
+ .5;
28 var result
= arithMulIdentityWrittenAsInteger(testValue
);
29 if (result
!== testValue
) {
30 throw "arithMulIdentityWrittenAsInteger(i) = " + result
+ ", expected " + testValue
;
34 for (var i
= 0; i
< 1e4
; ++i
) {;
35 var result
= arithMulIdentityWrittenAsInteger(NaN
);
37 throw "arithMulIdentityWrittenAsInteger(NaN) = " + result
+ ", expected NaN";
41 for (var i
= 0; i
< 1e4
; ++i
) {;
42 var result
= arithMulIdentityWrittenAsInteger(Infinity
);
43 if (isFinite(result
)) {
44 throw "arithMulIdentityWrittenAsInteger(Infinity) = " + result
+ ", expected Infinity";
48 for (var i
= 0; i
< 1e4
; ++i
) {;
49 var result
= arithMulIdentityWrittenAsInteger(-Infinity
);
50 if (isFinite(result
) || result
>= 0) {
51 throw "arithMulIdentityWrittenAsInteger(-Infinity) = " + result
+ ", expected -Infinity";
55 testArithMulIdentityWrittenAsInteger();
58 function arithMulIdentityWrittenAsDouble(x
) {
61 if (!(isNaN(x
) && isNaN(a
) && isNaN(b
)) && a
!== b
)
62 throw "Internal error on arithMulIdentityWrittenAsDouble, a = " + a
+ " b = " + b
;
65 noInline(arithMulIdentityWrittenAsDouble
);
67 function testArithMulIdentityWrittenAsDouble() {
68 for (var i
= 0; i
< 1e4
; ++i
) {
69 var result
= arithMulIdentityWrittenAsDouble(i
);
71 throw "arithMulIdentityWrittenAsDouble(i) = " + result
+ ", expected " + i
;
75 for (var i
= 0; i
< 1e4
; ++i
) {
76 var result
= arithMulIdentityWrittenAsDouble(-0);
78 throw "arithMulIdentityWrittenAsDouble(-0) = " + result
+ ", expected -0 ";
82 for (var i
= 0; i
< 1e4
; ++i
) {
83 var testValue
= i
+ .5;
84 var result
= arithMulIdentityWrittenAsDouble(testValue
);
85 if (result
!== testValue
) {
86 throw "arithMulIdentityWrittenAsDouble(i) = " + result
+ ", expected " + testValue
;
90 for (var i
= 0; i
< 1e4
; ++i
) {;
91 var result
= arithMulIdentityWrittenAsDouble(NaN
);
93 throw "arithMulIdentityWrittenAsDouble(NaN) = " + result
+ ", expected NaN";
97 for (var i
= 0; i
< 1e4
; ++i
) {;
98 var result
= arithMulIdentityWrittenAsDouble(Infinity
);
99 if (isFinite(result
)) {
100 throw "arithMulIdentityWrittenAsDouble(Infinity) = " + result
+ ", expected Infinity";
104 for (var i
= 0; i
< 1e4
; ++i
) {;
105 var result
= arithMulIdentityWrittenAsDouble(-Infinity
);
106 if (isFinite(result
) || result
>= 0) {
107 throw "arithMulIdentityWrittenAsDouble(-Infinity) = " + result
+ ", expected -Infinity";
111 testArithMulIdentityWrittenAsDouble();
114 // Test "value * 42".
115 function arithMul42WrittenAsInteger(x
) {
118 if (!(isNaN(x
) && isNaN(a
) && isNaN(b
)) && a
!== b
)
119 throw "Internal error on arithMul42WrittenAsInteger, a = " + a
+ " b = " + b
;
122 noInline(arithMul42WrittenAsInteger
);
124 function testArithMul42WrittenAsInteger() {
125 for (var i
= 0; i
< 1e4
; ++i
) {
126 var result
= arithMul42WrittenAsInteger(13);
127 if (result
!== 546) {
128 throw "arithMul42WrittenAsInteger(13) = " + result
+ ", expected 546";
132 for (var i
= 0; i
< 1e4
; ++i
) {
133 var result
= arithMul42WrittenAsInteger(-0);
135 throw "arithMul42WrittenAsInteger(-0) = " + result
+ ", expected -0";
139 for (var i
= 0; i
< 1e4
; ++i
) {
140 var result
= arithMul42WrittenAsInteger(13.3);
141 if (result
!== 558.6) {
142 throw "arithMul42WrittenAsInteger(13.3) = " + result
+ ", expected 558.6";
146 for (var i
= 0; i
< 1e4
; ++i
) {;
147 var result
= arithMul42WrittenAsInteger(NaN
);
148 if (!isNaN(result
)) {
149 throw "arithMul42WrittenAsInteger(NaN) = " + result
+ ", expected NaN";
153 for (var i
= 0; i
< 1e4
; ++i
) {;
154 var result
= arithMul42WrittenAsInteger(Infinity
);
155 if (isFinite(result
)) {
156 throw "arithMul42WrittenAsInteger(Infinity) = " + result
+ ", expected Infinity";
160 for (var i
= 0; i
< 1e4
; ++i
) {;
161 var result
= arithMul42WrittenAsInteger(-Infinity
);
162 if (isFinite(result
) || result
>= 0) {
163 throw "arithMul42WrittenAsInteger(-Infinity) = " + result
+ ", expected -Infinity";
167 testArithMul42WrittenAsInteger();
170 function arithMul42WrittenAsDouble(x
) {
173 if (!(isNaN(x
) && isNaN(a
) && isNaN(b
)) && a
!== b
)
174 throw "Internal error on arithMul42WrittenAsDouble, a = " + a
+ " b = " + b
;
177 noInline(arithMul42WrittenAsDouble
);
179 function testArithMul42WrittenAsDouble() {
180 for (var i
= 0; i
< 1e4
; ++i
) {
181 var result
= arithMul42WrittenAsDouble(13);
182 if (result
!== 546) {
183 throw "arithMul42WrittenAsDouble(i) = " + result
+ ", expected 546";
187 for (var i
= 0; i
< 1e4
; ++i
) {
188 var result
= arithMul42WrittenAsDouble(-0);
190 throw "arithMul42WrittenAsDouble(-0) = " + result
+ ", expected -0";
194 for (var i
= 0; i
< 1e4
; ++i
) {
195 var result
= arithMul42WrittenAsDouble(13.3);
196 if (result
!== 558.6) {
197 throw "arithMul42WrittenAsDouble(13.3) = " + result
+ ", expected 558.6";
201 for (var i
= 0; i
< 1e4
; ++i
) {;
202 var result
= arithMul42WrittenAsDouble(NaN
);
203 if (!isNaN(result
)) {
204 throw "arithMul42WrittenAsDouble(NaN) = " + result
+ ", expected NaN";
208 for (var i
= 0; i
< 1e4
; ++i
) {;
209 var result
= arithMul42WrittenAsDouble(Infinity
);
210 if (isFinite(result
)) {
211 throw "arithMul42WrittenAsDouble(Infinity) = " + result
+ ", expected Infinity";
215 for (var i
= 0; i
< 1e4
; ++i
) {;
216 var result
= arithMul42WrittenAsDouble(-Infinity
);
217 if (isFinite(result
) || result
>= 0) {
218 throw "arithMul42WrittenAsDouble(-Infinity) = " + result
+ ", expected -Infinity";
222 testArithMul42WrittenAsDouble();