]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/float64-array-nan-inlined.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / float64-array-nan-inlined.js
1 function foo(o) {
2 return o[0];
3 }
4
5 function isBigEndian() {
6 var word = new Int16Array(1);
7 word[0] = 1;
8 var bytes = new Int8Array(word.buffer);
9 return !bytes[0];
10 }
11
12 function test(a, b, x) {
13 var intArray = new Int32Array(2);
14 intArray[0] = a;
15 intArray[1] = b;
16 var floatArray = new Float64Array(intArray.buffer);
17 var element = foo(floatArray);
18 var result = element + 1;
19 if (("" + result) != ("" + x))
20 throw "Error: bad result for " + a + ", " + b + ": " + result + ", but expected: " + x + "; loaded " + element + " from the array";
21 }
22
23 noInline(test);
24
25 for (var i = 0; i < 100000; ++i)
26 test(0, 0, 1);
27
28 if (isBigEndian()) {
29 test(0xFFFF0000, 0, 0/0);
30 test(0, 0xFFFF0000, 1);
31 } else {
32 test(0xFFFF0000, 0, 1);
33 test(0, 0xFFFF0000, 0/0);
34 }