Debian Codegraph @

js/src/tests/test262/built-ins/Array/from/iter-set-length-err.js

raw
1 // Copyright (C) 2015 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-array.from
5 description: Error setting length of object (traversed via iterator)
6 info: |
7 [...]
8 6. If usingIterator is not undefined, then
9 [...]
10 g. Repeat
11 [...]
12 iv. If next is false, then
13 1. Let setStatus be Set(A, "length", k, true).
14 2. ReturnIfAbrupt(setStatus).
15 features: [Symbol.iterator]
16 ---*/
17
18 var poisonedPrototypeLength = function() {};
19 var items = {};
20 Object.defineProperty(poisonedPrototypeLength.prototype, 'length', {
21 set: function(_) {
22 throw new Test262Error();
23 }
24 });
25 items[Symbol.iterator] = function() {
26 return {
27 next: function() {
28 return {
29 done: true
30 };
31 }
32 };
33 };
34
35 assert.throws(Test262Error, function() {
36 Array.from.call(poisonedPrototypeLength, items);
37 }, 'Array.from.call(poisonedPrototypeLength, items) throws a Test262Error exception');
38
39 reportCompare(0, 0);