summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/statements/for-of/set.js
blob: ad11782018d048e369743fa4a3dbcb122de11fe7 (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
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: >
    Set instances should be able to be traversed using a `for...of` loop.
es6id: 13.6.4
features: [Set]
---*/

var set = new Set();
var obj = {};
var iterationCount = 0;

var first = 0;
var second = 'a';
var third = true;
var fourth = false;
var fifth = null;
var sixth = undefined;
var seventh = NaN;
var eight = obj;

set.add(0);
set.add('a');
set.add(true);
set.add(false);
set.add(null);
set.add(undefined);
set.add(NaN);
set.add(obj);

for (var x of set) {
  assert.sameValue(x, first);
  first = second;
  second = third;
  third = fourth;
  fourth = fifth;
  fifth = sixth;
  sixth = seventh;
  seventh = eight;
  eight = null;
  iterationCount += 1;
}

assert.sameValue(iterationCount, 8);

reportCompare(0, 0);