From 25d46a0d8b9b97fd5101bb0a38f2136861401725 Mon Sep 17 00:00:00 2001 From: multipleof4 Date: Mon, 13 Oct 2025 10:24:42 -0700 Subject: [PATCH] Refactor: Make test harness browser-compatible --- tests/3_lis/test.js | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/tests/3_lis/test.js b/tests/3_lis/test.js index ce83e1b..c020e56 100644 --- a/tests/3_lis/test.js +++ b/tests/3_lis/test.js @@ -1,4 +1,5 @@ export default { + functionName: 'findLISLength', prompt: ` // Your goal is to write a production-ready and maintainable JavaScript function. Apply code-golfing practices without sacrificing readability by putting everything on one line. Do not include any comments in your code. // @@ -8,20 +9,12 @@ export default { // - You MUST use a dynamic import() to load the 'd3-array' library from a CDN and use its 'bisectLeft' function to achieve O(n log n) complexity. // - The function should return a single number: the length of the LIS. `, - harness: ` -import assert from 'assert'; -async function runTest() { - const nums = [10, 9, 2, 5, 3, 7, 101, 18, 4, 6]; - try { + runTest: async (findLISLength) => { + const assert = { + strictEqual: (a, e, m) => { if (a !== e) throw new Error(m || `FAIL: ${a} !== ${e}`) }, + }; + const nums = [10, 9, 2, 5, 3, 7, 101, 18, 4, 6]; const length = await findLISLength(nums); - assert.strictEqual(length, 5, "Test Failed: LIS of [10,9,2,5,3,7,101,18,4,6] should be 5 (e.g., 2,3,4,6,18)."); - console.log("Test Passed!"); - process.exit(0); - } catch (e) { - console.error("Test Execution Error:", e.message); - process.exit(1); + assert.strictEqual(length, 5, "Test Failed: LIS length should be 5."); } -} -runTest(); -` };