X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/2d39b0e377c0896910ee49ae70082ba665faf986..ed1e77d3adeb83d26fd1dfb16dd84cabdcefd250:/tests/stress/array-from-with-accessors.js?ds=inline diff --git a/tests/stress/array-from-with-accessors.js b/tests/stress/array-from-with-accessors.js new file mode 100644 index 0000000..cfe65ca --- /dev/null +++ b/tests/stress/array-from-with-accessors.js @@ -0,0 +1,22 @@ +function shouldBe(actual, expected) { + if (actual !== expected) + throw new Error('bad value: ' + actual); +} + +var array = [0, 1, 2, 3, 4, 5]; +Object.defineProperty(Array.prototype, '0', { + get() { + throw new Error('cannot get to 0 getter'); + }, + set() { + throw new Error('cannot put to 0 setter'); + } +}); + +var result = Array.from(array); +shouldBe(result.length, array.length); +shouldBe(result instanceof Array, true); + +for (var i = 0; i < array.length; ++i) + shouldBe(result[i], array[i]); +