OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --harmony-collections --allow-natives-syntax | 5 // Flags: --harmony-collections --allow-natives-syntax |
6 | 6 |
7 | 7 |
8 (function TestSetIterator() { | 8 (function TestSetIterator() { |
9 var s = new Set; | 9 var s = new Set; |
10 var iter = s.values(); | 10 var iter = s.values(); |
(...skipping 19 matching lines...) Expand all Loading... |
30 var iter = s.values(); | 30 var iter = s.values(); |
31 | 31 |
32 assertEquals({value: 1, done: false}, iter.next()); | 32 assertEquals({value: 1, done: false}, iter.next()); |
33 assertEquals({value: 2, done: false}, iter.next()); | 33 assertEquals({value: 2, done: false}, iter.next()); |
34 assertEquals({value: 3, done: false}, iter.next()); | 34 assertEquals({value: 3, done: false}, iter.next()); |
35 assertEquals({value: undefined, done: true}, iter.next()); | 35 assertEquals({value: undefined, done: true}, iter.next()); |
36 assertEquals({value: undefined, done: true}, iter.next()); | 36 assertEquals({value: undefined, done: true}, iter.next()); |
37 })(); | 37 })(); |
38 | 38 |
39 | 39 |
| 40 (function TestSetIteratorKeys() { |
| 41 assertEquals(Set.prototype.keys, Set.prototype.values); |
| 42 })(); |
| 43 |
| 44 |
40 (function TestSetIteratorEntries() { | 45 (function TestSetIteratorEntries() { |
41 var s = new Set; | 46 var s = new Set; |
42 s.add(1); | 47 s.add(1); |
43 s.add(2); | 48 s.add(2); |
44 s.add(3); | 49 s.add(3); |
45 var iter = s.entries(); | 50 var iter = s.entries(); |
46 | 51 |
47 assertEquals({value: [1, 1], done: false}, iter.next()); | 52 assertEquals({value: [1, 1], done: false}, iter.next()); |
48 assertEquals({value: [2, 2], done: false}, iter.next()); | 53 assertEquals({value: [2, 2], done: false}, iter.next()); |
49 assertEquals({value: [3, 3], done: false}, iter.next()); | 54 assertEquals({value: [3, 3], done: false}, iter.next()); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 | 191 |
187 (function TestMapIteratorSymbol() { | 192 (function TestMapIteratorSymbol() { |
188 assertEquals(Map.prototype[Symbol.iterator], Map.prototype.entries); | 193 assertEquals(Map.prototype[Symbol.iterator], Map.prototype.entries); |
189 assertTrue(Map.prototype.hasOwnProperty(Symbol.iterator)); | 194 assertTrue(Map.prototype.hasOwnProperty(Symbol.iterator)); |
190 assertFalse(Map.prototype.propertyIsEnumerable(Symbol.iterator)); | 195 assertFalse(Map.prototype.propertyIsEnumerable(Symbol.iterator)); |
191 | 196 |
192 var iter = new Map().values(); | 197 var iter = new Map().values(); |
193 assertEquals(iter, iter[Symbol.iterator]()); | 198 assertEquals(iter, iter[Symbol.iterator]()); |
194 assertEquals(iter[Symbol.iterator].name, '[Symbol.iterator]'); | 199 assertEquals(iter[Symbol.iterator].name, '[Symbol.iterator]'); |
195 })(); | 200 })(); |
OLD | NEW |