Debian Codegraph @

js/src/tests/non262/async-functions/parameters-error-reject-promise.js

raw
1 // |reftest| skip-if(!xulRuntime.shell) -- needs drainJobQueue
2
3 class ExpectedError extends Error {
4 name = "ExpectedError";
5 }
6
7 class UnexpectedError extends Error {
8 name = "UnexpectedError";
9 }
10
11 function throwExpectedError() {
12 throw new ExpectedError();
13 }
14
15 async function throwsInParameterExpression(a = throwExpectedError()) {
16 throw new UnexpectedError();
17 }
18 assertEventuallyThrows(throwsInParameterExpression(), ExpectedError);
19
20 async function throwsInObjectDestructuringParameterEmpty({}) {
21 throw new UnexpectedError();
22 }
23 assertEventuallyThrows(throwsInObjectDestructuringParameterEmpty(), TypeError);
24
25 let objectThrowingExpectedError = {
26 get a() {
27 throw new ExpectedError();
28 }
29 }
30
31 async function throwsInObjectDestructuringParameter({a}) {
32 throw new UnexpectedError();
33 }
34 assertEventuallyThrows(throwsInObjectDestructuringParameter(), TypeError);
35 assertEventuallyThrows(throwsInObjectDestructuringParameter(objectThrowingExpectedError), ExpectedError);
36
37 let iteratorThrowingExpectedError = {
38 [Symbol.iterator]() {
39 throw new ExpectedError();
40 }
41 };
42
43 async function throwsInArrayDestructuringParameterEmpty([]) {
44 throw new UnexpectedError();
45 }
46 assertEventuallyThrows(throwsInArrayDestructuringParameterEmpty(), TypeError);
47 assertEventuallyThrows(throwsInArrayDestructuringParameterEmpty(iteratorThrowingExpectedError), ExpectedError);
48
49 async function throwsInArrayDestructuringParameter([a]) {
50 throw new UnexpectedError();
51 }
52 assertEventuallyThrows(throwsInArrayDestructuringParameter(), TypeError);
53 assertEventuallyThrows(throwsInArrayDestructuringParameter(iteratorThrowingExpectedError), ExpectedError);
54
55 if (typeof reportCompare === "function")
56 reportCompare(true, true);