%ArrayIteratorPrototype%.next must check for detached buffers
[WebKit-https.git] / JSTests / stress / int52rep-with-double-checks-int52-range.js
1 function shouldBe(actual, expected) {
2     if (actual !== expected)
3         throw new Error('bad value: ' + actual);
4 }
5
6 var doubleArray = [3, 1, 2, 3, 4, 5.5];
7 doubleArray[0] = 3; // Break CoW.
8
9 function test(array)
10 {
11     return fiatInt52(array[0]) + 0xffffffff;
12 }
13 noInline(test);
14
15 for (var i = 0; i < 1e6; ++i)
16     shouldBe(test(doubleArray), 0xffffffff + 3);
17 doubleArray[0] = 0x7ffffffffffff;
18 shouldBe(test(doubleArray), 0x80000fffffffe);
19 doubleArray[0] = 0x8000000000000;
20 shouldBe(test(doubleArray), 0x80000ffffffff);
21 doubleArray[0] = -0x8000000000000;
22 shouldBe(test(doubleArray), -0x7ffff00000001);
23 doubleArray[0] = -0x8000000000001;
24 shouldBe(test(doubleArray), -0x7ffff00000002);
25 doubleArray[0] = 1.3;
26 shouldBe(test(doubleArray), 4294967296.3);
27 doubleArray[0] = Number.NaN;
28 shouldBe(Number.isNaN(test(doubleArray)), true);
29 doubleArray[0] = Number.POSITIVE_INFINITY;
30 shouldBe(test(doubleArray), Number.POSITIVE_INFINITY);
31 doubleArray[0] = Number.NEGATIVE_INFINITY;
32 shouldBe(test(doubleArray), Number.NEGATIVE_INFINITY);
33
34 doubleArray[0] = 3;
35 shouldBe(test(doubleArray), 0xffffffff + 3);