2015-12-02 18:06:40 +01:00
|
|
|
// Copyright (C) 2015 André Bargull. All rights reserved.
|
|
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
|
|
|
|
/*---
|
|
|
|
es6id: 25.4.4.1
|
|
|
|
description: >
|
|
|
|
Throws a TypeError if either resolve or reject capability is not callable.
|
2018-01-05 18:26:51 +01:00
|
|
|
info: |
|
2015-12-02 18:06:40 +01:00
|
|
|
Promise.all ( iterable )
|
|
|
|
|
|
|
|
...
|
|
|
|
6. Let promiseCapability be NewPromiseCapability(C).
|
|
|
|
7. ReturnIfAbrupt(promiseCapability).
|
|
|
|
...
|
|
|
|
|
|
|
|
25.4.1.5 NewPromiseCapability ( C )
|
|
|
|
...
|
|
|
|
4. Let executor be a new built-in function object as defined in GetCapabilitiesExecutor Functions (25.4.1.5.1).
|
|
|
|
5. Set the [[Capability]] internal slot of executor to promiseCapability.
|
|
|
|
6. Let promise be Construct(C, «executor»).
|
|
|
|
7. ReturnIfAbrupt(promise).
|
|
|
|
8. If IsCallable(promiseCapability.[[Resolve]]) is false, throw a TypeError exception.
|
|
|
|
9. If IsCallable(promiseCapability.[[Reject]]) is false, throw a TypeError exception.
|
|
|
|
...
|
|
|
|
---*/
|
|
|
|
|
|
|
|
var checkPoint = "";
|
2019-04-24 19:35:20 +02:00
|
|
|
function fn1(executor) {
|
|
|
|
checkPoint += "a";
|
|
|
|
}
|
|
|
|
Object.defineProperty(fn1, 'resolve', {
|
|
|
|
get() { throw new Test262Error; }
|
|
|
|
});
|
2015-12-02 18:06:40 +01:00
|
|
|
assert.throws(TypeError, function() {
|
2019-04-24 19:35:20 +02:00
|
|
|
Promise.all.call(fn1, []);
|
2015-12-02 18:06:40 +01:00
|
|
|
}, "executor not called at all");
|
|
|
|
assert.sameValue(checkPoint, "a", "executor not called at all");
|
|
|
|
|
2019-04-24 19:35:20 +02:00
|
|
|
checkPoint = "";
|
|
|
|
function fn2(executor) {
|
|
|
|
checkPoint += "a";
|
|
|
|
executor();
|
|
|
|
checkPoint += "b";
|
|
|
|
}
|
|
|
|
Object.defineProperty(fn2, 'resolve', {
|
|
|
|
get() { throw new Test262Error; }
|
|
|
|
});
|
2015-12-02 18:06:40 +01:00
|
|
|
assert.throws(TypeError, function() {
|
2019-04-24 19:35:20 +02:00
|
|
|
Promise.all.call(fn2, []);
|
2015-12-02 18:06:40 +01:00
|
|
|
}, "executor called with no arguments");
|
|
|
|
assert.sameValue(checkPoint, "ab", "executor called with no arguments");
|
|
|
|
|
2019-04-24 19:35:20 +02:00
|
|
|
checkPoint = "";
|
|
|
|
function fn3(executor) {
|
|
|
|
checkPoint += "a";
|
|
|
|
executor(undefined, undefined);
|
|
|
|
checkPoint += "b";
|
|
|
|
}
|
|
|
|
Object.defineProperty(fn3, 'resolve', {
|
|
|
|
get() { throw new Test262Error; }
|
|
|
|
});
|
2015-12-02 18:06:40 +01:00
|
|
|
assert.throws(TypeError, function() {
|
2019-04-24 19:35:20 +02:00
|
|
|
Promise.all.call(fn3, []);
|
2015-12-02 18:06:40 +01:00
|
|
|
}, "executor called with (undefined, undefined)");
|
|
|
|
assert.sameValue(checkPoint, "ab", "executor called with (undefined, undefined)");
|
|
|
|
|
2019-04-24 19:35:20 +02:00
|
|
|
checkPoint = "";
|
|
|
|
function fn4(executor) {
|
|
|
|
checkPoint += "a";
|
|
|
|
executor(undefined, function() {});
|
|
|
|
checkPoint += "b";
|
|
|
|
}
|
|
|
|
Object.defineProperty(fn4, 'resolve', {
|
|
|
|
get() { throw new Test262Error; }
|
|
|
|
});
|
2015-12-02 18:06:40 +01:00
|
|
|
assert.throws(TypeError, function() {
|
2019-04-24 19:35:20 +02:00
|
|
|
Promise.all.call(fn4, []);
|
2015-12-02 18:06:40 +01:00
|
|
|
}, "executor called with (undefined, function)");
|
|
|
|
assert.sameValue(checkPoint, "ab", "executor called with (undefined, function)");
|
|
|
|
|
2019-04-24 19:35:20 +02:00
|
|
|
checkPoint = "";
|
|
|
|
function fn5(executor) {
|
|
|
|
checkPoint += "a";
|
|
|
|
executor(function() {}, undefined);
|
|
|
|
checkPoint += "b";
|
|
|
|
}
|
|
|
|
Object.defineProperty(fn5, 'resolve', {
|
|
|
|
get() { throw new Test262Error; }
|
|
|
|
});
|
2015-12-02 18:06:40 +01:00
|
|
|
assert.throws(TypeError, function() {
|
2019-04-24 19:35:20 +02:00
|
|
|
Promise.all.call(fn5, []);
|
2015-12-02 18:06:40 +01:00
|
|
|
}, "executor called with (function, undefined)");
|
|
|
|
assert.sameValue(checkPoint, "ab", "executor called with (function, undefined)");
|
|
|
|
|
2019-04-24 19:35:20 +02:00
|
|
|
checkPoint = "";
|
|
|
|
function fn6(executor) {
|
|
|
|
checkPoint += "a";
|
|
|
|
executor(123, "invalid value");
|
|
|
|
checkPoint += "b";
|
|
|
|
}
|
|
|
|
Object.defineProperty(fn6, 'resolve', {
|
|
|
|
get() { throw new Test262Error; }
|
|
|
|
});
|
2015-12-02 18:06:40 +01:00
|
|
|
assert.throws(TypeError, function() {
|
2019-04-24 19:35:20 +02:00
|
|
|
Promise.all.call(fn6, []);
|
2015-12-02 18:06:40 +01:00
|
|
|
}, "executor called with (Number, String)");
|
|
|
|
assert.sameValue(checkPoint, "ab", "executor called with (Number, String)");
|