mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-13 04:30:16 +08:00
* Expand static Test262 harness and exception semantics * Ignore ASan fiber warning in dev source test * Refresh TS7 parity baselines after main rebase
18 lines
589 B
JavaScript
18 lines
589 B
JavaScript
/**
|
|
* @param {unknown} expectedErrorConstructor
|
|
* @param {() => unknown} func
|
|
* @returns {"pass" | "missing" | "primitive" | "wrong" | "invalid" | "unsupported"}
|
|
*/
|
|
export function throwsOutcome(expectedErrorConstructor, func) {
|
|
if (typeof func !== "function") return "invalid";
|
|
try {
|
|
func();
|
|
} catch (thrown) {
|
|
const value = thrown;
|
|
if (typeof thrown !== "object" || thrown === null) return "primitive";
|
|
if (!(thrown instanceof Error)) return "unsupported";
|
|
return value.constructor === expectedErrorConstructor ? "pass" : "wrong";
|
|
}
|
|
return "missing";
|
|
}
|