OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 for (var i = 0; i < keys.length; i++) { | 112 for (var i = 0; i < keys.length; i++) { |
113 TestMapping(m, keys[i], new Object); | 113 TestMapping(m, keys[i], new Object); |
114 } | 114 } |
115 } | 115 } |
116 TestMapBehavior2(new Map); | 116 TestMapBehavior2(new Map); |
117 | 117 |
118 | 118 |
119 // Test expected querying behavior of Maps and WeakMaps | 119 // Test expected querying behavior of Maps and WeakMaps |
120 function TestQuery(m) { | 120 function TestQuery(m) { |
121 var key = new Object; | 121 var key = new Object; |
122 TestMapping(m, key, 'to-be-present'); | 122 var values = [ 'x', 0, +Infinity, -Infinity, true, false, null, undefined ]; |
123 assertTrue(m.has(key)); | 123 for (var i = 0; i < values.length; i++) { |
124 assertFalse(m.has(new Object)); | 124 TestMapping(m, key, values[i]); |
125 TestMapping(m, key, undefined); | 125 assertTrue(m.has(key)); |
126 assertFalse(m.has(key)); | 126 assertFalse(m.has(new Object)); |
127 assertFalse(m.has(new Object)); | 127 } |
128 } | 128 } |
129 TestQuery(new Map); | 129 TestQuery(new Map); |
130 TestQuery(new WeakMap); | 130 TestQuery(new WeakMap); |
131 | 131 |
132 | 132 |
133 // Test expected deletion behavior of Maps and WeakMaps | 133 // Test expected deletion behavior of Maps and WeakMaps |
134 function TestDelete(m) { | 134 function TestDelete(m) { |
135 var key = new Object; | 135 var key = new Object; |
136 TestMapping(m, key, 'to-be-deleted'); | 136 TestMapping(m, key, 'to-be-deleted'); |
137 assertTrue(m.delete(key)); | 137 assertTrue(m.delete(key)); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 } | 307 } |
308 } | 308 } |
309 } | 309 } |
310 TestBogusReceivers(bogusReceiversTestSet); | 310 TestBogusReceivers(bogusReceiversTestSet); |
311 | 311 |
312 | 312 |
313 // Stress Test | 313 // Stress Test |
314 // There is a proposed stress-test available at the es-discuss mailing list | 314 // There is a proposed stress-test available at the es-discuss mailing list |
315 // which cannot be reasonably automated. Check it out by hand if you like: | 315 // which cannot be reasonably automated. Check it out by hand if you like: |
316 // https://mail.mozilla.org/pipermail/es-discuss/2011-May/014096.html | 316 // https://mail.mozilla.org/pipermail/es-discuss/2011-May/014096.html |
OLD | NEW |