2 function arithAddIdentityWrittenAsInteger(x
) {
5 if (!(isNaN(x
) && isNaN(a
) && isNaN(b
)) && a
!== b
)
6 throw "Internal error on arithAddIdentityWrittenAsInteger, a = " + a
+ " b = " + b
;
9 noInline(arithAddIdentityWrittenAsInteger
);
11 function testArithAddIdentityWrittenAsInteger() {
12 for (var i
= 0; i
< 1e4
; ++i
) {
13 var result
= arithAddIdentityWrittenAsInteger(i
);
15 throw "arithAddIdentityWrittenAsInteger(i) = " + result
+ ", expected " + i
;
19 for (var i
= 0; i
< 1e4
; ++i
) {
20 var result
= arithAddIdentityWrittenAsInteger(-0);
22 throw "arithAddIdentityWrittenAsInteger(-0) = " + result
+ ", expected -0";
26 for (var i
= 0; i
< 1e4
; ++i
) {
27 var testValue
= i
+ .5;
28 var result
= arithAddIdentityWrittenAsInteger(testValue
);
29 if (result
!== testValue
) {
30 throw "arithAddIdentityWrittenAsInteger(i) = " + result
+ ", expected " + testValue
;
34 for (var i
= 0; i
< 1e4
; ++i
) {;
35 var result
= arithAddIdentityWrittenAsInteger(NaN
);
37 throw "arithAddIdentityWrittenAsInteger(NaN) = " + result
+ ", expected NaN";
41 for (var i
= 0; i
< 1e4
; ++i
) {;
42 var result
= arithAddIdentityWrittenAsInteger(Infinity
);
43 if (isFinite(result
)) {
44 throw "arithAddIdentityWrittenAsInteger(Infinity) = " + result
+ ", expected Infinity";
48 for (var i
= 0; i
< 1e4
; ++i
) {;
49 var result
= arithAddIdentityWrittenAsInteger(-Infinity
);
50 if (isFinite(result
) || result
>= 0) {
51 throw "arithAddIdentityWrittenAsInteger(-Infinity) = " + result
+ ", expected -Infinity";
55 testArithAddIdentityWrittenAsInteger();
58 function arithAddIdentityWrittenAsDouble(x
) {
61 if (!(isNaN(x
) && isNaN(a
) && isNaN(b
)) && a
!== b
)
62 throw "Internal error on arithAddIdentityWrittenAsDouble, a = " + a
+ " b = " + b
;
65 noInline(arithAddIdentityWrittenAsDouble
);
67 function testArithAddIdentityWrittenAsDouble() {
68 for (var i
= 0; i
< 1e4
; ++i
) {
69 var result
= arithAddIdentityWrittenAsDouble(i
);
71 throw "arithAddIdentityWrittenAsDouble(i) = " + result
+ ", expected " + i
;
75 for (var i
= 0; i
< 1e4
; ++i
) {
76 var result
= arithAddIdentityWrittenAsDouble(-0);
78 throw "arithAddIdentityWrittenAsDouble(-0) = " + result
+ ", expected -0 ";
82 for (var i
= 0; i
< 1e4
; ++i
) {
83 var testValue
= i
+ .5;
84 var result
= arithAddIdentityWrittenAsDouble(testValue
);
85 if (result
!== testValue
) {
86 throw "arithAddIdentityWrittenAsDouble(i) = " + result
+ ", expected " + testValue
;
90 for (var i
= 0; i
< 1e4
; ++i
) {;
91 var result
= arithAddIdentityWrittenAsDouble(NaN
);
93 throw "arithAddIdentityWrittenAsDouble(NaN) = " + result
+ ", expected NaN";
97 for (var i
= 0; i
< 1e4
; ++i
) {;
98 var result
= arithAddIdentityWrittenAsDouble(Infinity
);
99 if (isFinite(result
)) {
100 throw "arithAddIdentityWrittenAsDouble(Infinity) = " + result
+ ", expected Infinity";
104 for (var i
= 0; i
< 1e4
; ++i
) {;
105 var result
= arithAddIdentityWrittenAsDouble(-Infinity
);
106 if (isFinite(result
) || result
>= 0) {
107 throw "arithAddIdentityWrittenAsDouble(-Infinity) = " + result
+ ", expected -Infinity";
111 testArithAddIdentityWrittenAsDouble();
114 // Test "value + 42".
115 function arithAdd42WrittenAsInteger(x
) {
118 if (!(isNaN(x
) && isNaN(a
) && isNaN(b
)) && a
!== b
)
119 throw "Internal error on arithAdd42WrittenAsInteger, a = " + a
+ " b = " + b
;
122 noInline(arithAdd42WrittenAsInteger
);
124 function testArithAdd42WrittenAsInteger() {
125 for (var i
= 0; i
< 1e4
; ++i
) {
126 var result
= arithAdd42WrittenAsInteger(13);
128 throw "arithAdd42WrittenAsInteger(13) = " + result
+ ", expected 55";
132 for (var i
= 0; i
< 1e4
; ++i
) {
133 var result
= arithAdd42WrittenAsInteger(-0);
135 throw "arithAdd42WrittenAsInteger(-0) = " + result
+ ", expected 42";
139 for (var i
= 0; i
< 1e4
; ++i
) {
140 var result
= arithAdd42WrittenAsInteger(13.3);
141 if (result
!== 55.3) {
142 throw "arithAdd42WrittenAsInteger(13.3) = " + result
+ ", expected 55.3";
146 for (var i
= 0; i
< 1e4
; ++i
) {;
147 var result
= arithAdd42WrittenAsInteger(NaN
);
148 if (!isNaN(result
)) {
149 throw "arithAdd42WrittenAsInteger(NaN) = " + result
+ ", expected NaN";
153 for (var i
= 0; i
< 1e4
; ++i
) {;
154 var result
= arithAdd42WrittenAsInteger(Infinity
);
155 if (isFinite(result
)) {
156 throw "arithAdd42WrittenAsInteger(Infinity) = " + result
+ ", expected Infinity";
160 for (var i
= 0; i
< 1e4
; ++i
) {;
161 var result
= arithAdd42WrittenAsInteger(-Infinity
);
162 if (isFinite(result
) || result
>= 0) {
163 throw "arithAdd42WrittenAsInteger(-Infinity) = " + result
+ ", expected -Infinity";
167 testArithAdd42WrittenAsInteger();
172 // Test "value + 42".
173 function arithAdd42WrittenAsInteger(x
) {
176 if (!(isNaN(x
) && isNaN(a
) && isNaN(b
)) && a
!== b
)
177 throw "Internal error on arithAdd42WrittenAsInteger, a = " + a
+ " b = " + b
;
180 noInline(arithAdd42WrittenAsInteger
);
182 function testArithAdd42WrittenAsInteger() {
183 for (var i
= 0; i
< 1e4
; ++i
) {
184 var result
= arithAdd42WrittenAsInteger(13);
186 throw "arithAdd42WrittenAsInteger(13) = " + result
+ ", expected 55";
190 for (var i
= 0; i
< 1e4
; ++i
) {
191 var result
= arithAdd42WrittenAsInteger(-0);
193 throw "arithAdd42WrittenAsInteger(-0) = " + result
+ ", expected 42";
197 for (var i
= 0; i
< 1e4
; ++i
) {
198 var result
= arithAdd42WrittenAsInteger(13.3);
199 if (result
!== 55.3) {
200 throw "arithAdd42WrittenAsInteger(13.3) = " + result
+ ", expected 55.3";
204 for (var i
= 0; i
< 1e4
; ++i
) {;
205 var result
= arithAdd42WrittenAsInteger(NaN
);
206 if (!isNaN(result
)) {
207 throw "arithAdd42WrittenAsInteger(NaN) = " + result
+ ", expected NaN";
211 for (var i
= 0; i
< 1e4
; ++i
) {;
212 var result
= arithAdd42WrittenAsInteger(Infinity
);
213 if (isFinite(result
)) {
214 throw "arithAdd42WrittenAsInteger(Infinity) = " + result
+ ", expected Infinity";
218 for (var i
= 0; i
< 1e4
; ++i
) {;
219 var result
= arithAdd42WrittenAsInteger(-Infinity
);
220 if (isFinite(result
) || result
>= 0) {
221 throw "arithAdd42WrittenAsInteger(-Infinity) = " + result
+ ", expected -Infinity";
225 testArithAdd42WrittenAsInteger();
227 function arithSub42WrittenAsDouble(x
) {
228 var a
= (x
|0) - 42.0;
229 var b
= -42. + (x
|0);
230 if (!(isNaN(x
) && isNaN(a
) && isNaN(b
)) && a
!== b
)
231 throw "Internal error on arithSub42WrittenAsDouble, a = " + a
+ " b = " + b
;
234 noInline(arithSub42WrittenAsDouble
);
236 function testArithSub42WrittenAsDouble() {
237 for (var i
= 0; i
< 1e4
; ++i
) {
238 var result
= arithSub42WrittenAsDouble(13);
239 if (result
!== -29) {
240 throw "arithSub42WrittenAsDouble(13) = " + result
+ ", expected -29";
244 for (var i
= 0; i
< 1e4
; ++i
) {
245 var result
= arithSub42WrittenAsDouble(-0);
246 if (result
!== -42) {
247 throw "arithSub42WrittenAsDouble(-0) = " + result
+ ", expected -42";
251 for (var i
= 0; i
< 1e4
; ++i
) {
252 var result
= arithSub42WrittenAsDouble(13.3);
253 if (result
!== -29) {
254 throw "arithSub42WrittenAsDouble(13.3) = " + result
+ ", expected -29";
258 testArithSub42WrittenAsDouble();
261 function doubleConstant(){
264 } noInline(doubleConstant
);
266 function testDoubleConstant(){
267 for (var i
= 0; i
< 1e4
; ++i
) {
271 testDoubleConstant();