| 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: Setting property on result value (traversed via iterator) |
| 7 |
info: | |
| 8 |
[...] |
| 9 |
6. If usingIterator is not undefined, then |
| 10 |
[...] |
| 11 |
g. Repeat |
| 12 |
[...] |
| 13 |
ix. Let defineStatus be CreateDataPropertyOrThrow(A, Pk, |
| 14 |
mappedValue). |
| 15 |
features: [Symbol.iterator] |
| 16 |
---*/ |
| 17 |
|
| 18 |
var items = {}; |
| 19 |
var firstIterResult = { |
| 20 |
done: false, |
| 21 |
value: {} |
| 22 |
}; |
| 23 |
var secondIterResult = { |
| 24 |
done: false, |
| 25 |
value: {} |
| 26 |
}; |
| 27 |
var thirdIterResult = { |
| 28 |
done: true, |
| 29 |
value: {} |
| 30 |
}; |
| 31 |
var nextIterResult = firstIterResult; |
| 32 |
var nextNextIterResult = secondIterResult; |
| 33 |
var result; |
| 34 |
|
| 35 |
items[Symbol.iterator] = function() { |
| 36 |
return { |
| 37 |
next: function() { |
| 38 |
var result = nextIterResult; |
| 39 |
|
| 40 |
nextIterResult = nextNextIterResult; |
| 41 |
nextNextIterResult = thirdIterResult; |
| 42 |
|
| 43 |
return result; |
| 44 |
} |
| 45 |
}; |
| 46 |
}; |
| 47 |
|
| 48 |
result = Array.from(items); |
| 49 |
|
| 50 |
assert.sameValue(result[0], firstIterResult.value); |
| 51 |
assert.sameValue(result[1], secondIterResult.value); |