iter-set-elem-prop-err.js (1368B)
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 property on result value (traversed via iterator) 6 info: | 7 [...] 8 6. If usingIterator is not undefined, then 9 [...] 10 g. Repeat 11 [...] 12 ix. Let defineStatus be CreateDataPropertyOrThrow(A, Pk, 13 mappedValue). 14 x. If defineStatus is an abrupt completion, return 15 IteratorClose(iterator, defineStatus). 16 features: [Symbol.iterator] 17 ---*/ 18 19 var constructorSetsIndex0ConfigurableFalse = function() { 20 Object.defineProperty(this, '0', { 21 writable: true, 22 configurable: false 23 }); 24 }; 25 var closeCount = 0; 26 var items = {}; 27 var nextResult = { 28 done: false 29 }; 30 31 items[Symbol.iterator] = function() { 32 return { 33 return: function() { 34 closeCount += 1; 35 }, 36 next: function() { 37 var result = nextResult; 38 39 nextResult = { 40 done: true 41 }; 42 43 return result; 44 } 45 }; 46 }; 47 48 assert.throws(TypeError, function() { 49 Array.from.call(constructorSetsIndex0ConfigurableFalse, items); 50 }, 'Array.from.call(constructorSetsIndex0ConfigurableFalse, items) throws a TypeError exception'); 51 52 assert.sameValue(closeCount, 1, 'The value of closeCount is expected to be 1'); 53 54 reportCompare(0, 0);