]>
Commit | Line | Data |
---|---|---|
1 | function shouldBe(actual, expected) { | |
2 | if (actual !== expected) | |
3 | throw new Error('bad value: ' + actual); | |
4 | } | |
5 | ||
6 | var array = [0, 1, 2, 3, 4, 5]; | |
7 | Object.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 | ||
16 | var result = Array.from(array); | |
17 | shouldBe(result.length, array.length); | |
18 | shouldBe(result instanceof Array, true); | |
19 | ||
20 | for (var i = 0; i < array.length; ++i) | |
21 | shouldBe(result[i], array[i]); | |
22 |