Skip to content

Commit c874540

Browse files
Merge pull request #22 from test262-automation/javascriptcore-debug-test262-debug-automation-export-1531745985464
Import test changes from JavaScriptCore (Debug)
2 parents 3516619 + 0717a40 commit c874540

File tree

24 files changed

+2424
-191
lines changed

24 files changed

+2424
-191
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"targetRevisionAtLastExport": "1418889",
3-
"sourceRevisionAtLastExport": "1a4026b7",
2+
"targetRevisionAtLastExport": "577c7a9",
3+
"sourceRevisionAtLastExport": "6c8213bb",
44
"curatedFiles": {
5-
5+
"/262-fully-curated-vendor-not-modified/array-flatten.js": "DELETED_IN_TARGET"
66
}
77
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* Copyright (C) 2015 Apple Inc. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21+
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
var funcArgAndBodyStr =
27+
"(arr) {" + "\n" +
28+
" var sum = 0;" + "\n" +
29+
" for (var i in arr)" + "\n" +
30+
" sum += arr[i];" + "\n" +
31+
" return sum;" + "\n" +
32+
"}";
33+
34+
var testData = {
35+
"ArrayWithUndecided": { in: [], out: 0 },
36+
"ArrayWithInt32": { in: [ 1, 2, 3 ], out: 6 },
37+
"ArrayWithContiguous": { in: [ "a", "b", "c" ], out: "0abc" },
38+
"ArrayWithDouble": { in: [10.25, 20.25, 30.25 ], out: 60.75 },
39+
"ArrayWithArrayStorage": { in: [ "a", "b", "c" ], out: "0abc1000" }, // The in array will be augmented below.
40+
"ArrayWithSlowPutArrayStorage": { in: [ "a", "b", "c" ], out: "0abc10" }, // the in array will be augmented below.
41+
42+
"NonArrayWithUndecided": { in: {}, out: 0 },
43+
"NonArrayWithInt32": { in: { "0":1, "1":2, "2":3 }, out: 6 },
44+
"NonArrayWithContiguous": { in: { "0":"a", "1":"b", "2":"c" }, out: "0abc" },
45+
"NonArrayWithDouble": { in: { "0":10.25, "1":20.25, "2":30.25 }, out: 60.75 },
46+
"NonArrayWithArrayStorage": { in: { "0":"a", "1":"b", "2":"c" }, out: "0abc1000" }, // The in obj will be augmented below.
47+
"NonArrayWithSlowPutArrayStorage": { in: { "0":"a", "1":"b", "2":"c" }, out: "0abc10" }, // the in obj will be augmented below.
48+
};
49+
50+
51+
var o = { a: 10 };
52+
Object.defineProperties(o, {
53+
"0": {
54+
get: function() { return this.a; },
55+
set: function(x) { this.a = x; },
56+
},
57+
});
58+
59+
testData["ArrayWithArrayStorage"].in[1000] = 1000;
60+
testData["ArrayWithSlowPutArrayStorage"].in.__proto__ = o;
61+
testData["NonArrayWithArrayStorage"].in["1000"] = 1000;
62+
testData["NonArrayWithSlowPutArrayStorage"].in.__proto__ = o;
63+
64+
var numberOfFailures = 0;
65+
66+
function test(name, data) {
67+
eval("function " + name + funcArgAndBodyStr);
68+
noInline(name);
69+
70+
var failed = false;
71+
var previousResult;
72+
for (var i = 0; i < 10000; ++i) {
73+
var expected = data.out;
74+
var actual = eval(name + "(data.in)");
75+
76+
if ((actual != expected) && (actual != previousResult)) {
77+
print("FAIL: " + name + ": expected: " + expected + ", actual: " + actual + ", starting @ loop iteration " + i);
78+
previousResult = actual;
79+
failed = true;
80+
numberOfFailures++;
81+
}
82+
}
83+
}
84+
85+
for (name in testData)
86+
test(name, testData[name]);
87+
88+
if (numberOfFailures)
89+
throw "Error: number of failures found: " + numberOfFailures;

0 commit comments

Comments
 (0)