]> git.saurik.com Git - apple/javascriptcore.git/blame - tests/stress/int32array-transition-on-nan.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / int32array-transition-on-nan.js
CommitLineData
ed1e77d3
A
1function insertNaNWhileFilling()
2{
3 var array = new Array(6);
4 for (var i = 0; i < 4; ++i)
5 array[i] = i;
6 array[5] = NaN;
7 return array;
8}
9noInline(insertNaNWhileFilling);
10
11function testInsertNaNWhileFilling()
12{
13 var array = insertNaNWhileFilling();
14 for (var i = 0; i < 4; ++i) {
15 var value = array[i];
16 if (value !== i) {
17 throw "Failed testInsertNaNWhileFilling, value = " + value + " instead of " + i;
18 }
19 }
20 var nan = array[5];
21 if (!Number.isNaN(nan))
22 throw "Failed testInsertNaNWhileFilling, array[5] is " + nan + " instead of NaN";
23}
24noInline(testInsertNaNWhileFilling);
25
26for (var i = 0; i < 1e4; ++i) {
27 testInsertNaNWhileFilling();
28}
29
30
31function insertNaNAfterFilling()
32{
33 var array = new Array(6);
34 for (var i = 0; i < 5; ++i)
35 array[i] = i;
36 array[5] = NaN;
37 return array;
38}
39noInline(insertNaNAfterFilling);
40
41function testInsertNaNAfterFilling()
42{
43 var array = insertNaNAfterFilling();
44 for (var i = 0; i < 4; ++i) {
45 var value = array[i];
46 if (value !== i) {
47 throw "Failed testInsertNaNAfterFilling, value = " + value + " instead of " + i;
48 }
49 }
50 var nan = array[5];
51 if (!Number.isNaN(nan))
52 throw "Failed testInsertNaNAfterFilling, array[5] is " + nan + " instead of NaN";
53}
54noInline(testInsertNaNAfterFilling);
55
56for (var i = 0; i < 1e4; ++i) {
57 testInsertNaNAfterFilling();
58}
59
60
61function pushNaNWhileFilling()
62{
63 var array = [];
64 for (var i = 0; i < 5; ++i)
65 array.push(i);
66 array.push(NaN);
67 return array;
68}
69noInline(pushNaNWhileFilling);
70
71function testPushNaNWhileFilling()
72{
73 var array = pushNaNWhileFilling();
74 for (var i = 0; i < 4; ++i) {
75 var value = array[i];
76 if (value !== i) {
77 throw "Failed testPushNaNWhileFilling, value = " + value + " instead of " + i;
78 }
79 }
80 var nan = array[5];
81 if (!Number.isNaN(nan))
82 throw "Failed testPushNaNWhileFilling, array[5] is " + nan + " instead of NaN";
83}
84noInline(testPushNaNWhileFilling);
85
86for (var i = 0; i < 1e4; ++i) {
87 testPushNaNWhileFilling();
88}