Debian Codegraph @

js/src/tests/test262/built-ins/Array/from/iter-get-iter-val-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 retrieving value of iterator result
6 info: |
7 [...]
8 6. If usingIterator is not undefined, then
9 [...]
10 g. Repeat
11 [...]
12 v. Let nextValue be IteratorValue(next).
13 vi. ReturnIfAbrupt(nextValue).
14 features: [Symbol.iterator]
15 ---*/
16
17 var itemsPoisonedIteratorValue = {};
18 var poisonedValue = {};
19 Object.defineProperty(poisonedValue, 'value', {
20 get: function() {
21 throw new Test262Error();
22 }
23 });
24 itemsPoisonedIteratorValue[Symbol.iterator] = function() {
25 return {
26 next: function() {
27 return poisonedValue;
28 }
29 };
30 };
31
32 assert.throws(Test262Error, function() {
33 Array.from(itemsPoisonedIteratorValue);
34 }, 'Array.from(itemsPoisonedIteratorValue) throws a Test262Error exception');
35
36 reportCompare(0, 0);