]>
Commit | Line | Data |
---|---|---|
ed1e77d3 A |
1 | function shouldBe(actual, expected) { |
2 | if (actual !== expected) | |
3 | throw new Error('bad value: ' + actual); | |
4 | } | |
5 | ||
6 | for (var i = 0; i < 10; ++i) { | |
7 | Object.defineProperty(Array.prototype, i, { | |
8 | get() { | |
9 | throw new Error('get is called.'); | |
10 | }, | |
11 | set(value) { | |
12 | throw new Error('set is called.'); | |
13 | } | |
14 | }); | |
15 | } | |
16 | ||
17 | var original = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; | |
18 | ||
19 | // Doesn't throw any errors. | |
20 | var generated = Array.from(original); | |
21 | ||
22 | shouldBe(generated.length, 10); | |
23 | for (var i = 0; i < 10; ++i) { | |
24 | shouldBe(generated[i], i); | |
25 | } |