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

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

Issue 21400002: Calling Map etc without new should throw TypeError (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 months 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') | test/mjsunit/harmony/proxies-example-membrane.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 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
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 TestProperty(m, i, 'val' + i); 200 TestProperty(m, i, 'val' + i);
201 TestProperty(m, 'foo' + i, 'bar' + i); 201 TestProperty(m, 'foo' + i, 'bar' + i);
202 } 202 }
203 TestMapping(m, new Object, 'foobar'); 203 TestMapping(m, new Object, 'foobar');
204 } 204 }
205 TestArbitrary(new Map); 205 TestArbitrary(new Map);
206 TestArbitrary(new WeakMap); 206 TestArbitrary(new WeakMap);
207 207
208 208
209 // Test direct constructor call 209 // Test direct constructor call
210 assertTrue(Set() instanceof Set); 210 assertThrows(function() { Set(); }, TypeError);
211 assertTrue(Map() instanceof Map); 211 assertThrows(function() { Map(); }, TypeError);
212 assertTrue(WeakMap() instanceof WeakMap); 212 assertThrows(function() { WeakMap(); }, TypeError);
213 assertTrue(WeakSet() instanceof WeakSet); 213 assertThrows(function() { WeakSet(); }, TypeError);
214 214
215 215
216 // Test whether NaN values as keys are treated correctly. 216 // Test whether NaN values as keys are treated correctly.
217 var s = new Set; 217 var s = new Set;
218 assertFalse(s.has(NaN)); 218 assertFalse(s.has(NaN));
219 assertFalse(s.has(NaN + 1)); 219 assertFalse(s.has(NaN + 1));
220 assertFalse(s.has(23)); 220 assertFalse(s.has(23));
221 s.add(NaN); 221 s.add(NaN);
222 assertTrue(s.has(NaN)); 222 assertTrue(s.has(NaN));
223 assertTrue(s.has(NaN + 1)); 223 assertTrue(s.has(NaN + 1));
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 TestPrototype(Set); 301 TestPrototype(Set);
302 TestPrototype(Map); 302 TestPrototype(Map);
303 TestPrototype(WeakMap); 303 TestPrototype(WeakMap);
304 TestPrototype(WeakSet); 304 TestPrototype(WeakSet);
305 305
306 306
307 // Test constructor property of the Set, Map, WeakMap and WeakSet prototype. 307 // Test constructor property of the Set, Map, WeakMap and WeakSet prototype.
308 function TestConstructor(C) { 308 function TestConstructor(C) {
309 assertFalse(C === Object.prototype.constructor); 309 assertFalse(C === Object.prototype.constructor);
310 assertSame(C, C.prototype.constructor); 310 assertSame(C, C.prototype.constructor);
311 assertSame(C, C().__proto__.constructor);
312 assertSame(C, (new C).__proto__.constructor); 311 assertSame(C, (new C).__proto__.constructor);
313 } 312 }
314 TestConstructor(Set); 313 TestConstructor(Set);
315 TestConstructor(Map); 314 TestConstructor(Map);
316 TestConstructor(WeakMap); 315 TestConstructor(WeakMap);
317 TestConstructor(WeakSet); 316 TestConstructor(WeakSet);
318 317
319 318
320 // Test the Set, Map, WeakMap and WeakSet global properties themselves. 319 // Test the Set, Map, WeakMap and WeakSet global properties themselves.
321 function TestDescriptor(global, C) { 320 function TestDescriptor(global, C) {
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 477
479 // Test WeakSet clear 478 // Test WeakSet clear
480 (function() { 479 (function() {
481 var k = new Object(); 480 var k = new Object();
482 var w = new WeakSet(); 481 var w = new WeakSet();
483 w.add(k); 482 w.add(k);
484 assertTrue(w.has(k)); 483 assertTrue(w.has(k));
485 w.clear(); 484 w.clear();
486 assertFalse(w.has(k)); 485 assertFalse(w.has(k));
487 })(); 486 })();
OLDNEW
« no previous file with comments | « src/collection.js ('k') | test/mjsunit/harmony/proxies-example-membrane.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698