OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 'use strict'; |
| 6 |
| 7 var set = new Set(); |
| 8 |
| 9 var objectKey = {}; |
| 10 var stringKey = 'keykeykey'; |
| 11 var numberKey = 42.24; |
| 12 var booleanKey = true; |
| 13 var undefinedKey = undefined; |
| 14 var nullKey = null; |
| 15 var nanKey = NaN; |
| 16 var zeroKey = 0; |
| 17 var minusZeroKey = -0; |
| 18 |
| 19 assertEquals(set.size, 0); |
| 20 |
| 21 set.add(objectKey); |
| 22 set.add(stringKey); |
| 23 set.add(numberKey); |
| 24 set.add(booleanKey); |
| 25 set.add(undefinedKey); |
| 26 set.add(nullKey); |
| 27 set.add(nanKey); |
| 28 set.add(zeroKey); |
| 29 |
| 30 assertEquals(8, set.size); |
| 31 |
| 32 assertTrue(set.has(objectKey)); |
| 33 assertTrue(set.has(stringKey)); |
| 34 assertTrue(set.has(numberKey)); |
| 35 assertTrue(set.has(booleanKey)); |
| 36 assertTrue(set.has(undefinedKey)); |
| 37 assertTrue(set.has(nullKey)); |
| 38 assertTrue(set.has(nanKey)); |
| 39 assertTrue(set.has(zeroKey)); |
| 40 |
| 41 assertFalse(set.has({})); |
| 42 assertTrue(set.has('keykeykey')); |
| 43 assertTrue(set.has(42.24)); |
| 44 assertTrue(set.has(true)); |
| 45 assertTrue(set.has(undefined)); |
| 46 assertTrue(set.has(null)); |
| 47 assertTrue(set.has(NaN)); |
| 48 assertTrue(set.has(0)); |
| 49 assertTrue(set.has(-0)); |
| 50 assertTrue(set.has(1 / Infinity)); |
| 51 assertTrue(set.has(-1 / Infinity)); |
OLD | NEW |