]> git.saurik.com Git - apple/javascriptcore.git/blame_incremental - tests/stress/array-from-with-accessors.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / array-from-with-accessors.js
... / ...
CommitLineData
1function shouldBe(actual, expected) {
2 if (actual !== expected)
3 throw new Error('bad value: ' + actual);
4}
5
6var array = [0, 1, 2, 3, 4, 5];
7Object.defineProperty(Array.prototype, '0', {
8 get() {
9 throw new Error('cannot get to 0 getter');
10 },
11 set() {
12 throw new Error('cannot put to 0 setter');
13 }
14});
15
16var result = Array.from(array);
17shouldBe(result.length, array.length);
18shouldBe(result instanceof Array, true);
19
20for (var i = 0; i < array.length; ++i)
21 shouldBe(result[i], array[i]);
22