diff options
author | 2023-03-02 19:02:10 -0800 | |
---|---|---|
committer | 2023-03-02 19:02:10 -0800 | |
commit | 9388b3f8257bc2e580deaece4cd2677928104fc6 (patch) | |
tree | 3f6aff2009cef69897f599fe51305b894f81a376 /test/bun.js/disabled-module.test.js | |
parent | b469e5035161286abeb1a7726518d1afcc163a51 (diff) | |
download | bun-9388b3f8257bc2e580deaece4cd2677928104fc6.tar.gz bun-9388b3f8257bc2e580deaece4cd2677928104fc6.tar.zst bun-9388b3f8257bc2e580deaece4cd2677928104fc6.zip |
Add a zig fmt action (#2277)
* Add a zig fmt action
* add failing file
* Setup prettier better
* Update prettier-fmt.yml
* Fail on error
* Update prettier-fmt.yml
* boop
* boop2
* tar.gz
* Update zig-fmt.yml
* Update zig-fmt.yml
* Update zig-fmt.yml
* Update zig-fmt.yml
* Update zig-fmt.yml
* boop
* Update prettier-fmt.yml
* tag
* newlines
* multiline
* fixup
* Update zig-fmt.yml
* update it
* fixup
* both
* w
* Update prettier-fmt.yml
* prettier all the things
* Update package.json
* zig fmt
* ❌ ✅
* bump
* .
* quotes
* fix prettier ignore
* once more
* Update prettier-fmt.yml
* Update fallback.ts
* consistentcy
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'test/bun.js/disabled-module.test.js')
-rw-r--r-- | test/bun.js/disabled-module.test.js | 94 |
1 files changed, 64 insertions, 30 deletions
diff --git a/test/bun.js/disabled-module.test.js b/test/bun.js/disabled-module.test.js index c12676959..61411aa44 100644 --- a/test/bun.js/disabled-module.test.js +++ b/test/bun.js/disabled-module.test.js @@ -1,38 +1,72 @@ import { expect, test } from "bun:test"; -test("not implemented yet module masquerades as undefined and throws an error", () => { - const worker_threads = import.meta.require("worker_threads"); +// test("not implemented yet module masquerades as undefined and throws an error", () => { +// const worker_threads = import.meta.require("worker_threads"); - expect(typeof worker_threads).toBe("undefined"); - expect(typeof worker_threads.getEnvironmentData).toBe("undefined"); +// expect(typeof worker_threads).toBe("undefined"); +// expect(typeof worker_threads.getEnvironmentData).toBe("undefined"); +// }); + +test("AsyncContext", async done => { + const { AsyncContext } = import.meta.require("async_hooks"); + console.log("here"); + const ctx = new AsyncContext(); + ctx + .run(1234, async () => { + expect(ctx.get()).toBe(1234); + console.log("here"); + await 1; + console.log("ctx", ctx.get()); + const setTimeoutResult = await ctx.run( + 2345, + () => + new Promise(resolve => { + queueMicrotask(() => { + console.log("queueMicrotask", ctx.get()); + resolve(ctx.get()); + }); + }), + ); + expect(setTimeoutResult).toBe(2345); + expect(ctx.get()).toBe(1234); + return "final result"; + }) + .then(result => { + expect(result).toBe("final result"); + // The code that generated the Promise has access to the 1234 + // value provided to ctx.run above, but consumers of the Promise + // do not automatically inherit it. + expect(ctx.get()).toBeUndefined(); + done(); + }); }); -test("AsyncLocalStorage polyfill", () => { - const { AsyncLocalStorage } = import.meta.require("async_hooks"); +// test("AsyncLocalStorage polyfill", () => { +// const { AsyncLocalStorage } = import.meta.require("async_hooks"); - const store = new AsyncLocalStorage(); - var called = false; - expect(store.getStore()).toBe(null); - store.run({ foo: "bar" }, () => { - expect(store.getStore()).toEqual({ foo: "bar" }); - called = true; - }); - expect(store.getStore()).toBe(null); - expect(called).toBe(true); -}); +// const store = new AsyncLocalStorage(); +// var called = false; +// expect(store.getStore()).toBe(null); +// store.run({ foo: "bar" }, () => { +// expect(store.getStore()).toEqual({ foo: "bar" }); +// called = true; +// }); +// expect(store.getStore()).toBe(null); +// expect(called).toBe(true); +// }); -test("AsyncResource polyfill", () => { - const { AsyncResource } = import.meta.require("async_hooks"); +// test("AsyncResource polyfill", () => { +// const { AsyncResource } = import.meta.require("async_hooks"); - const resource = new AsyncResource("test"); - var called = false; - resource.runInAsyncScope( - () => { - called = true; - }, - null, - "foo", - "bar", - ); - expect(called).toBe(true); -}); +// const resource = new AsyncResource("test"); +// var called = false; +// resource.runInAsyncScope( +// () => { +// called = true; +// }, +// null, +// "foo", +// "bar", +// ); +// expect(called).toBe(true); +// }); |