mirror of https://github.com/tc39/test262.git
Extend coverage for NewPromiseCapability
This commit is contained in:
parent
1c1a75eead
commit
615f42274d
|
@ -0,0 +1,26 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
`Promise.all` invoked on a constructor value that throws an error
|
||||
es6id: 25.4.4.1
|
||||
info: >
|
||||
1. Let C be the this value.
|
||||
[...]
|
||||
6. Let promiseCapability be NewPromiseCapability(C).
|
||||
7. ReturnIfAbrupt(promiseCapability).
|
||||
|
||||
25.4.1.5 NewPromiseCapability
|
||||
[...]
|
||||
6. Let promise be Construct(C, «executor»).
|
||||
7. ReturnIfAbrupt(promise).
|
||||
---*/
|
||||
|
||||
var CustomPromise = function() {
|
||||
throw new Test262Error();
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Promise.all.call(CustomPromise);
|
||||
});
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
`Promise.prototype.then` invoked on a constructor value that throws an
|
||||
error
|
||||
es6id: 25.4.5.3
|
||||
info: >
|
||||
1. Let promise be the this value.
|
||||
[...]
|
||||
3. Let C be SpeciesConstructor(promise, %Promise%).
|
||||
[...]
|
||||
5. Let resultCapability be NewPromiseCapability(C).
|
||||
6. ReturnIfAbrupt(resultCapability).
|
||||
|
||||
25.4.1.5 NewPromiseCapability
|
||||
[...]
|
||||
6. Let promise be Construct(C, «executor»).
|
||||
7. ReturnIfAbrupt(promise).
|
||||
features: [Symbol.species]
|
||||
---*/
|
||||
|
||||
var BadCtor = function() {
|
||||
throw new Test262Error();
|
||||
};
|
||||
var originalSpecies = Object.getOwnPropertyDescriptor(Promise, Symbol.species);
|
||||
|
||||
Object.defineProperty(Promise, Symbol.species, { value: BadCtor });
|
||||
|
||||
try {
|
||||
var p = new Promise(function(resolve) { resolve(); });
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
p.then();
|
||||
});
|
||||
} finally {
|
||||
Object.defineProperty(Promise, Symbol.species, originalSpecies);
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
`Promise.race` invoked on a constructor value that throws an error
|
||||
es6id: 25.4.4.3
|
||||
info: >
|
||||
1. Let C be the this value.
|
||||
[...]
|
||||
6. Let promiseCapability be NewPromiseCapability(C).
|
||||
7. ReturnIfAbrupt(promiseCapability).
|
||||
|
||||
25.4.1.5 NewPromiseCapability
|
||||
[...]
|
||||
6. Let promise be Construct(C, «executor»).
|
||||
7. ReturnIfAbrupt(promise).
|
||||
---*/
|
||||
|
||||
var CustomPromise = function() {
|
||||
throw new Test262Error();
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Promise.race.call(CustomPromise);
|
||||
});
|
|
@ -0,0 +1,26 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
`Promise.reject` invoked on a constructor value that throws an error
|
||||
es6id: 25.4.4.4
|
||||
info: >
|
||||
1. Let C be the this value.
|
||||
[...]
|
||||
3. Let promiseCapability be NewPromiseCapability(C).
|
||||
4. ReturnIfAbrupt(promiseCapability).
|
||||
|
||||
25.4.1.5 NewPromiseCapability
|
||||
[...]
|
||||
6. Let promise be Construct(C, «executor»).
|
||||
7. ReturnIfAbrupt(promise).
|
||||
---*/
|
||||
|
||||
var CustomPromise = function() {
|
||||
throw new Test262Error();
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Promise.reject.call(CustomPromise);
|
||||
});
|
|
@ -0,0 +1,26 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
`Promise.resolve` invoked on a constructor value that throws an error
|
||||
es6id: 25.4.4.5
|
||||
info: >
|
||||
1. Let C be the this value.
|
||||
[...]
|
||||
4. Let promiseCapability be NewPromiseCapability(C).
|
||||
5. ReturnIfAbrupt(promiseCapability).
|
||||
|
||||
25.4.1.5 NewPromiseCapability
|
||||
[...]
|
||||
6. Let promise be Construct(C, «executor»).
|
||||
7. ReturnIfAbrupt(promise).
|
||||
---*/
|
||||
|
||||
var CustomPromise = function() {
|
||||
throw new Test262Error();
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Promise.resolve.call(CustomPromise);
|
||||
});
|
Loading…
Reference in New Issue