// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --harmony-promises --harmony-observation --allow-natives-syntax
+// Flags: --harmony-promises --allow-natives-syntax
var asyncAssertsExpected = 0;
})();
(function() {
- Promise.resolve(5);
- Promise.resolve(5).chain(undefined, assertUnreachable).chain(
+ Promise.accept(5);
+ Promise.accept(5).chain(undefined, assertUnreachable).chain(
function(x) { assertAsync(x === 5, "resolved/chain-nohandler") },
assertUnreachable
)
})();
(function() {
- Promise.resolve(5).then(undefined, assertUnreachable).chain(
+ Promise.accept(5).then(undefined, assertUnreachable).chain(
function(x) { assertAsync(x === 5, "resolved/then-nohandler-undefined") },
assertUnreachable
)
assertAsyncRan()
- Promise.resolve(6).then(null, assertUnreachable).chain(
+ Promise.accept(6).then(null, assertUnreachable).chain(
function(x) { assertAsync(x === 6, "resolved/then-nohandler-null") },
assertUnreachable
)
})();
(function() {
- var p1 = Promise.resolve(5)
- var p2 = Promise.resolve(p1)
- var p3 = Promise.resolve(p2)
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
p3.chain(
function(x) { assertAsync(x === p2, "resolved/chain") },
assertUnreachable
})();
(function() {
- var p1 = Promise.resolve(5)
- var p2 = Promise.resolve(p1)
- var p3 = Promise.resolve(p2)
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
p3.then(
function(x) { assertAsync(x === 5, "resolved/then") },
assertUnreachable
(function() {
var p1 = Promise.reject(5)
- var p2 = Promise.resolve(p1)
- var p3 = Promise.resolve(p2)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
p3.chain(
function(x) { assertAsync(x === p2, "rejected/chain") },
assertUnreachable
(function() {
var p1 = Promise.reject(5)
- var p2 = Promise.resolve(p1)
- var p3 = Promise.resolve(p2)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
p3.then(
assertUnreachable,
function(x) { assertAsync(x === 5, "rejected/then") }
})();
(function() {
- var p1 = Promise.resolve(5)
- var p2 = Promise.resolve(p1)
- var p3 = Promise.resolve(p2)
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
p3.chain(function(x) { return x }, assertUnreachable).chain(
function(x) { assertAsync(x === p1, "resolved/chain/chain") },
assertUnreachable
})();
(function() {
- var p1 = Promise.resolve(5)
- var p2 = Promise.resolve(p1)
- var p3 = Promise.resolve(p2)
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
p3.chain(function(x) { return x }, assertUnreachable).then(
function(x) { assertAsync(x === 5, "resolved/chain/then") },
assertUnreachable
})();
(function() {
- var p1 = Promise.resolve(5)
- var p2 = Promise.resolve(p1)
- var p3 = Promise.resolve(p2)
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
p3.chain(function(x) { return 6 }, assertUnreachable).chain(
function(x) { assertAsync(x === 6, "resolved/chain/chain2") },
assertUnreachable
})();
(function() {
- var p1 = Promise.resolve(5)
- var p2 = Promise.resolve(p1)
- var p3 = Promise.resolve(p2)
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
p3.chain(function(x) { return 6 }, assertUnreachable).then(
function(x) { assertAsync(x === 6, "resolved/chain/then2") },
assertUnreachable
})();
(function() {
- var p1 = Promise.resolve(5)
- var p2 = Promise.resolve(p1)
- var p3 = Promise.resolve(p2)
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
p3.then(function(x) { return x + 1 }, assertUnreachable).chain(
function(x) { assertAsync(x === 6, "resolved/then/chain") },
assertUnreachable
})();
(function() {
- var p1 = Promise.resolve(5)
- var p2 = Promise.resolve(p1)
- var p3 = Promise.resolve(p2)
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
p3.then(function(x) { return x + 1 }, assertUnreachable).then(
function(x) { assertAsync(x === 6, "resolved/then/then") },
assertUnreachable
})();
(function() {
- var p1 = Promise.resolve(5)
- var p2 = Promise.resolve(p1)
- var p3 = Promise.resolve(p2)
- p3.then(function(x){ return Promise.resolve(x+1) }, assertUnreachable).chain(
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
+ p3.then(function(x){ return Promise.accept(x+1) }, assertUnreachable).chain(
function(x) { assertAsync(x === 6, "resolved/then/chain2") },
assertUnreachable
)
})();
(function() {
- var p1 = Promise.resolve(5)
- var p2 = Promise.resolve(p1)
- var p3 = Promise.resolve(p2)
- p3.then(function(x) { return Promise.resolve(x+1) }, assertUnreachable).then(
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
+ p3.then(function(x) { return Promise.accept(x+1) }, assertUnreachable).then(
function(x) { assertAsync(x === 6, "resolved/then/then2") },
assertUnreachable
)
})();
(function() {
- var p1 = Promise.resolve(5)
- var p2 = Promise.resolve(p1)
- var p3 = Promise.resolve(p2)
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
p3.chain(function(x) { throw 6 }, assertUnreachable).chain(
assertUnreachable,
function(x) { assertAsync(x === 6, "resolved/chain-throw/chain") }
})();
(function() {
- var p1 = Promise.resolve(5)
- var p2 = Promise.resolve(p1)
- var p3 = Promise.resolve(p2)
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
p3.chain(function(x) { throw 6 }, assertUnreachable).then(
assertUnreachable,
function(x) { assertAsync(x === 6, "resolved/chain-throw/then") }
})();
(function() {
- var p1 = Promise.resolve(5)
- var p2 = Promise.resolve(p1)
- var p3 = Promise.resolve(p2)
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
p3.then(function(x) { throw 6 }, assertUnreachable).chain(
assertUnreachable,
function(x) { assertAsync(x === 6, "resolved/then-throw/chain") }
})();
(function() {
- var p1 = Promise.resolve(5)
- var p2 = Promise.resolve(p1)
- var p3 = Promise.resolve(p2)
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
p3.then(function(x) { throw 6 }, assertUnreachable).then(
assertUnreachable,
function(x) { assertAsync(x === 6, "resolved/then-throw/then") }
})();
(function() {
- var p1 = Promise.resolve(5)
+ var p1 = Promise.accept(5)
var p2 = {then: function(onResolve, onReject) { onResolve(p1) }}
- var p3 = Promise.resolve(p2)
+ var p3 = Promise.accept(p2)
p3.chain(
function(x) { assertAsync(x === p2, "resolved/thenable/chain") },
assertUnreachable
})();
(function() {
- var p1 = Promise.resolve(5)
+ var p1 = Promise.accept(5)
var p2 = {then: function(onResolve, onReject) { onResolve(p1) }}
- var p3 = Promise.resolve(p2)
+ var p3 = Promise.accept(p2)
p3.then(
function(x) { assertAsync(x === 5, "resolved/thenable/then") },
assertUnreachable
(function() {
var p1 = Promise.reject(5)
var p2 = {then: function(onResolve, onReject) { onResolve(p1) }}
- var p3 = Promise.resolve(p2)
+ var p3 = Promise.accept(p2)
p3.chain(
function(x) { assertAsync(x === p2, "rejected/thenable/chain") },
assertUnreachable
(function() {
var p1 = Promise.reject(5)
var p2 = {then: function(onResolve, onReject) { onResolve(p1) }}
- var p3 = Promise.resolve(p2)
+ var p3 = Promise.accept(p2)
p3.then(
assertUnreachable,
function(x) { assertAsync(x === 5, "rejected/thenable/then") }
(function() {
var deferred = Promise.defer()
var p1 = deferred.promise
- var p2 = Promise.resolve(p1)
- var p3 = Promise.resolve(p2)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
p3.chain(
function(x) { assertAsync(x === p2, "chain/resolve") },
assertUnreachable
(function() {
var deferred = Promise.defer()
var p1 = deferred.promise
- var p2 = Promise.resolve(p1)
- var p3 = Promise.resolve(p2)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
p3.then(
function(x) { assertAsync(x === 5, "then/resolve") },
assertUnreachable
(function() {
var deferred = Promise.defer()
var p1 = deferred.promise
- var p2 = Promise.resolve(p1)
- var p3 = Promise.resolve(p2)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
p3.chain(
function(x) { assertAsync(x === p2, "chain/reject") },
assertUnreachable
(function() {
var deferred = Promise.defer()
var p1 = deferred.promise
- var p2 = Promise.resolve(p1)
- var p3 = Promise.resolve(p2)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
p3.then(
assertUnreachable,
function(x) { assertAsync(x === 5, "then/reject") }
var deferred = Promise.defer()
var p1 = deferred.promise
var p2 = {then: function(onResolve, onReject) { onResolve(p1) }}
- var p3 = Promise.resolve(p2)
+ var p3 = Promise.accept(p2)
p3.chain(
function(x) { assertAsync(x === p2, "chain/resolve/thenable") },
assertUnreachable
var deferred = Promise.defer()
var p1 = deferred.promise
var p2 = {then: function(onResolve, onReject) { onResolve(p1) }}
- var p3 = Promise.resolve(p2)
+ var p3 = Promise.accept(p2)
p3.then(
function(x) { assertAsync(x === 5, "then/resolve/thenable") },
assertUnreachable
var deferred = Promise.defer()
var p1 = deferred.promise
var p2 = {then: function(onResolve, onReject) { onResolve(p1) }}
- var p3 = Promise.resolve(p2)
+ var p3 = Promise.accept(p2)
p3.chain(
function(x) { assertAsync(x === p2, "chain/reject/thenable") },
assertUnreachable
var deferred = Promise.defer()
var p1 = deferred.promise
var p2 = {then: function(onResolve, onReject) { onResolve(p1) }}
- var p3 = Promise.resolve(p2)
+ var p3 = Promise.accept(p2)
p3.then(
assertUnreachable,
function(x) { assertAsync(x === 5, "then/reject/thenable") }
})();
(function() {
- var p1 = Promise.resolve(5)
- var p2 = Promise.resolve(p1)
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
var deferred = Promise.defer()
var p3 = deferred.promise
p3.chain(
})();
(function() {
- var p1 = Promise.resolve(5)
- var p2 = Promise.resolve(p1)
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
var deferred = Promise.defer()
var p3 = deferred.promise
p3.then(
})();
(function() {
- var p1 = Promise.resolve(5)
- var p2 = Promise.resolve(p1)
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
var deferred = Promise.defer()
var p3 = deferred.promise
p3.chain(
})();
(function() {
- var p1 = Promise.resolve(5)
- var p2 = Promise.resolve(p1)
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
var deferred = Promise.defer()
var p3 = deferred.promise
p3.then(
})();
(function() {
- var p1 = Promise.resolve(5)
+ var p1 = Promise.accept(5)
var p2 = {then: function(onResolve, onReject) { onResolve(p1) }}
var deferred = Promise.defer()
var p3 = deferred.promise
})();
(function() {
- var p1 = Promise.resolve(5)
+ var p1 = Promise.accept(5)
var p2 = {then: function(onResolve, onReject) { onResolve(p1) }}
var deferred = Promise.defer()
var p3 = deferred.promise
})();
(function() {
- var p1 = Promise.resolve(0)
+ var p1 = Promise.accept(0)
var p2 = p1.chain(function(x) { return p2 }, assertUnreachable)
p2.chain(
assertUnreachable,
})();
(function() {
- var p1 = Promise.resolve(0)
+ var p1 = Promise.accept(0)
var p2 = p1.then(function(x) { return p2 }, assertUnreachable)
p2.chain(
assertUnreachable,
(function() {
var deferred = Promise.defer()
var p1 = deferred.promise
- var p2 = Promise.resolve(2)
+ var p2 = Promise.accept(2)
var p3 = Promise.defer().promise
Promise.all([p1, p2, p3]).chain(
assertUnreachable,
})();
(function() {
- var p1 = Promise.resolve(1)
- var p2 = Promise.resolve(2)
- var p3 = Promise.resolve(3)
+ var p1 = Promise.accept(1)
+ var p2 = Promise.accept(2)
+ var p3 = Promise.accept(3)
Promise.race([p1, p2, p3]).chain(
function(x) { assertAsync(x === 1, "resolved/one") },
assertUnreachable
})();
(function() {
- var p1 = Promise.resolve(1)
- var p2 = Promise.resolve(2)
- var p3 = Promise.resolve(3)
+ var p1 = Promise.accept(1)
+ var p2 = Promise.accept(2)
+ var p3 = Promise.accept(3)
Promise.race([0, p1, p2, p3]).chain(
function(x) { assertAsync(x === 0, "resolved-const/one") },
assertUnreachable
(function() {
var deferred = Promise.defer()
var p1 = deferred.promise
- var p2 = Promise.resolve(2)
+ var p2 = Promise.accept(2)
var p3 = Promise.defer().promise
Promise.race([p1, p2, p3]).chain(
function(x) { assertAsync(x === 2, "resolved/one") },
assertTrue(log === "dncncnx6", "subclass/chain")
log = ""
- Promise.all([11, Promise.resolve(12), 13, MyPromise.resolve(14), 15, 16])
+ Promise.all([11, Promise.accept(12), 13, MyPromise.accept(14), 15, 16])
assertTrue(log === "nx14cn", "subclass/all/arg")
log = ""
- MyPromise.all([21, Promise.resolve(22), 23, MyPromise.resolve(24), 25, 26])
+ MyPromise.all([21, Promise.accept(22), 23, MyPromise.accept(24), 25, 26])
assertTrue(log === "nx24nnx21cnnx23cncnnx25cnnx26cn", "subclass/all/self")
})();