Skip to content
Snippets Groups Projects
Commit cc18dd2d authored by smikes's avatar smikes
Browse files

2 new tests re: foreign thenables

parent 8eb0bd12
No related branches found
No related tags found
No related merge requests found
......@@ -17,10 +17,17 @@ var thenable = {
sequence.push(3);
checkSequence(sequence, "thenable.then called");
Promise.resolve().then(function () {
sequence.push(4);
checkSequence(sequence, "all done");
}).then($DONE, $DONE);
assert.sameValue(this, thenable);
onResolve('resolved');
sequence.push(4);
checkSequence(sequence, "after resolved");
throw new Error('interrupt flow');
sequence.push(4);
checkSequence(sequence, "duplicate sequence point not pushed");
}
};
......@@ -31,3 +38,11 @@ var p1 = Promise.resolve(thenable);
sequence.push(2);
checkSequence(sequence, "thenable.then queued but not yet called");
p1.then(function (q) {
sequence.push(5);
checkSequence(sequence, "all done");
assert.sameValue(q, 'resolved');
}).then($DONE, $DONE);
// Copyright 2014 Cubane Canada, Inc. All rights reserved.
// See LICENSE for details.
/*---
info: >
Promise.resolve
es6id: S25.4.4.5
author: Sam Mikes
description: Promise.resolve delegates to foreign thenable
includes: [PromiseHelper.js]
---*/
var sequence = [];
var thenable = {
then: function(onResolve, onReject) {
return onResolve('resolved');
}
};
var p = Promise.resolve(thenable);
p.then(function (r) {
assert.sameValue(r, 'resolved');
}).then($DONE, $DONE);
// Copyright 2014 Cubane Canada, Inc. All rights reserved.
// See LICENSE for details.
/*---
info: >
Promise.resolve
es6id: S25.4.4.5
author: Sam Mikes
description: Promise.resolve delegates to foreign thenable
includes: [PromiseHelper.js]
---*/
var sequence = [];
var thenable = {
then: function(onResolve, onReject) {
sequence.push(3);
checkSequence(sequence, "thenable.then called");
assert.sameValue(this, thenable, "thenable.then called with `thenable` as `this`");
return onResolve('resolved');
}
};
sequence.push(1);
checkSequence(sequence, "no async calls yet");
var p = Promise.resolve(thenable);
sequence.push(2);
checkSequence(sequence, "thenable.then queued but not yet called");
p.then(function (r) {
sequence.push(4);
checkSequence(sequence, "all done");
assert.sameValue(r, 'resolved');
}).then($DONE, $DONE);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment