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

Unified Diff: test/mjsunit/harmony/collections.js

Issue 21924007: Make new Harmony constructors subclassing-friendly (Closed) Base URL: https://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 side-by-side diff with in-line comments
Download patch
Index: test/mjsunit/harmony/collections.js
diff --git a/test/mjsunit/harmony/collections.js b/test/mjsunit/harmony/collections.js
index 174d3d1dc7ca772c86e388e8de68f786b9022e08..a3d1ca8f26566422da120374330c03ede82781e2 100644
--- a/test/mjsunit/harmony/collections.js
+++ b/test/mjsunit/harmony/collections.js
@@ -304,6 +304,20 @@ TestPrototype(WeakMap);
TestPrototype(WeakSet);
+// Test that constructor can be called only on appropriate objects only once.
+function TestConstructorBehavior(C) {
+ var obj = new C();
+ assertThrows(function() { C.call(obj); }, TypeError);
+ assertThrows(function() { C.call({}); }, TypeError);
+ var uninitObj = %NewObject(C);
+ C.call(uninitObj); // shouldn't throw
+}
+TestConstructorBehavior(Set);
+TestConstructorBehavior(Map);
+TestConstructorBehavior(WeakMap);
+TestConstructorBehavior(WeakSet);
+
+
// Test constructor property of the Set, Map, WeakMap and WeakSet prototype.
function TestConstructor(C) {
assertFalse(C === Object.prototype.constructor);
@@ -483,4 +497,4 @@ for (var i = 9; i >= 0; i--) {
assertTrue(w.has(k));
w.clear();
assertFalse(w.has(k));
-})();
+})();
« src/runtime.cc ('K') | « src/typedarray.js ('k') | test/mjsunit/harmony/typedarrays.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698