Files
bun.sh/test/v8/v8-module/main.js

19 lines
543 B
JavaScript

// usage: bun/node main.js <name of test function to run> [JSON array of arguments] [JSON `this` value] [debug]
const buildMode = process.argv[5];
const tests = require("./module")(buildMode === "debug");
const testName = process.argv[2];
const args = JSON.parse(process.argv[3] ?? "[]");
const thisValue = JSON.parse(process.argv[4] ?? "null");
const fn = tests[testName];
if (typeof fn !== "function") {
throw new Error("Unknown test:", testName);
}
const result = fn.apply(thisValue, args);
if (result) {
throw new Error(result);
}