Skip to content
Snippets Groups Projects
Commit cd60a6d8 authored by Gorkem Yakin's avatar Gorkem Yakin
Browse files

Merge pull request #464 from jugglinmike/improve-promise-coverage-cap

Improve Promise coverage: NewPromiseCapability
parents 9d48bb08 615f4227
No related branches found
No related tags found
No related merge requests found
// 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);
});
// 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);
}
// 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);
});
// 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);
});
// 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);
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment