Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/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 es6id: 22.1.2.1
6 description: Error setting length of object (traversed via iterator)
7 info: |
8 [...]
9 6. If usingIterator is not undefined, then
10 [...]
11 g. Repeat
12 [...]
13 iv. If next is false, then
14 1. Let setStatus be Set(A, "length", k, true).
15 2. ReturnIfAbrupt(setStatus).
16 features: [Symbol.iterator]
17 ---*/
18
19 var C = function() {};
20 var items = {};
21 Object.defineProperty(C.prototype, 'length', {
22 set: function(_) {
23 throw new Test262Error();
24 }
25 });
26 items[Symbol.iterator] = function() {
27 return {
28 next: function() {
29 return {
30 done: true
31 };
32 }
33 };
34 };
35
36 assert.throws(Test262Error, function() {
37 Array.from.call(C, items);
38 });