blob: 27076c53defc3f39b86b8c347b63845cdd951453 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
// Copyright (C) 2013 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.6.4.13 S5.f
description: >
The `value` of iteration result objects should be retrieved using the Get
abstract operation.
features: [Symbol.iterator]
---*/
var iterable = {};
var i, firstIterResult;
iterable[Symbol.iterator] = function() {
var finalIterResult = { value: null, done: true };
var nextIterResult = firstIterResult;
return {
next: function() {
var iterResult = nextIterResult;
nextIterResult = finalIterResult;
return iterResult;
}
};
};
firstIterResult = { value: 45, done: false };
i = 0;
for (var x of iterable) {
assert.sameValue(x, 45);
i++;
}
assert.sameValue(i, 1);
firstIterResult = { done: false };
Object.defineProperty(firstIterResult, 'value', {
get: function() {
return 23;
}
});
i = 0;
for (var x of iterable) {
assert.sameValue(x, 23);
i++;
}
assert.sameValue(i, 1);
reportCompare(0, 0);
|