mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
run bun fmt
This commit is contained in:
Submodule src/deps/base64 updated: 3a5add8652...e77bd70bdd
@@ -593,7 +593,7 @@ function ffiRunner(fast) {
|
||||
const bigint = typeof min === "bigint";
|
||||
const inc = bigint
|
||||
? //
|
||||
(max - min) / 32768n
|
||||
(max - min) / 32768n
|
||||
: Math.ceil((max - min) / 32768);
|
||||
it(type, () => {
|
||||
expect(bigint ? BigInt(fn(min)) : fn(min)).toBe(min);
|
||||
@@ -652,7 +652,7 @@ if (ok) {
|
||||
ffiRunner(true);
|
||||
});
|
||||
} else {
|
||||
it.skip("run ffi", () => { });
|
||||
it.skip("run ffi", () => {});
|
||||
}
|
||||
|
||||
it("dlopen throws an error instead of returning it", () => {
|
||||
@@ -680,8 +680,8 @@ const lib_path =
|
||||
platform() === "darwin"
|
||||
? "/usr/lib/libSystem.B.dylib"
|
||||
: existsSync("/lib/x86_64-linux-gnu/libc.so.6")
|
||||
? "/lib/x86_64-linux-gnu/libc.so.6"
|
||||
: null;
|
||||
? "/lib/x86_64-linux-gnu/libc.so.6"
|
||||
: null;
|
||||
const test = lib_path ? it : it.skip;
|
||||
test("can open more than 63 symbols", () => {
|
||||
const lib = dlopen(lib_path, {
|
||||
|
||||
@@ -6,7 +6,7 @@ it("extendable", () => {
|
||||
const classes = [Blob, TextDecoder, TextEncoder, Request, Response, Headers, HTMLRewriter, Bun.Transpiler, Buffer];
|
||||
for (let Class of classes) {
|
||||
if (process.env.BUN_POLYFILLS_TEST_RUNNER && Class === Buffer) continue;
|
||||
var Foo = class extends Class { };
|
||||
var Foo = class extends Class {};
|
||||
var bar = Class === Request ? new Request("https://example.com") : new Foo();
|
||||
expect(bar instanceof Class).toBe(true);
|
||||
expect(!!Class.prototype).toBe(true);
|
||||
@@ -32,7 +32,7 @@ it("writable", () => {
|
||||
];
|
||||
for (let [name, Class] of classes) {
|
||||
if (!Class) continue;
|
||||
if (process.env.BUN_POLYFILLS_TEST_RUNNER && name === 'Response') continue;
|
||||
if (process.env.BUN_POLYFILLS_TEST_RUNNER && name === "Response") continue;
|
||||
globalThis[name] = 123;
|
||||
expect(globalThis[name]).toBe(123);
|
||||
globalThis[name] = Class;
|
||||
@@ -55,8 +55,9 @@ it("name", () => {
|
||||
];
|
||||
for (let [name, Class] of classes) {
|
||||
if (process.env.BUN_POLYFILLS_TEST_RUNNER) {
|
||||
if (Class.name.startsWith('_')) expect(Class.name.slice(1)).toBe(name); // _Request, _Response, _Headers... why Node? Just why.
|
||||
else if (Class.name.endsWith('2')) expect(Class.name.slice(0, -1)).toBe(name); // Response2 monkeypatch by Hono
|
||||
if (Class.name.startsWith("_"))
|
||||
expect(Class.name.slice(1)).toBe(name); // _Request, _Response, _Headers... why Node? Just why.
|
||||
else if (Class.name.endsWith("2")) expect(Class.name.slice(0, -1)).toBe(name); // Response2 monkeypatch by Hono
|
||||
else expect(Class.name).toBe(name);
|
||||
} else expect(Class.name).toBe(name);
|
||||
}
|
||||
|
||||
@@ -31,19 +31,19 @@ describe("large file", () => {
|
||||
it(`write ${filename} ${content.length} (text)`, async () => {
|
||||
try {
|
||||
unlinkSync(filename);
|
||||
} catch (e) { }
|
||||
} catch (e) {}
|
||||
await Bun.write(filename, content);
|
||||
expect(await Bun.file(filename).text()).toBe(content);
|
||||
|
||||
try {
|
||||
unlinkSync(filename);
|
||||
} catch (e) { }
|
||||
} catch (e) {}
|
||||
});
|
||||
|
||||
it(`write ${filename}.bytes ${content.length} (bytes)`, async () => {
|
||||
try {
|
||||
unlinkSync(filename + ".bytes");
|
||||
} catch (e) { }
|
||||
} catch (e) {}
|
||||
var bytes = new TextEncoder().encode(content);
|
||||
const written = await Bun.write(filename + ".bytes", bytes);
|
||||
expect(written).toBe(bytes.byteLength);
|
||||
@@ -51,20 +51,20 @@ describe("large file", () => {
|
||||
|
||||
try {
|
||||
unlinkSync(filename + ".bytes");
|
||||
} catch (e) { }
|
||||
} catch (e) {}
|
||||
});
|
||||
|
||||
it(`write ${filename}.blob ${content.length} (Blob)`, async () => {
|
||||
try {
|
||||
unlinkSync(filename + ".blob");
|
||||
} catch (e) { }
|
||||
} catch (e) {}
|
||||
var bytes = new Blob([content]);
|
||||
await Bun.write(filename + ".blob", bytes);
|
||||
expect(await Bun.file(filename + ".blob").text()).toBe(content);
|
||||
|
||||
try {
|
||||
unlinkSync(filename + ".blob");
|
||||
} catch (e) { }
|
||||
} catch (e) {}
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -110,7 +110,7 @@ it("Bun.write('out.txt', 'string')", async () => {
|
||||
if (erase) {
|
||||
try {
|
||||
fs.unlinkSync(path.join("/tmp", "out.txt"));
|
||||
} catch (e) { }
|
||||
} catch (e) {}
|
||||
}
|
||||
await gcTick();
|
||||
expect(await Bun.write("/tmp/out.txt", "string")).toBe("string".length);
|
||||
@@ -127,11 +127,11 @@ it("Bun.write('out.txt', 'string')", async () => {
|
||||
it("Bun.file -> Bun.file", async () => {
|
||||
try {
|
||||
fs.unlinkSync(path.join("/tmp", "fetch.js.in"));
|
||||
} catch (e) { }
|
||||
} catch (e) {}
|
||||
await gcTick();
|
||||
try {
|
||||
fs.unlinkSync(path.join("/tmp", "fetch.js.out"));
|
||||
} catch (e) { }
|
||||
} catch (e) {}
|
||||
await gcTick();
|
||||
const file = path.join(import.meta.dir, "fetch.js.txt");
|
||||
await gcTick();
|
||||
@@ -245,7 +245,7 @@ it("Bun.file -> Response", async () => {
|
||||
// ensure the file doesn't already exist
|
||||
try {
|
||||
fs.unlinkSync("/tmp/fetch.js.out");
|
||||
} catch { }
|
||||
} catch {}
|
||||
await gcTick();
|
||||
const file = path.join(import.meta.dir, "fetch.js.txt");
|
||||
await gcTick();
|
||||
|
||||
@@ -79,8 +79,8 @@ describe("bun:jsc", () => {
|
||||
it.skipIf(!!process.env.BUN_POLYFILLS_TEST_RUNNER)("callerSourceOrigin", () => {
|
||||
expect(callerSourceOrigin()).toBe(import.meta.url);
|
||||
});
|
||||
it("noFTL", () => { });
|
||||
it("noOSRExitFuzzing", () => { });
|
||||
it("noFTL", () => {});
|
||||
it("noOSRExitFuzzing", () => {});
|
||||
it("optimizeNextInvocation", () => {
|
||||
count();
|
||||
expect(optimizeNextInvocation(count)).toBeUndefined();
|
||||
|
||||
@@ -29,8 +29,8 @@ it("remoteAddress works", async () => {
|
||||
setTimeout(() => server.stop(true), 0);
|
||||
}
|
||||
},
|
||||
close() { },
|
||||
data() { },
|
||||
close() {},
|
||||
data() {},
|
||||
},
|
||||
port: 0,
|
||||
hostname: "127.0.0.1",
|
||||
@@ -49,8 +49,8 @@ it("remoteAddress works", async () => {
|
||||
ws.end();
|
||||
}
|
||||
},
|
||||
data() { },
|
||||
close() { },
|
||||
data() {},
|
||||
close() {},
|
||||
},
|
||||
hostname: server.hostname,
|
||||
port: server.port,
|
||||
@@ -64,9 +64,9 @@ it("should not allow invalid tls option", () => {
|
||||
// @ts-ignore
|
||||
const server = Bun.listen({
|
||||
socket: {
|
||||
open(ws) { },
|
||||
close() { },
|
||||
data() { },
|
||||
open(ws) {},
|
||||
close() {},
|
||||
data() {},
|
||||
},
|
||||
port: 0,
|
||||
hostname: "localhost",
|
||||
@@ -83,9 +83,9 @@ it("should allow using false, null or undefined tls option", () => {
|
||||
// @ts-ignore
|
||||
const server = Bun.listen({
|
||||
socket: {
|
||||
open(ws) { },
|
||||
close() { },
|
||||
data() { },
|
||||
open(ws) {},
|
||||
close() {},
|
||||
data() {},
|
||||
},
|
||||
port: 0,
|
||||
hostname: "localhost",
|
||||
@@ -230,13 +230,13 @@ describe("tcp socket binaryType", () => {
|
||||
data(socket, buffer) {
|
||||
expect(
|
||||
buffer instanceof
|
||||
(type === "arraybuffer"
|
||||
? ArrayBuffer
|
||||
: type === "uint8array"
|
||||
(type === "arraybuffer"
|
||||
? ArrayBuffer
|
||||
: type === "uint8array"
|
||||
? Uint8Array
|
||||
: type === "buffer"
|
||||
? Buffer
|
||||
: Error),
|
||||
? Buffer
|
||||
: Error),
|
||||
).toBe(true);
|
||||
const msg = `${socket.data.isServer ? "server:" : "client:"} Hello World! ${socket.data.counter++}`;
|
||||
socket.data.sendQueue.push(msg);
|
||||
|
||||
@@ -60,38 +60,41 @@ it("Module.createRequire does not use file url as the referrer (err message chec
|
||||
} catch (e) {
|
||||
expect(e.name).not.toBe("UnreachableError");
|
||||
expect(e.message).not.toInclude("file:///");
|
||||
expect(e.message).toInclude('whaaat');
|
||||
expect(e.message).toInclude("whaaat");
|
||||
expect(e.message).toInclude(import.meta.path);
|
||||
}
|
||||
});
|
||||
|
||||
it.skipIf(process.env.BUN_POLYFILLS_TEST_RUNNER)("require with a query string works on dynamically created content", () => {
|
||||
rmSync("/tmp/bun-test-import-meta-dynamic-dir", {
|
||||
recursive: true,
|
||||
force: true,
|
||||
});
|
||||
try {
|
||||
const require = Module.createRequire("/tmp/bun-test-import-meta-dynamic-dir/foo.js");
|
||||
try {
|
||||
require("./bar.js?query=123.js");
|
||||
} catch (e) {
|
||||
expect(e.name).toBe(process.env.BUN_POLYFILLS_TEST_RUNNER ? "Error" : "ResolveMessage");
|
||||
}
|
||||
|
||||
mkdirSync("/tmp/bun-test-import-meta-dynamic-dir", { recursive: true });
|
||||
|
||||
writeFileSync("/tmp/bun-test-import-meta-dynamic-dir/bar.js", "export default 'hello';", "utf8");
|
||||
|
||||
expect(require("./bar.js?query=123.js").default).toBe("hello");
|
||||
} catch (e) {
|
||||
throw e;
|
||||
} finally {
|
||||
it.skipIf(process.env.BUN_POLYFILLS_TEST_RUNNER)(
|
||||
"require with a query string works on dynamically created content",
|
||||
() => {
|
||||
rmSync("/tmp/bun-test-import-meta-dynamic-dir", {
|
||||
recursive: true,
|
||||
force: true,
|
||||
});
|
||||
}
|
||||
});
|
||||
try {
|
||||
const require = Module.createRequire("/tmp/bun-test-import-meta-dynamic-dir/foo.js");
|
||||
try {
|
||||
require("./bar.js?query=123.js");
|
||||
} catch (e) {
|
||||
expect(e.name).toBe(process.env.BUN_POLYFILLS_TEST_RUNNER ? "Error" : "ResolveMessage");
|
||||
}
|
||||
|
||||
mkdirSync("/tmp/bun-test-import-meta-dynamic-dir", { recursive: true });
|
||||
|
||||
writeFileSync("/tmp/bun-test-import-meta-dynamic-dir/bar.js", "export default 'hello';", "utf8");
|
||||
|
||||
expect(require("./bar.js?query=123.js").default).toBe("hello");
|
||||
} catch (e) {
|
||||
throw e;
|
||||
} finally {
|
||||
rmSync("/tmp/bun-test-import-meta-dynamic-dir", {
|
||||
recursive: true,
|
||||
force: true,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
it("import.meta.require (json)", () => {
|
||||
expect(import.meta.require("./require-json.json").hello).toBe(sync.hello);
|
||||
|
||||
@@ -53,7 +53,7 @@ test("spawn can write to stdin multiple chunks", async () => {
|
||||
|
||||
try {
|
||||
unlinkSync(tmperr);
|
||||
} catch (e) { }
|
||||
} catch (e) {}
|
||||
})();
|
||||
}
|
||||
|
||||
|
||||
@@ -132,45 +132,49 @@ for (let [gcTick, label] of [
|
||||
gcTick();
|
||||
});
|
||||
|
||||
it.skipIf(!!process.env.BUN_POLYFILLS_TEST_RUNNER)("check exit code from onExit", async () => {
|
||||
for (let i = 0; i < 1000; i++) {
|
||||
var exitCode1, exitCode2;
|
||||
await new Promise<void>(resolve => {
|
||||
var counter = 0;
|
||||
spawn({
|
||||
cmd: ["ls"],
|
||||
stdin: "ignore",
|
||||
stdout: "ignore",
|
||||
stderr: "ignore",
|
||||
onExit(subprocess, code) {
|
||||
exitCode1 = code;
|
||||
counter++;
|
||||
if (counter === 2) {
|
||||
resolve();
|
||||
}
|
||||
},
|
||||
it.skipIf(!!process.env.BUN_POLYFILLS_TEST_RUNNER)(
|
||||
"check exit code from onExit",
|
||||
async () => {
|
||||
for (let i = 0; i < 1000; i++) {
|
||||
var exitCode1, exitCode2;
|
||||
await new Promise<void>(resolve => {
|
||||
var counter = 0;
|
||||
spawn({
|
||||
cmd: ["ls"],
|
||||
stdin: "ignore",
|
||||
stdout: "ignore",
|
||||
stderr: "ignore",
|
||||
onExit(subprocess, code) {
|
||||
exitCode1 = code;
|
||||
counter++;
|
||||
if (counter === 2) {
|
||||
resolve();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
spawn({
|
||||
cmd: ["false"],
|
||||
stdin: "ignore",
|
||||
stdout: "ignore",
|
||||
stderr: "ignore",
|
||||
onExit(subprocess, code) {
|
||||
exitCode2 = code;
|
||||
counter++;
|
||||
|
||||
if (counter === 2) {
|
||||
resolve();
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
spawn({
|
||||
cmd: ["false"],
|
||||
stdin: "ignore",
|
||||
stdout: "ignore",
|
||||
stderr: "ignore",
|
||||
onExit(subprocess, code) {
|
||||
exitCode2 = code;
|
||||
counter++;
|
||||
|
||||
if (counter === 2) {
|
||||
resolve();
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
expect<number>(exitCode1).toBe(0);
|
||||
expect<number>(exitCode2).toBe(1);
|
||||
}
|
||||
}, 60_000_0);
|
||||
expect<number>(exitCode1).toBe(0);
|
||||
expect<number>(exitCode2).toBe(1);
|
||||
}
|
||||
},
|
||||
60_000_0,
|
||||
);
|
||||
|
||||
// FIXME: fix the assertion failure
|
||||
it.skip("Uint8Array works as stdout", () => {
|
||||
@@ -497,22 +501,26 @@ for (let [gcTick, label] of [
|
||||
}
|
||||
|
||||
if (!process.env.BUN_FEATURE_FLAG_FORCE_WAITER_THREAD) {
|
||||
it.skipIf(!!process.env.BUN_POLYFILLS_TEST_RUNNER)("with BUN_FEATURE_FLAG_FORCE_WAITER_THREAD", async () => {
|
||||
const result = spawnSync({
|
||||
cmd: [bunExe(), "test", import.meta.path],
|
||||
env: {
|
||||
...bunEnv,
|
||||
// Both flags are necessary to force this condition
|
||||
"BUN_FEATURE_FLAG_FORCE_WAITER_THREAD": "1",
|
||||
"BUN_GARBAGE_COLLECTOR_LEVEL": "1",
|
||||
},
|
||||
});
|
||||
if (result.exitCode !== 0) {
|
||||
console.error(result.stderr.toString());
|
||||
console.log(result.stdout.toString());
|
||||
}
|
||||
expect(result.exitCode).toBe(0);
|
||||
}, 60_000);
|
||||
it.skipIf(!!process.env.BUN_POLYFILLS_TEST_RUNNER)(
|
||||
"with BUN_FEATURE_FLAG_FORCE_WAITER_THREAD",
|
||||
async () => {
|
||||
const result = spawnSync({
|
||||
cmd: [bunExe(), "test", import.meta.path],
|
||||
env: {
|
||||
...bunEnv,
|
||||
// Both flags are necessary to force this condition
|
||||
"BUN_FEATURE_FLAG_FORCE_WAITER_THREAD": "1",
|
||||
"BUN_GARBAGE_COLLECTOR_LEVEL": "1",
|
||||
},
|
||||
});
|
||||
if (result.exitCode !== 0) {
|
||||
console.error(result.stderr.toString());
|
||||
console.log(result.stdout.toString());
|
||||
}
|
||||
expect(result.exitCode).toBe(0);
|
||||
},
|
||||
60_000,
|
||||
);
|
||||
}
|
||||
|
||||
describe("spawn unref and kill should not hang", () => {
|
||||
|
||||
@@ -15,17 +15,19 @@ it("Database.open", () => {
|
||||
expect(error.message).toBe(
|
||||
process.env.BUN_POLYFILLS_TEST_RUNNER
|
||||
? "Cannot open database because the directory does not exist"
|
||||
: "unable to open database file"
|
||||
: "unable to open database file",
|
||||
);
|
||||
}
|
||||
|
||||
// in a file which doesn't exist
|
||||
if (!process.env.BUN_POLYFILLS_TEST_RUNNER) try { // not sure why this is supposed to error, better-sqlite3 has no issue with it?
|
||||
Database.open(`/tmp/database-${Math.random()}.sqlite`, constants.SQLITE_OPEN_READWRITE);
|
||||
throw new Error("Expected an error to be thrown");
|
||||
} catch (error) {
|
||||
expect(error.message).toBe("unable to open database file");
|
||||
}
|
||||
if (!process.env.BUN_POLYFILLS_TEST_RUNNER)
|
||||
try {
|
||||
// not sure why this is supposed to error, better-sqlite3 has no issue with it?
|
||||
Database.open(`/tmp/database-${Math.random()}.sqlite`, constants.SQLITE_OPEN_READWRITE);
|
||||
throw new Error("Expected an error to be thrown");
|
||||
} catch (error) {
|
||||
expect(error.message).toBe("unable to open database file");
|
||||
}
|
||||
|
||||
// in a file which doesn't exist
|
||||
try {
|
||||
@@ -36,12 +38,14 @@ it("Database.open", () => {
|
||||
}
|
||||
|
||||
// in a file which doesn't exist
|
||||
if (!process.env.BUN_POLYFILLS_TEST_RUNNER) try { // not sure why this is supposed to error, better-sqlite3 has no issue with it? (x2)
|
||||
Database.open(`/tmp/database-${Math.random()}.sqlite`, { readwrite: true });
|
||||
throw new Error("Expected an error to be thrown");
|
||||
} catch (error) {
|
||||
expect(error.message).toBe("unable to open database file");
|
||||
}
|
||||
if (!process.env.BUN_POLYFILLS_TEST_RUNNER)
|
||||
try {
|
||||
// not sure why this is supposed to error, better-sqlite3 has no issue with it? (x2)
|
||||
Database.open(`/tmp/database-${Math.random()}.sqlite`, { readwrite: true });
|
||||
throw new Error("Expected an error to be thrown");
|
||||
} catch (error) {
|
||||
expect(error.message).toBe("unable to open database file");
|
||||
}
|
||||
|
||||
// create works
|
||||
{
|
||||
@@ -140,8 +144,8 @@ it("int52", () => {
|
||||
it("typechecks", () => {
|
||||
const db = Database.open(":memory:");
|
||||
db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT)");
|
||||
db.exec('INSERT INTO test (name) VALUES (\'Hello\')');
|
||||
db.exec('INSERT INTO test (name) VALUES (\'World\')');
|
||||
db.exec("INSERT INTO test (name) VALUES ('Hello')");
|
||||
db.exec("INSERT INTO test (name) VALUES ('World')");
|
||||
|
||||
const q = db.prepare("SELECT * FROM test WHERE (name = ?)");
|
||||
|
||||
@@ -173,8 +177,8 @@ it("typechecks", () => {
|
||||
|
||||
expectfail(Symbol("oh hai"));
|
||||
expectfail(new Date());
|
||||
expectfail(class Foo { });
|
||||
expectfail(() => class Foo { });
|
||||
expectfail(class Foo {});
|
||||
expectfail(() => class Foo {});
|
||||
expectfail(new RangeError("what"));
|
||||
expectfail(new Map());
|
||||
expectfail(new Map([["foo", "bar"]]));
|
||||
@@ -221,8 +225,8 @@ it("db.query supports TypedArray", () => {
|
||||
it("supports serialize/deserialize", () => {
|
||||
const db = Database.open(":memory:");
|
||||
db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT)");
|
||||
db.exec('INSERT INTO test (name) VALUES (\'Hello\')');
|
||||
db.exec('INSERT INTO test (name) VALUES (\'World\')');
|
||||
db.exec("INSERT INTO test (name) VALUES ('Hello')");
|
||||
db.exec("INSERT INTO test (name) VALUES ('World')");
|
||||
|
||||
const input = db.serialize();
|
||||
const db2 = new Database(input);
|
||||
@@ -286,8 +290,8 @@ it("db.query()", () => {
|
||||
var q = db.query("SELECT * FROM test WHERE name = ?");
|
||||
expect(q.get("Hello") === null).toBe(true);
|
||||
|
||||
db.exec('INSERT INTO test (name) VALUES (\'Hello\')');
|
||||
db.exec('INSERT INTO test (name) VALUES (\'World\')');
|
||||
db.exec("INSERT INTO test (name) VALUES ('Hello')");
|
||||
db.exec("INSERT INTO test (name) VALUES ('World')");
|
||||
|
||||
var rows = db.query("SELECT * FROM test WHERE name = ?").all(["Hello"]);
|
||||
|
||||
@@ -342,9 +346,7 @@ it("db.query()", () => {
|
||||
db.query("SELECT * FROM test where (name = ? OR name = ?)").all("Hello");
|
||||
} catch (e) {
|
||||
expect(e.message).toBe(
|
||||
process.env.BUN_POLYFILLS_TEST_RUNNER
|
||||
? "Too few parameter values were provided"
|
||||
: "Expected 2 values, got 1"
|
||||
process.env.BUN_POLYFILLS_TEST_RUNNER ? "Too few parameter values were provided" : "Expected 2 values, got 1",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -410,9 +412,7 @@ it("db.transaction()", () => {
|
||||
throw new Error("Should have thrown");
|
||||
} catch (exception) {
|
||||
expect(exception.message).toBe(
|
||||
process.env.BUN_POLYFILLS_TEST_RUNNER
|
||||
? "UNIQUE constraint failed: cats.name"
|
||||
: "constraint failed"
|
||||
process.env.BUN_POLYFILLS_TEST_RUNNER ? "UNIQUE constraint failed: cats.name" : "constraint failed",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -563,8 +563,8 @@ describe("Database.run", () => {
|
||||
var q = db.query("SELECT * FROM test WHERE name = ?");
|
||||
expect(q.get("Hello") === null).toBe(true);
|
||||
|
||||
db.exec('INSERT INTO test (name) VALUES (\'Hello\')');
|
||||
db.exec('INSERT INTO test (name) VALUES (\'World\')');
|
||||
db.exec("INSERT INTO test (name) VALUES ('Hello')");
|
||||
db.exec("INSERT INTO test (name) VALUES ('World')");
|
||||
|
||||
try {
|
||||
db.run(" ");
|
||||
|
||||
@@ -4,7 +4,8 @@ import { bunEnv, bunExe } from "harness";
|
||||
test("Bun.isMainThread", () => {
|
||||
expect(Bun.isMainThread).toBeTrue();
|
||||
|
||||
if (!process.env.BUN_POLYFILLS_TEST_RUNNER) { // can be removed once node has web Worker support
|
||||
if (!process.env.BUN_POLYFILLS_TEST_RUNNER) {
|
||||
// can be removed once node has web Worker support
|
||||
const { stdout, exitCode } = Bun.spawnSync({
|
||||
cmd: [bunExe(), ...process.execArgv, import.meta.resolveSync("./main-worker-file.js")],
|
||||
stderr: "inherit",
|
||||
|
||||
@@ -45,7 +45,7 @@ describe("FileSink", () => {
|
||||
const path = `/tmp/bun-test-${Bun.hash(label).toString(10)}.txt`;
|
||||
try {
|
||||
require("fs").unlinkSync(path);
|
||||
} catch (e) { }
|
||||
} catch (e) {}
|
||||
return path;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ describe("FileSink", () => {
|
||||
const path = `/tmp/bun-test-${Bun.hash(label).toString(10)}.txt`;
|
||||
try {
|
||||
require("fs").unlinkSync(path);
|
||||
} catch (e) { }
|
||||
} catch (e) {}
|
||||
mkfifo(path, 0o666);
|
||||
activeFIFO = (async function (stream: ReadableStream<Uint8Array>) {
|
||||
var chunks: Uint8Array[] = [];
|
||||
|
||||
@@ -16,7 +16,7 @@ test.skipIf(!!process.env.BUN_POLYFILLS_TEST_RUNNER)("peek", () => {
|
||||
expect(value).toBe(42);
|
||||
|
||||
// if we peek a pending promise, it returns the promise again
|
||||
const pending = new Promise(() => { });
|
||||
const pending = new Promise(() => {});
|
||||
expect(peek(pending)).toBe(pending);
|
||||
|
||||
// If we peek a rejected promise, it:
|
||||
@@ -26,17 +26,17 @@ test.skipIf(!!process.env.BUN_POLYFILLS_TEST_RUNNER)("peek", () => {
|
||||
const peeked = peek(rejected);
|
||||
expect(peeked instanceof Error).toBe(true);
|
||||
expect((peeked as Error).message).toBe("Succesfully tested promise rejection");
|
||||
rejected.catch(() => { });
|
||||
rejected.catch(() => {});
|
||||
});
|
||||
|
||||
test("peek.status", () => {
|
||||
const promise = Promise.resolve(true);
|
||||
expect(peek.status(promise)).toBe("fulfilled");
|
||||
|
||||
const pending = new Promise(() => { });
|
||||
const pending = new Promise(() => {});
|
||||
expect(peek.status(pending)).toBe("pending");
|
||||
|
||||
const rejected = Promise.reject(new Error("oh nooo"));
|
||||
expect(peek.status(rejected)).toBe("rejected");
|
||||
rejected.catch(() => { });
|
||||
rejected.catch(() => {});
|
||||
});
|
||||
|
||||
@@ -49,7 +49,7 @@ test("which", () => {
|
||||
try {
|
||||
mkdirSync("myscript.sh");
|
||||
chmodSync("myscript.sh", "755");
|
||||
} catch (e) { }
|
||||
} catch (e) {}
|
||||
|
||||
// directories should not be returned
|
||||
expect(which("myscript.sh")).toBe(null);
|
||||
@@ -78,7 +78,7 @@ test("which", () => {
|
||||
function writeFixture(path: string) {
|
||||
try {
|
||||
unlinkSync(path);
|
||||
} catch (e) { }
|
||||
} catch (e) {}
|
||||
|
||||
var script_name = path;
|
||||
var script_content = "echo Hello world!";
|
||||
|
||||
Reference in New Issue
Block a user