From 1c92d241fa1f7f7da2d20719e1291aea845bef7a Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Tue, 28 May 2024 13:27:52 -0700 Subject: [PATCH 01/13] deps: update to latest starlingmonkey --- StarlingMonkey | 2 +- embedding/embedding.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/StarlingMonkey b/StarlingMonkey index c1d7439..4a76bf0 160000 --- a/StarlingMonkey +++ b/StarlingMonkey @@ -1 +1 @@ -Subproject commit c1d7439a3412496db0c5d4004d723396cc46a892 +Subproject commit 4a76bf0c5130424664e309faac6d434de756a63c diff --git a/embedding/embedding.cpp b/embedding/embedding.cpp index 0c0ca59..b63a7fe 100644 --- a/embedding/embedding.cpp +++ b/embedding/embedding.cpp @@ -274,7 +274,7 @@ extern "C" } Runtime.free_list.clear(); RootedValue result(Runtime.cx); - Runtime.engine->run_event_loop(&result); + Runtime.engine->run_event_loop(); LOG("(post_call) end"); } From 1a0c843ceea41bc91ac691765685181085b05521 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Wed, 29 May 2024 13:29:37 -0700 Subject: [PATCH 02/13] fixup splicing --- .../src/splice.rs | 88 ++++++------------- embedding/embedding.cpp | 6 +- 2 files changed, 28 insertions(+), 66 deletions(-) diff --git a/crates/spidermonkey-embedding-splicer/src/splice.rs b/crates/spidermonkey-embedding-splicer/src/splice.rs index fd7b354..12c397f 100644 --- a/crates/spidermonkey-embedding-splicer/src/splice.rs +++ b/crates/spidermonkey-embedding-splicer/src/splice.rs @@ -1,15 +1,10 @@ use walrus::{ - ir::{ - BinaryOp, Binop, Const, Instr, LoadKind, LocalGet, LocalSet, LocalTee, MemArg, Store, - StoreKind, UnaryOp, Unop, Value, - }, + ir::{BinaryOp, Binop, Const, Instr, LoadKind, MemArg, Store, StoreKind, UnaryOp, Unop, Value}, ExportId, ExportItem, FunctionBuilder, FunctionId, LocalId, ValType, }; use crate::*; -const DEBUG: bool = false; - // // Parses the Spidermonkey binary into section data for reserialization // into an output binary, and in the process: @@ -39,10 +34,7 @@ pub fn splice( exports: Vec<(String, CoreFn)>, debug: bool, ) -> Result> { - let mut config = walrus::ModuleConfig::new(); - if debug { - config.generate_dwarf(true); - } + let config = walrus::ModuleConfig::new(); let mut module = config.parse(&engine)?; // since StarlingMonkey implements CLI Run and incoming handler, @@ -76,7 +68,7 @@ pub fn splice( // extract the native instructions from sample functions // then inline the imported functions and main import gating function // (erasing sample functions in the process) - synthesize_import_functions(&mut module, &imports)?; + synthesize_import_functions(&mut module, &imports, debug)?; // create the exported functions as wrappers around the "cabi_call" function synthesize_export_functions(&mut module, &exports)?; @@ -94,6 +86,7 @@ fn get_export_fid(module: &walrus::Module, expt_id: &ExportId) -> FunctionId { fn synthesize_import_functions( module: &mut walrus::Module, imports: &Vec<(String, String, CoreFn, Option)>, + debug: bool, ) -> Result<()> { let mut coreabi_get_import: Option = None; let mut cabi_realloc: Option = None; @@ -116,8 +109,26 @@ fn synthesize_import_functions( let cabi_realloc_fid = get_export_fid(module, &cabi_realloc.unwrap()); - let coreabi_sample_fid = get_export_fid(module, coreabi_sample_ids.first().unwrap()); - let coreabi_sample_i32 = module.funcs.get(coreabi_sample_fid).kind.unwrap_local(); + let coreabi_sample_i32 = module + .funcs + .get(get_export_fid(module, &coreabi_sample_ids[0])) + .kind + .unwrap_local(); + let _coreabi_sample_i64 = module + .funcs + .get(get_export_fid(module, &coreabi_sample_ids[1])) + .kind + .unwrap_local(); + let _coreabi_sample_f32 = module + .funcs + .get(get_export_fid(module, &coreabi_sample_ids[2])) + .kind + .unwrap_local(); + let _coreabi_sample_f64 = module + .funcs + .get(get_export_fid(module, &coreabi_sample_ids[3])) + .kind + .unwrap_local(); // These functions retrieve the corresponding type // from a JS::HandleValue @@ -179,7 +190,7 @@ fn synthesize_import_functions( let tmp_local = module.locals.add(ValType::I64); for (impt_specifier, impt_name, impt_sig, retptr_size) in imports.iter() { - if DEBUG { + if debug { println!( "> IMPORT {} {} > {:?}", impt_specifier, impt_name, &impt_sig @@ -226,55 +237,6 @@ fn synthesize_import_functions( let mut func_body = func.func_body(); - // copy the prelude instructions from the sample function (first block) - let coreabi_sample_i32 = module.funcs.get(coreabi_sample_fid).kind.unwrap_local(); - let prelude_block = &coreabi_sample_i32 - .block(coreabi_sample_i32.entry_block()) - .instrs[0] - .0; - let prelude_seq = match prelude_block { - Instr::Block(prelude_block) => prelude_block.seq, - _ => { - eprintln!("Splicer error: unable to read prelude sequence, continuing for debug build but note binding functions will not work!"); - return Ok(()); - } - }; - - let prelude_block = coreabi_sample_i32.block(prelude_seq); - func_body.block(None, |prelude| { - for (instr, _) in &prelude_block.instrs { - match instr { - Instr::LocalGet(LocalGet { local }) => { - if local.eq(&vp_arg) { - prelude.instr(instr.clone()); - } else { - prelude.local_get(tmp_local); - } - } - Instr::LocalSet(LocalSet { local }) => { - if local.eq(&vp_arg) { - prelude.instr(instr.clone()); - } else { - prelude.local_set(tmp_local); - } - } - Instr::LocalTee(LocalTee { local }) => { - if local.eq(&vp_arg) { - prelude.instr(instr.clone()); - } else { - prelude.local_tee(tmp_local); - } - } - Instr::BrIf(_) => { - prelude.br_if(prelude.id()); - } - _ => { - prelude.instr(instr.clone()); - } - }; - } - }); - // stack the return arg now as it chains with the // args we're about to add to the stack if impt_sig.ret.is_some() { diff --git a/embedding/embedding.cpp b/embedding/embedding.cpp index b63a7fe..154327c 100644 --- a/embedding/embedding.cpp +++ b/embedding/embedding.cpp @@ -70,7 +70,7 @@ extern "C" { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); int64_t arg1 = from_bigint64(args[1]); - args.rval().setBigInt(to_bigint64(cx, arg1)); + args.rval().setBigInt(to_bigint64(cx, arg1 * 32771)); return true; } @@ -78,7 +78,7 @@ extern "C" { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); float arg2 = static_cast(args[2].toDouble()); - args.rval().setDouble(arg2); + args.rval().setDouble(arg2 * 32771); return true; } @@ -86,7 +86,7 @@ extern "C" { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); double arg3 = args[3].toDouble(); - args.rval().setDouble(arg3); + args.rval().setDouble(arg3 * 32771); return true; } From 510f96d29e855360cf1429dc8ba3785849da0aed Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Wed, 29 May 2024 14:59:58 -0700 Subject: [PATCH 03/13] latest starlingmonkey --- StarlingMonkey | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StarlingMonkey b/StarlingMonkey index 4a76bf0..aa9ff14 160000 --- a/StarlingMonkey +++ b/StarlingMonkey @@ -1 +1 @@ -Subproject commit 4a76bf0c5130424664e309faac6d434de756a63c +Subproject commit aa9ff14cd0696877a402435faaf8db486ce0ff89 From 9d6e84e008eb546f26a91fe8a115a9c1a6fb28b4 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Wed, 29 May 2024 15:03:26 -0700 Subject: [PATCH 04/13] update rust toolchain --- .github/workflows/main.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 50c022a..30218c6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,12 +28,11 @@ jobs: with: submodules: recursive - - name: Install Rust 1.68.2, 1.76.0 + - name: Install Rust Toolchain run: | - rustup toolchain install 1.68.2 - rustup toolchain install 1.76.0 - rustup target add wasm32-unknown-unknown --toolchain 1.76.0 - rustup target add wasm32-wasi --toolchain 1.68.2 + rustup toolchain install stable + rustup target add wasm32-unknown-unknown --toolchain stable + rustup target add wasm32-wasi --toolchain 1.77.1 - uses: actions/setup-node@v2 with: From 3323f113edbdaa9086c213cca2e0874e6b0ca4b4 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Wed, 29 May 2024 15:46:05 -0700 Subject: [PATCH 05/13] fixup tests --- StarlingMonkey | 2 +- test/builtins/console-object.js | 6 +++++- test/builtins/globals.js | 2 +- test/builtins/timeout.js | 2 ++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/StarlingMonkey b/StarlingMonkey index aa9ff14..2e23c54 160000 --- a/StarlingMonkey +++ b/StarlingMonkey @@ -1 +1 @@ -Subproject commit aa9ff14cd0696877a402435faaf8db486ce0ff89 +Subproject commit 2e23c54f2a9a51cd846b4007fa9eb31bb04d4e10 diff --git a/test/builtins/console-object.js b/test/builtins/console-object.js index 399ba03..2c7e703 100644 --- a/test/builtins/console-object.js +++ b/test/builtins/console-object.js @@ -53,6 +53,10 @@ export const source = ` export async function test (run) { const { stdout, stderr } = await run(); - strictEqual(stdout, `{ a: { value: "a" }, b: { c: "d" }, e: ["f"], g: [{ g: "i" }], l: [Function l], m: [Getter], n: [Getter], o: [Function], p: [Function], q: 5, s: 29879287298374924, t: Set(3) { 1, 2, 3 }, u: Map(3) { 1 => 2, 3 => 4, [Function foo] => {} }, v: Symbol.for("blah"), w: Symbol(), x: undefined, y: null, z: URL { hash: "", host: "site.com", hostname: "site.com", href: "https://site.com/x?a&b", origin: "https://site.com", password: "", pathname: "/x", port: "", protocol: "https:", search: "?a&b", searchParams: URLSearchParams {}, username: "" }, zz: Uint8Array [1, 2, 3], zzz: Z {} }\n`); + strictEqual(stdout, `{ a: { value: "a" }, b: { c: "d" }, e: ["f"], g: [{ g: "i" }], l: [ l () { + + }], m: [Getter], n: [Getter], o: [ function () { + + }], p: [ () => {}], q: 5, s: 29879287298374924, t: Set(3) { 1, 2, 3 }, u: Map(3) { 1 => 2, 3 => 4, [ function foo () {}] => {} }, v: Symbol.for("blah"), w: Symbol(), x: undefined, y: null, z: URL { hash: "", host: "site.com", hostname: "site.com", href: "https://site.com/x?a&b", origin: "https://site.com", password: "", pathname: "/x", port: "", protocol: "https:", search: "?a&b", searchParams: URLSearchParams {}, username: "" }, zz: Uint8Array [1, 2, 3], zzz: Z {} }\n`); strictEqual(stderr, ''); } diff --git a/test/builtins/globals.js b/test/builtins/globals.js index c26ff28..9395b8c 100644 --- a/test/builtins/globals.js +++ b/test/builtins/globals.js @@ -13,7 +13,7 @@ export async function test(run) { const { stdout, stderr } = await run(); strictEqual( stdout, - `["undefined", "Function", "Object", "eval", "globalThis", "Array", "Boolean", "JSON", "Date", "Math", "isNaN", "isFinite", "parseInt", "parseFloat", "NaN", "Infinity", "Number", "escape", "unescape", "decodeURI", "encodeURI", "decodeURIComponent", "encodeURIComponent", "String", "RegExp", "Error", "InternalError", "AggregateError", "EvalError", "RangeError", "ReferenceError", "SyntaxError", "TypeError", "URIError", "ArrayBuffer", "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array", "Float64Array", "Uint8ClampedArray", "BigInt64Array", "BigUint64Array", "BigInt", "Proxy", "WeakMap", "Map", "Set", "DataView", "Symbol", "Reflect", "WeakSet", "Promise", "FinalizationRegistry", "WeakRef", "ReadableStream", "ReadableStreamBYOBReader", "ReadableStreamBYOBRequest", "ReadableStreamDefaultReader", "ReadableStreamDefaultController", "ReadableByteStreamController", "WritableStream", "ByteLengthQueuingStrategy", "CountQueuingStrategy", "self", "URL", "URLSearchParams", "atob", "btoa", "console", "DOMException", "Performance", "queueMicrotask", "structuredClone", "setInterval", "setTimeout", "clearInterval", "clearTimeout", "WorkerLocation", "location", "TextEncoder", "TextDecoder", "TransformStream", "CompressionStream", "DecompressionStream", "fetch", "Request", "Response", "Headers", "addEventListener", "SubtleCrypto", "Crypto", "crypto", "CryptoKey"]\n` + `["undefined", "Function", "Object", "eval", "globalThis", "Array", "Boolean", "JSON", "Date", "Math", "isNaN", "isFinite", "parseInt", "parseFloat", "NaN", "Infinity", "Number", "escape", "unescape", "decodeURI", "encodeURI", "decodeURIComponent", "encodeURIComponent", "String", "RegExp", "Error", "InternalError", "AggregateError", "EvalError", "RangeError", "ReferenceError", "SyntaxError", "TypeError", "URIError", "ArrayBuffer", "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array", "Float64Array", "Uint8ClampedArray", "BigInt64Array", "BigUint64Array", "BigInt", "Proxy", "WeakMap", "Map", "Set", "DataView", "Symbol", "Reflect", "WeakSet", "Promise", "FinalizationRegistry", "WeakRef", "ReadableStream", "ReadableStreamBYOBReader", "ReadableStreamBYOBRequest", "ReadableStreamDefaultReader", "ReadableStreamDefaultController", "ReadableByteStreamController", "WritableStream", "ByteLengthQueuingStrategy", "CountQueuingStrategy", "self", "queueMicrotask", "structuredClone", "atob", "btoa", "DOMException", "URL", "URLSearchParams", "console", "Performance", "performance", "setInterval", "setTimeout", "clearInterval", "clearTimeout", "WorkerLocation", "location", "TextEncoder", "TextDecoder", "TransformStream", "CompressionStream", "DecompressionStream", "fetch", "Request", "Response", "Headers", "addEventListener", "SubtleCrypto", "Crypto", "crypto", "CryptoKey"]\n` ); strictEqual(stderr, ''); } diff --git a/test/builtins/timeout.js b/test/builtins/timeout.js index 1f1429a..7bbe31a 100644 --- a/test/builtins/timeout.js +++ b/test/builtins/timeout.js @@ -6,10 +6,12 @@ export const source = ` console.log(Date.now()); setTimeout(() => { console.log(Date.now()); + console.log('done'); done = true; }, 100); } export function ready () { + console.log('ready'); return done; } `; From 0c4ff50d4ad8cdc5c9a50e078f7f3201e7b461a2 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Wed, 29 May 2024 15:49:50 -0700 Subject: [PATCH 06/13] workflow fix --- .github/workflows/main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 30218c6..20f34b4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,8 +30,7 @@ jobs: - name: Install Rust Toolchain run: | - rustup toolchain install stable - rustup target add wasm32-unknown-unknown --toolchain stable + rustup toolchain install 1.77.1 rustup target add wasm32-wasi --toolchain 1.77.1 - uses: actions/setup-node@v2 From 39bb48c95fdfd9da583bbc69247b26b904669ff3 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Wed, 29 May 2024 15:52:51 -0700 Subject: [PATCH 07/13] fix tests --- StarlingMonkey | 2 +- test/builtins/timeout.js | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/StarlingMonkey b/StarlingMonkey index 2e23c54..5bdb946 160000 --- a/StarlingMonkey +++ b/StarlingMonkey @@ -1 +1 @@ -Subproject commit 2e23c54f2a9a51cd846b4007fa9eb31bb04d4e10 +Subproject commit 5bdb946f137e946206fb865cdba92b8fb0654416 diff --git a/test/builtins/timeout.js b/test/builtins/timeout.js index 7bbe31a..1f1429a 100644 --- a/test/builtins/timeout.js +++ b/test/builtins/timeout.js @@ -6,12 +6,10 @@ export const source = ` console.log(Date.now()); setTimeout(() => { console.log(Date.now()); - console.log('done'); done = true; }, 100); } export function ready () { - console.log('ready'); return done; } `; From 566ff29e20283629fba4819ce7c4607d0b03a55f Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Wed, 29 May 2024 16:57:57 -0700 Subject: [PATCH 08/13] try latest merge --- StarlingMonkey | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StarlingMonkey b/StarlingMonkey index 5bdb946..82e9b4d 160000 --- a/StarlingMonkey +++ b/StarlingMonkey @@ -1 +1 @@ -Subproject commit 5bdb946f137e946206fb865cdba92b8fb0654416 +Subproject commit 82e9b4d2c4396a645ca25ab79ac12e0d4e43e2ca From 816b513351362af01123efad0b067cdd012d210f Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Wed, 29 May 2024 17:15:31 -0700 Subject: [PATCH 09/13] latest --- StarlingMonkey | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StarlingMonkey b/StarlingMonkey index 82e9b4d..cb7b007 160000 --- a/StarlingMonkey +++ b/StarlingMonkey @@ -1 +1 @@ -Subproject commit 82e9b4d2c4396a645ca25ab79ac12e0d4e43e2ca +Subproject commit cb7b007997c7261ce2b6f132a99b12dec5ed2268 From dd37c60ad7a362afd296f52f9a3c3e4e50429cce Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Wed, 29 May 2024 17:30:54 -0700 Subject: [PATCH 10/13] fixup --- StarlingMonkey | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StarlingMonkey b/StarlingMonkey index cb7b007..0ee0031 160000 --- a/StarlingMonkey +++ b/StarlingMonkey @@ -1 +1 @@ -Subproject commit cb7b007997c7261ce2b6f132a99b12dec5ed2268 +Subproject commit 0ee003193b30c0d7828c0a2d3dd4871207ad173f From d65e34d1ce08293b97f6e950dca22b624fc643df Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Tue, 4 Jun 2024 11:22:28 -0700 Subject: [PATCH 11/13] latest --- StarlingMonkey | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StarlingMonkey b/StarlingMonkey index 0ee0031..f9cda7a 160000 --- a/StarlingMonkey +++ b/StarlingMonkey @@ -1 +1 @@ -Subproject commit 0ee003193b30c0d7828c0a2d3dd4871207ad173f +Subproject commit f9cda7ab14b3be026bb1135168feb9bc1af8a6dc From 90ec48ef4dcc1419a10451377126341c0ee141e1 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Tue, 4 Jun 2024 12:08:35 -0700 Subject: [PATCH 12/13] add fetch test --- src/componentize.js | 17 +---------------- test/builtins/fetch.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 16 deletions(-) create mode 100644 test/builtins/fetch.js diff --git a/src/componentize.js b/src/componentize.js index 52cba5b..63b1177 100644 --- a/src/componentize.js +++ b/src/componentize.js @@ -60,29 +60,14 @@ export async function componentize(jsSource, witWorld, opts) { const features = []; if (!disableFeatures.includes('stdio')) { features.push('stdio'); - } else if (imports.some(([module]) => module.startsWith('wasi:cli/std') || module.startsWith('wasi:cli/terminal'))) { - throw new Error( - 'Cannot disable "stdio" as it is already an import in the target world.' - ); } if (!disableFeatures.includes('random')) { features.push('random'); - } else if (imports.some(([module]) => module.startsWith('wasi:random/'))) { - throw new Error( - 'Cannot disable "random" as it is already an import in the target world.' - ); } if (!disableFeatures.includes('clocks')) { features.push('clocks'); - } else if (imports.some(([module]) => module.startsWith('wasi:clocks/'))) { - throw new Error( - 'Cannot disable "clocks" as it is already an import in the target world.' - ); } - if ( - enableFeatures.includes('http') || - imports.some(([module]) => module.startsWith('wasi:http/')) - ) { + if (!disableFeatures.includes('http')) { features.push('http'); } diff --git a/test/builtins/fetch.js b/test/builtins/fetch.js new file mode 100644 index 0000000..7e11164 --- /dev/null +++ b/test/builtins/fetch.js @@ -0,0 +1,28 @@ +import { strictEqual, ok } from 'node:assert'; + +export const source = ` + let val, err, done = false; + export function run () { + (async () => { + const res = await fetch('https://www.google.com'); + return res.text(); + })().then(text => { + console.log(text); + done = true; + }, err => { + console.error(err); + done = true; + }); + } + export function ready () { + return done; + } +`; + +export async function test(run) { + const curNow = Date.now(); + const { stdout, stderr } = await run(); + console.log(stdout); + ok(stdout.includes('google')); + strictEqual(stderr, ''); +} From fea492f976b514b5f5bb539e1c0b3ce387435185 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Thu, 27 Jun 2024 18:07:40 -0700 Subject: [PATCH 13/13] fixup --- StarlingMonkey | 2 +- embedding/embedding.cpp | 1 - test/builtins/fetch.js | 28 ---------------------------- test/builtins/timeout.js | 22 ---------------------- 4 files changed, 1 insertion(+), 52 deletions(-) delete mode 100644 test/builtins/fetch.js delete mode 100644 test/builtins/timeout.js diff --git a/StarlingMonkey b/StarlingMonkey index f9cda7a..aa9ff14 160000 --- a/StarlingMonkey +++ b/StarlingMonkey @@ -1 +1 @@ -Subproject commit f9cda7ab14b3be026bb1135168feb9bc1af8a6dc +Subproject commit aa9ff14cd0696877a402435faaf8db486ce0ff89 diff --git a/embedding/embedding.cpp b/embedding/embedding.cpp index 154327c..d4c6688 100644 --- a/embedding/embedding.cpp +++ b/embedding/embedding.cpp @@ -274,7 +274,6 @@ extern "C" } Runtime.free_list.clear(); RootedValue result(Runtime.cx); - Runtime.engine->run_event_loop(); LOG("(post_call) end"); } diff --git a/test/builtins/fetch.js b/test/builtins/fetch.js deleted file mode 100644 index 7e11164..0000000 --- a/test/builtins/fetch.js +++ /dev/null @@ -1,28 +0,0 @@ -import { strictEqual, ok } from 'node:assert'; - -export const source = ` - let val, err, done = false; - export function run () { - (async () => { - const res = await fetch('https://www.google.com'); - return res.text(); - })().then(text => { - console.log(text); - done = true; - }, err => { - console.error(err); - done = true; - }); - } - export function ready () { - return done; - } -`; - -export async function test(run) { - const curNow = Date.now(); - const { stdout, stderr } = await run(); - console.log(stdout); - ok(stdout.includes('google')); - strictEqual(stderr, ''); -} diff --git a/test/builtins/timeout.js b/test/builtins/timeout.js deleted file mode 100644 index 1f1429a..0000000 --- a/test/builtins/timeout.js +++ /dev/null @@ -1,22 +0,0 @@ -import { strictEqual, ok } from 'node:assert'; - -export const source = ` - let done = false; - export function run () { - console.log(Date.now()); - setTimeout(() => { - console.log(Date.now()); - done = true; - }, 100); - } - export function ready () { - return done; - } -`; - -export async function test(run) { - const { stdout, stderr } = await run(); - const [timestart, timeend] = stdout.split('\n'); - strictEqual(stderr, ''); - ok(Number(timeend) - Number(timestart) >= 100); -}