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

Unified Diff: test/mjsunit/es6/classes-subclass-builtins.js

Issue 1424283002: [es6] Fix WeakMap/Set built-ins subclasssing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@func-subclass
Patch Set: Test updated once again Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/classes-subclass-builtins.js
diff --git a/test/mjsunit/es6/classes-subclass-builtins.js b/test/mjsunit/es6/classes-subclass-builtins.js
index afd0c03db22352ac97db9a16427a6af13f353c36..0b20f8349468e02236a4b1548cb254d1e485caf2 100644
--- a/test/mjsunit/es6/classes-subclass-builtins.js
+++ b/test/mjsunit/es6/classes-subclass-builtins.js
@@ -266,6 +266,63 @@ function TestArraySubclassing(array) {
})();
+function TestMapSetSubclassing(container, is_map) {
+ var keys = [{name: "banana"}, {name: "cow"}, {name: "orange"}, {name: "chicken"}, {name: "apple"}];
+
+ class A extends container {
+ constructor(...args) {
+ assertTrue(%IsConstructCall());
+ super(...args);
+ this.a = 42;
+ this.d = 4.2;
+ }
+ }
+
+ var o = new A();
+ assertTrue(o instanceof Object);
+ assertTrue(o instanceof container);
+ assertTrue(o instanceof A);
+ assertEquals("object", typeof o);
+ checkPrototypeChain(o, [A, container, Object]);
+
+ for (var i = 0; i < keys.length; i++) {
+ if (is_map) {
+ o.set(keys[i], (i + 1) * 11);
+ } else {
+ o.add(keys[i]);
+ }
+ }
+ o.delete(keys[1]);
+ o.delete(keys[3]);
+
+ assertTrue(o.has(keys[0]));
+ assertFalse(o.has(keys[1]));
+ assertTrue(o.has(keys[2]));
+ assertFalse(o.has(keys[1]));
+ assertTrue(o.has(keys[4]));
+ if (is_map) {
+ assertEquals(11, o.get(keys[0]));
+ assertEquals(undefined, o.get(keys[1]));
+ assertEquals(33, o.get(keys[2]));
+ assertEquals(undefined, o.get(keys[3]));
+ assertEquals(55, o.get(keys[4]));
+ }
+ assertEquals(42, o.a);
+ assertEquals(4.2, o.d);
+
+ var o1 = new A();
+ assertTrue(%HaveSameMap(o, o1));
+}
+
+
+(function() {
+ TestMapSetSubclassing(Map, true);
+ TestMapSetSubclassing(WeakMap, true);
+ TestMapSetSubclassing(Set, false);
+ TestMapSetSubclassing(WeakSet, false);
+})();
+
+
(function() {
class A extends ArrayBuffer {
constructor(...args) {
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698