Index: test/mjsunit/es6/promises.js |
diff --git a/test/mjsunit/es6/promises.js b/test/mjsunit/es6/promises.js |
index 405da02b53999493215658c07cc2025ff586ac5c..341242f8d9df11c3def63ac6f393f0747bca818a 100644 |
--- a/test/mjsunit/es6/promises.js |
+++ b/test/mjsunit/es6/promises.js |
@@ -1011,9 +1011,9 @@ function assertAsyncDone(iteration) { |
log = "" |
var p4 = MyPromise.resolve(4) |
var p5 = MyPromise.reject(5) |
- assertTrue(p4 instanceof Promise, "subclass/instance4") |
+ assertTrue(p4 instanceof MyPromise, "subclass/instance4") |
assertTrue(p4 instanceof MyPromise, "subclass/instance-my4") |
- assertTrue(p5 instanceof Promise, "subclass/instance5") |
+ assertTrue(p5 instanceof MyPromise, "subclass/instance5") |
assertTrue(p5 instanceof MyPromise, "subclass/instance-my5") |
d3.resolve(3) |
assertTrue(log === "nx4nr5x3", "subclass/resolve") |
@@ -1028,12 +1028,35 @@ function assertAsyncDone(iteration) { |
log = "" |
Promise.all([11, Promise.accept(12), 13, MyPromise.accept(14), 15, 16]) |
- assertTrue(log === "nx14n", "subclass/all/arg") |
+ |
+ assertTrue(log === "nx14", "subclass/all/arg") |
log = "" |
MyPromise.all([21, Promise.accept(22), 23, MyPromise.accept(24), 25, 26]) |
- assertTrue(log === "nx24nnx21nnx23nnnx25nnx26n", "subclass/all/self") |
+ assertTrue(log === "nx24nnx21nnnnx23nnnx25nnx26n", "subclass/all/self") |
})(); |
+(function() { |
+ 'use strict'; |
+ |
+ class Pact extends Promise { } |
+ class Vow extends Pact { } |
+ class Oath extends Vow { } |
+ |
+ Oath.constructor = Vow; |
+ |
+ assertTrue(Pact.resolve(Pact.resolve()).constructor === Pact, |
+ "subclass/resolve/own"); |
+ |
+ assertTrue(Pact.resolve(Promise.resolve()).constructor === Pact, |
+ "subclass/resolve/ancestor"); |
+ |
+ assertTrue(Pact.resolve(Vow.resolve()).constructor === Pact, |
+ "subclass/resolve/descendant"); var vow = Vow.resolve(); |
+ |
+ vow.constructor = Oath; |
+ assertTrue(Oath.resolve(vow) === vow, |
+ "subclass/resolve/descendant with transplanted own constructor"); |
+}()); |
assertAsyncDone() |