From 4b407b5f3d9c452e07d9d0b0755f51a1186512dc Mon Sep 17 00:00:00 2001 From: multipleof4 Date: Thu, 13 Nov 2025 16:45:23 -0800 Subject: [PATCH] Refactor: Export test case inputs for debug page --- tests/3_lis/test.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/3_lis/test.js b/tests/3_lis/test.js index a2cbc47..dc0df91 100644 --- a/tests/3_lis/test.js +++ b/tests/3_lis/test.js @@ -5,13 +5,16 @@ export default { // - You MUST implement the efficient O(n log n) algorithm. // - 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.`, + getTestCases: () => { + const nums = [10, 9, 2, 5, 3, 7, 101, 18, 4, 6]; + return [nums]; + }, 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 [nums] = globalThis.getTestCases ? globalThis.getTestCases() : this.getTestCases(); const length = await findLISLength(nums); assert.strictEqual(length, 4, "Test Failed: LIS length should be 4."); } }; -