-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix test regression in asyncHelpers.js
- Loading branch information
Showing
2 changed files
with
47 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
test/harness/asyncHelpers-throwsAsync-func-bad-thenable.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (C) 2024 Julián Espina. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
description: | | ||
assert.throwsAsync returns a promise that rejects if func returns a bad thenable. | ||
flags: [async] | ||
includes: [asyncHelpers.js] | ||
---*/ | ||
|
||
asyncTest(async function() { | ||
var caught = false; | ||
var func = function () { | ||
return { | ||
then: function () {}, | ||
}; | ||
}; | ||
const p = assert.throwsAsync(TypeError, func); | ||
assert(p instanceof Promise, "assert.throwsAsync should return a promise"); | ||
try { | ||
await p; | ||
} catch (e) { | ||
caught = true; | ||
assert.sameValue( | ||
e.constructor, | ||
Test262Error, | ||
"throwsAsync should reject bad thenable with a Test262Error" | ||
); | ||
} finally { | ||
assert( | ||
caught, | ||
"assert.throwsAsync did not reject bad thenable in " + func | ||
); | ||
} | ||
}); |