OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 'use strict'; |
| 6 |
| 7 var map = new Map(); |
| 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(map.size, 0); |
| 20 |
| 21 map.set(objectKey, 'aaa'); |
| 22 map.set(stringKey, 'bbb'); |
| 23 map.set(numberKey, 'ccc'); |
| 24 map.set(booleanKey, 'ddd'); |
| 25 map.set(undefinedKey, 'eee'); |
| 26 map.set(nullKey, 'fff'); |
| 27 map.set(nanKey, 'ggg'); |
| 28 map.set(zeroKey, 'hhh'); |
| 29 |
| 30 assertEquals(8, map.size); |
| 31 |
| 32 assertEquals('aaa', map.get(objectKey)); |
| 33 assertEquals('bbb', map.get(stringKey)); |
| 34 assertEquals('ccc', map.get(numberKey)); |
| 35 assertEquals('ddd', map.get(booleanKey)); |
| 36 assertEquals('eee', map.get(undefinedKey)); |
| 37 assertEquals('fff', map.get(nullKey)); |
| 38 assertEquals('ggg', map.get(nanKey)); |
| 39 assertEquals('hhh', map.get(zeroKey)); |
| 40 |
| 41 assertEquals(undefined, map.get({})); |
| 42 assertEquals('bbb', map.get('keykeykey')); |
| 43 assertEquals('ccc', map.get(42.24)); |
| 44 assertEquals('ddd', map.get(true)); |
| 45 assertEquals('eee', map.get(undefined)); |
| 46 assertEquals('fff', map.get(null)); |
| 47 assertEquals('ggg', map.get(NaN)); |
| 48 assertEquals('hhh', map.get(0)); |
| 49 assertEquals('hhh', map.get(-0)); |
| 50 assertEquals('hhh', map.get(1 / Infinity)); |
| 51 assertEquals('hhh', map.get(-1 / Infinity)); |
OLD | NEW |