-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: can't use setInitialize of LazyCell multi-times
- Loading branch information
Showing
2 changed files
with
19 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { assertEquals } from "./deps/std/assert.ts"; | ||
import { LazyCell } from "./util.ts"; | ||
|
||
Deno.test({ | ||
name: "LazyCell", | ||
async fn(t) { | ||
await t.step({ | ||
name: "can use setInitialize multi-times", | ||
async fn() { | ||
const cell = new LazyCell(() => 0); | ||
cell.setInitializer(() => Promise.resolve(1)); | ||
assertEquals(await cell.get(), 1); | ||
cell.setInitializer(() => Promise.resolve(2)); | ||
assertEquals(await cell.get(), 2); | ||
}, | ||
}); | ||
}, | ||
}); |