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

Unified Diff: test/mjsunit/es6/promises.js

Issue 1098663002: Promise assimilation fix. Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « src/promise.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/promises.js
diff --git a/test/mjsunit/es6/promises.js b/test/mjsunit/es6/promises.js
index 63b6d2f94a9a7ec0799a7ef766845675dc8466fb..14425e84ba4e77d66c43ec93bbe57255decb60ff 100644
--- a/test/mjsunit/es6/promises.js
+++ b/test/mjsunit/es6/promises.js
@@ -391,6 +391,59 @@ function assertAsyncDone(iteration) {
})();
(function() {
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var called = false
+ p2.then = function(onResolve, onReject) {
+ called = true;
+ return call(Promise.prototype.then, p2, onResolve, onReject)
+ }
+ var p3 = Promise.accept(p2)
+ p3.chain(
+ function(x) {
+ assertAsync(x === p2 && !called, "resolved/thenable-promise/chain")
+ },
+ assertUnreachable)
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var called = false
+ p2.then = function(onResolve, onReject) {
+ called = true
+ return call(Promise.prototype.then, p2, onResolve, onReject)
+ }
+ var p3 = Promise.accept(p2)
+ p3.then(
+ function(x) {
+ assertAsync(x === 5 && called, "resolved/thenable-promise/then")
+ },
+ assertUnreachable)
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.accept(5)
+ var called = false
+ var p3 = p1.then(function(x) {
+ var p2 = Promise.accept(5)
+ p2.then = function(onResolve, onReject) {
+ called = true
+ throw 25
+ }
+ return p2
+ });
+ p3.then(
+ assertUnreachable,
+ function(x) {
+ assertAsync(called && x === 25, "thenable-promise/then-call-throw")
+ })
+ assertAsyncRan()
+})();
+
+(function() {
var deferred = Promise.defer()
var p1 = deferred.promise
var p2 = Promise.accept(p1)
@@ -519,6 +572,106 @@ function assertAsyncDone(iteration) {
})();
(function() {
+ var deferred = Promise.defer()
+ var deferred2 = Promise.defer()
+ var deferred3 = Promise.defer()
+
+ var p1 = deferred.promise
+ var p2 = deferred2.promise
+ var p3 = deferred3.promise
+
+ var called = false
+ p2.then = function(onResolve, onReject) {
+ called = true
+ return call(Promise.prototype.then, p2, onResolve, onReject)
+ }
+ p3.chain(
+ function(x) { assertAsync(x === p2 && !called,
+ "chain/resolve/thenable-promise") },
+ assertUnreachable
+ )
+ deferred3.resolve(p2)
+ deferred2.resolve(p1)
+ deferred.resolve(5)
+ assertAsyncRan()
+})();
+
+(function() {
+ var deferred = Promise.defer()
+ var deferred2 = Promise.defer()
+ var deferred3 = Promise.defer()
+
+ var p1 = deferred.promise
+ var p2 = deferred2.promise
+ var p3 = deferred3.promise
+
+ var called = false
+ p2.then = function(onResolve, onReject) {
+ called = true
+ return call(Promise.prototype.then, p2, onResolve, onReject)
+ }
+ p3.then(
+ function(x) { assertAsync(x === 5 && called,
+ "then/resolve/thenable-promise") },
+ assertUnreachable
+ )
+ deferred3.resolve(p2)
+ deferred2.resolve(p1)
+ deferred.resolve(5)
+ assertAsyncRan()
+})();
+
+(function() {
+ var deferred = Promise.defer()
+ var deferred2 = Promise.defer()
+ var deferred3 = Promise.defer()
+
+ var p1 = deferred.promise
+ var p2 = deferred2.promise
+ var p3 = deferred3.promise
+
+ var called = false
+ p2.then = function(onResolve, onReject) {
+ called = true
+ return call(Promise.prototype.then, p2, onResolve, onReject)
+ }
+ p3.chain(
+ function(x) { assertAsync(x === p2 && !called,
+ "chain/reject/thenable-promise") },
+ assertUnreachable
+ )
+ deferred3.resolve(p2)
+ deferred2.resolve(p1)
+ deferred.reject(5)
+ assertAsyncRan()
+})();
+
+(function() {
+ var deferred = Promise.defer()
+ var deferred2 = Promise.defer()
+ var deferred3 = Promise.defer()
+
+ var p1 = deferred.promise
+ var p2 = deferred2.promise
+ var p3 = deferred3.promise
+
+ var called = false
+ p2.then = function(onResolve, onReject) {
+ called = true
+ return call(Promise.prototype.then, p2, onResolve, onReject)
+ }
+ p3.then(
+ assertUnreachable,
+ function(x) { assertAsync(x === 5 && called,
+ "then/reject/thenable-promise") }
+ )
+ deferred3.resolve(p2)
+ deferred2.resolve(p1)
+ deferred.reject(5)
+ assertAsyncRan()
+})();
+
+(function() {
var p1 = Promise.accept(5)
var p2 = Promise.accept(p1)
var deferred = Promise.defer()
« no previous file with comments | « src/promise.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698