]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/array-from-set-length.js
ab6adeadb02056665683298628692d908b5f675c
1 function shouldBe(actual
, expected
) {
2 if (actual
!== expected
)
3 throw new Error('bad value: ' + actual
);
6 for (var i
= 0; i
< 10; ++i
) {
7 Object
.defineProperty(Array
.prototype, i
, {
9 throw new Error('get is called.');
12 throw new Error('set is called.');
19 this.lengthCalled
= false;
20 this._length
= length
;
23 this.lengthCalled
= true;
31 var arrayLike
= new ArrayLike(10);
32 for (var i
= 0; i
< 10; ++i
) {
35 shouldBe(arrayLike
.lengthCalled
, false);
37 var generated
= Array
.from.call(ArrayLike
, arrayLike
);
39 shouldBe(generated
.length
, 10);
40 shouldBe(generated
instanceof ArrayLike
, true);
41 for (var i
= 0; i
< 10; ++i
) {
42 shouldBe(generated
[i
], i
);
44 shouldBe(arrayLike
.lengthCalled
, false);
45 shouldBe(generated
.lengthCalled
, true);