mirror of
https://github.com/tc39/test262.git
synced 2025-07-27 07:54:41 +02:00
thrower in the middle
This commit is contained in:
parent
4314e2cab3
commit
5867eb3f1a
30
test/built-ins/Promise/resolve-constructor-trickery.js
Normal file
30
test/built-ins/Promise/resolve-constructor-trickery.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// Copyright (C) 2018 Leo Balter. All rights reserved.
|
||||||
|
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
description: thrower in the middle
|
||||||
|
flags: [async]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var throwable = new Test262Error("lol");
|
||||||
|
var p = Promise.resolve(42);
|
||||||
|
|
||||||
|
Object.defineProperty(p, "constructor", {
|
||||||
|
get() {
|
||||||
|
throw throwable;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
async function fn() {
|
||||||
|
return await p;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn().then(
|
||||||
|
result => {
|
||||||
|
throw new Test262Error("Promise should be rejected.");
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
assert.sameValue(error, throwable, "Promise should be rejected with throwable");
|
||||||
|
}
|
||||||
|
).then($DONE, $DONE);
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user