]>
Commit | Line | Data |
---|---|---|
81345200 A |
1 | function foo(o) { |
2 | return o[0]; | |
3 | } | |
4 | ||
5 | noInline(foo); | |
6 | ||
7 | function isBigEndian() { | |
8 | var word = new Int16Array(1); | |
9 | word[0] = 1; | |
10 | var bytes = new Int8Array(word.buffer); | |
11 | return !bytes[0]; | |
12 | } | |
13 | ||
14 | function test(a, b, x) { | |
15 | var intArray = new Int32Array(2); | |
16 | intArray[0] = a; | |
17 | intArray[1] = b; | |
18 | var floatArray = new Float64Array(intArray.buffer); | |
19 | var element = foo(floatArray); | |
20 | var result = element + 1; | |
21 | if (("" + result) != ("" + x)) | |
22 | throw "Error: bad result for " + a + ", " + b + ": " + result + ", but expected: " + x + "; loaded " + element + " from the array"; | |
23 | } | |
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 | } |