1<!DOCTYPE html>
2<html>
3<head>
4<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
5<script>
6function test()
7{
8 let suite = InspectorTest.createSyncSuite("SetUtilities");
9
10 suite.addTestCase({
11 name: "Set.prototype.intersects",
12 test() {
13 function testTrue(a, b, message) {
14 InspectorTest.expectThat((new Set(a)).intersects(new Set(b)), message);
15 }
16
17 function testFalse(a, b, message) {
18 InspectorTest.expectFalse((new Set(a)).intersects(new Set(b)), message);
19 }
20
21 const object1 = {a: 1};
22 const object2 = {b: 2};
23 const object3 = {c: 3};
24
25 testFalse([], [], "empy sets should not intersect.");
26 testTrue([1, "a", object1], [1, "a", object1], "sets with the same values should intersect.");
27 testFalse([1, "a", object1], [2, "b", object2], "sets with the different values should not intersect.");
28 testTrue([1, 2, "a", "b", object1, object2], [1, 3, "a", "c", object1, object3], "sets with same and different values should intersect.");
29
30 return true;
31 }
32 });
33
34 suite.addTestCase({
35 name: "Set.prototype.contains",
36 test() {
37 function testTrue(a, b, message) {
38 InspectorTest.expectThat((new Set(a)).contains(new Set(b)), message);
39 }
40
41 function testFalse(a, b, message) {
42 InspectorTest.expectFalse((new Set(a)).contains(new Set(b)), message);
43 }
44
45 const object1 = {a: 1};
46 const object2 = {b: 2};
47 const object3 = {c: 3};
48
49 testFalse([], [], "an empy sets should not contain another empty set.");
50 testTrue([1, "a", object1], [1, "a", object1], "a set should contain another set with the same values.");
51 testFalse([1, "a", object1], [2, "b", object2], "a set should not contain another set with different values.");
52 testFalse([1, 2, "a", "b", object1, object2], [1, 3, "a", "c", object1, object3], "a set should not contain another set with same and different values.");
53
54 return true;
55 }
56 });
57
58 suite.runTestCasesAndFinish();
59}
60</script>
61</head>
62<body onLoad="runTest()">
63</body>
64</html>