OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 set.delete(key); | 70 set.delete(key); |
71 assertFalse(set.has(key)); | 71 assertFalse(set.has(key)); |
72 } | 72 } |
73 function TestSetBehavior(set) { | 73 function TestSetBehavior(set) { |
74 for (var i = 0; i < 20; i++) { | 74 for (var i = 0; i < 20; i++) { |
75 TestSet(set, new Object); | 75 TestSet(set, new Object); |
76 } | 76 } |
77 } | 77 } |
78 TestSet(new Set, 23); | 78 TestSet(new Set, 23); |
79 TestSet(new Set, 'foo'); | 79 TestSet(new Set, 'foo'); |
80 TestSetBehavior(new Set); | 80 TestSetBehavior(new Set); |
rossberg
2011/11/03 14:14:31
Can you add some tests for sets with null and unde
Michael Starzinger
2011/11/03 14:34:21
Done.
| |
81 | 81 |
82 | 82 |
83 // Test expected mapping behavior for Maps and WeakMaps | 83 // Test expected mapping behavior for Maps and WeakMaps |
84 function TestMapping(map, key, value) { | 84 function TestMapping(map, key, value) { |
85 map.set(key, value); | 85 map.set(key, value); |
86 assertSame(value, map.get(key)); | 86 assertSame(value, map.get(key)); |
87 } | 87 } |
88 function TestMapBehavior1(m) { | 88 function TestMapBehavior1(m) { |
89 TestMapping(m, new Object, 23); | 89 TestMapping(m, new Object, 23); |
90 TestMapping(m, new Object, 'the-value'); | 90 TestMapping(m, new Object, 'the-value'); |
91 TestMapping(m, new Object, new Object); | 91 TestMapping(m, new Object, new Object); |
92 } | 92 } |
93 TestMapBehavior1(new Map); | 93 TestMapBehavior1(new Map); |
94 TestMapBehavior1(new WeakMap); | 94 TestMapBehavior1(new WeakMap); |
95 | 95 |
96 | 96 |
97 // Test expected mapping behavior for Maps only | 97 // Test expected mapping behavior for Maps only |
98 function TestMapBehavior2(m) { | 98 function TestMapBehavior2(m) { |
99 for (var i = 0; i < 20; i++) { | 99 for (var i = 0; i < 20; i++) { |
100 TestMapping(m, i, new Object); | 100 TestMapping(m, i, new Object); |
101 TestMapping(m, i / 10, new Object); | 101 TestMapping(m, i / 10, new Object); |
102 TestMapping(m, 'key-' + i, new Object); | 102 TestMapping(m, 'key-' + i, new Object); |
103 } | 103 } |
104 var keys = [ +0, -0, +Infinity, -Infinity, true, false, null ]; | 104 var keys = [ +0, -0, +Infinity, -Infinity, true, false, null, undefined ]; |
105 for (var i = 0; i < keys.length; i++) { | 105 for (var i = 0; i < keys.length; i++) { |
106 TestMapping(m, keys[i], new Object); | 106 TestMapping(m, keys[i], new Object); |
107 } | 107 } |
108 } | 108 } |
109 TestMapBehavior2(new Map); | 109 TestMapBehavior2(new Map); |
110 | 110 |
111 | 111 |
112 // Test expected querying behavior of Maps and WeakMaps | 112 // Test expected querying behavior of Maps and WeakMaps |
113 function TestQuery(m) { | 113 function TestQuery(m) { |
114 var key = new Object; | 114 var key = new Object; |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
266 configurable: true, | 266 configurable: true, |
267 writable: true | 267 writable: true |
268 }}); | 268 }}); |
269 assertEquals(10, o.myValue); | 269 assertEquals(10, o.myValue); |
270 | 270 |
271 | 271 |
272 // Stress Test | 272 // Stress Test |
273 // There is a proposed stress-test available at the es-discuss mailing list | 273 // There is a proposed stress-test available at the es-discuss mailing list |
274 // which cannot be reasonably automated. Check it out by hand if you like: | 274 // which cannot be reasonably automated. Check it out by hand if you like: |
275 // https://mail.mozilla.org/pipermail/es-discuss/2011-May/014096.html | 275 // https://mail.mozilla.org/pipermail/es-discuss/2011-May/014096.html |
OLD | NEW |