-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Await nullish async disposable (#16408)
* Await disposing a nullish async-disposable * update fixtures * set stack.d for property access * update fixtures * fix typings
- Loading branch information
Showing
5 changed files
with
63 additions
and
7 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
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
25 changes: 25 additions & 0 deletions
25
...gin-proposal-explicit-resource-management/test/fixtures/exec-async/using-null-multiple.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,25 @@ | ||
return (async function () { | ||
const log = []; | ||
|
||
function disposable(name) { | ||
return { | ||
async [Symbol.dispose || Symbol.for("Symbol.dispose")]() { | ||
log.push(name); | ||
}, | ||
}; | ||
} | ||
|
||
async function f() { | ||
using y = disposable("y"); | ||
await using x = null; | ||
log.push("f body"); | ||
} | ||
|
||
const promise = f(); | ||
|
||
log.push("body"); | ||
|
||
await promise; | ||
|
||
expect(log).toEqual(["f body", "body", "y"]); | ||
})(); |
25 changes: 25 additions & 0 deletions
25
...roposal-explicit-resource-management/test/fixtures/exec-async/using-undefined-multiple.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,25 @@ | ||
return (async function () { | ||
const log = []; | ||
|
||
function disposable(name) { | ||
return { | ||
async [Symbol.dispose || Symbol.for("Symbol.dispose")]() { | ||
log.push(name); | ||
}, | ||
}; | ||
} | ||
|
||
async function f() { | ||
using y = disposable("y"); | ||
await using x = undefined; | ||
log.push("f body"); | ||
} | ||
|
||
const promise = f(); | ||
|
||
log.push("body"); | ||
|
||
await promise; | ||
|
||
expect(log).toEqual(["f body", "body", "y"]); | ||
})(); |
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