Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: test/mjsunit/harmony/collections.js

Issue 8439069: Fix Harmony sets and maps to allow undefined as keys. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Andreas Rossberg. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/collection.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 function TestSet(set, key) { 66 function TestSet(set, key) {
67 assertFalse(set.has(key)); 67 assertFalse(set.has(key));
68 set.add(key); 68 set.add(key);
69 assertTrue(set.has(key)); 69 assertTrue(set.has(key));
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 TestSet(set, i);
77 TestSet(set, i / 100);
78 TestSet(set, 'key-' + i);
79 }
80 var keys = [ +0, -0, +Infinity, -Infinity, true, false, null, undefined ];
81 for (var i = 0; i < keys.length; i++) {
82 TestSet(set, keys[i]);
76 } 83 }
77 } 84 }
78 TestSet(new Set, 23);
79 TestSet(new Set, 'foo');
80 TestSetBehavior(new Set); 85 TestSetBehavior(new Set);
81 86
82 87
83 // Test expected mapping behavior for Maps and WeakMaps 88 // Test expected mapping behavior for Maps and WeakMaps
84 function TestMapping(map, key, value) { 89 function TestMapping(map, key, value) {
85 map.set(key, value); 90 map.set(key, value);
86 assertSame(value, map.get(key)); 91 assertSame(value, map.get(key));
87 } 92 }
88 function TestMapBehavior1(m) { 93 function TestMapBehavior1(m) {
89 TestMapping(m, new Object, 23); 94 TestMapping(m, new Object, 23);
90 TestMapping(m, new Object, 'the-value'); 95 TestMapping(m, new Object, 'the-value');
91 TestMapping(m, new Object, new Object); 96 TestMapping(m, new Object, new Object);
92 } 97 }
93 TestMapBehavior1(new Map); 98 TestMapBehavior1(new Map);
94 TestMapBehavior1(new WeakMap); 99 TestMapBehavior1(new WeakMap);
95 100
96 101
97 // Test expected mapping behavior for Maps only 102 // Test expected mapping behavior for Maps only
98 function TestMapBehavior2(m) { 103 function TestMapBehavior2(m) {
99 for (var i = 0; i < 20; i++) { 104 for (var i = 0; i < 20; i++) {
100 TestMapping(m, i, new Object); 105 TestMapping(m, i, new Object);
101 TestMapping(m, i / 10, new Object); 106 TestMapping(m, i / 10, new Object);
102 TestMapping(m, 'key-' + i, new Object); 107 TestMapping(m, 'key-' + i, new Object);
103 } 108 }
104 var keys = [ +0, -0, +Infinity, -Infinity, true, false, null ]; 109 var keys = [ +0, -0, +Infinity, -Infinity, true, false, null, undefined ];
105 for (var i = 0; i < keys.length; i++) { 110 for (var i = 0; i < keys.length; i++) {
106 TestMapping(m, keys[i], new Object); 111 TestMapping(m, keys[i], new Object);
107 } 112 }
108 } 113 }
109 TestMapBehavior2(new Map); 114 TestMapBehavior2(new Map);
110 115
111 116
112 // Test expected querying behavior of Maps and WeakMaps 117 // Test expected querying behavior of Maps and WeakMaps
113 function TestQuery(m) { 118 function TestQuery(m) {
114 var key = new Object; 119 var key = new Object;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 configurable: true, 271 configurable: true,
267 writable: true 272 writable: true
268 }}); 273 }});
269 assertEquals(10, o.myValue); 274 assertEquals(10, o.myValue);
270 275
271 276
272 // Stress Test 277 // Stress Test
273 // There is a proposed stress-test available at the es-discuss mailing list 278 // 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: 279 // 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 280 // https://mail.mozilla.org/pipermail/es-discuss/2011-May/014096.html
OLDNEW
« no previous file with comments | « src/collection.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698