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

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

Issue 1473323003: Add test for Promises subclassing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@in-obj-array-buffer-view
Patch Set: 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 | « no previous file | 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 7e0958baf14b57c743cf3f74c10f21b532f7a5d8..1dd93e77f37660907f6a95ab749569ed500d8398 100644
--- a/test/mjsunit/es6/classes-subclass-builtins.js
+++ b/test/mjsunit/es6/classes-subclass-builtins.js
@@ -547,6 +547,46 @@ function TestMapSetSubclassing(container, is_map) {
(function() {
+ class A extends Promise {
+ constructor(...args) {
+ assertTrue(%IsConstructCall());
+ super(...args);
+ this.a = 42;
+ this.d = 4.2;
+ this.o = {foo:153};
+ }
+ }
+
+ var o = new A(function(resolve, reject) {
+ resolve("ok");
+ });
+ assertTrue(o instanceof Object);
+ assertTrue(o instanceof Promise);
+ assertTrue(o instanceof A);
+ assertEquals("object", typeof o);
+ checkPrototypeChain(o, [A, Promise, Object]);
+ assertEquals(42, o.a);
+ assertEquals(4.2, o.d);
+ assertEquals(153, o.o.foo);
+ o.then(
+ function(val) { assertEquals("ok", val); },
+ function(reason) { assertUnreachable(); })
+ .catch(function(reason) { %AbortJS("catch handler called: " + reason); });
+
+ var o1 = new A(function(resolve, reject) {
+ reject("fail");
+ });
+ o1.then(
+ function(val) { assertUnreachable(); },
+ function(reason) { assertEquals("fail", reason); })
+ .catch(function(reason) { %AbortJS("catch handler called: " + reason); });
+ assertTrue(%HaveSameMap(o, o1));
+
+ gc();
+})();
+
+
+(function() {
class A extends Boolean {
constructor() {
assertTrue(%IsConstructCall());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698