summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/collections/Set-constructor-2.js
blob: 43fffba8e8e33ef281bb8ffd26d6c6a31b99de38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// The Set constructor can take an argument that is an array.

var s = new Set([]);
assertEq(s.size, 0);
assertEq(s.has(undefined), false);

s = new Set(["one", "two", "three"]);
assertEq(s.size, 3);
assertEq(s.has("one"), true);
assertEq(s.has("eleventeen"), false);

var a = [{}, {}, {}];
s = new Set(a);
assertEq(s.size, 3);
for (let obj of a)
    assertEq(s.has(obj), true);
assertEq(s.has({}), false);
assertEq(s.has("three"), false);