From 06d66aa1ad66dd56c08a2508849c40943df7a2fc Mon Sep 17 00:00:00 2001 From: multipleof4 Date: Mon, 13 Oct 2025 05:50:51 -0700 Subject: [PATCH] Feat: Reorganizing tests into subdirectories --- tests/4_determinant/test.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/4_determinant/test.js diff --git a/tests/4_determinant/test.js b/tests/4_determinant/test.js new file mode 100644 index 0000000..dc1db11 --- /dev/null +++ b/tests/4_determinant/test.js @@ -0,0 +1,25 @@ +module.exports = { + prompt: ` +// Write an async JavaScript function 'calculateDeterminant' that calculates the determinant of a square matrix. +// - The function must accept an n x n matrix, represented as an array of arrays. +// - You MUST use a dynamic import() to load the 'mathjs' library from a CDN. +// - You MUST use the library's built-in 'det' function to perform the calculation. +// - The function should return the determinant value. +`, + harness: ` +const assert = require('assert'); +async function runTest() { + const matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; + try { + const det = await calculateDeterminant(matrix); + assert.strictEqual(det, 0, "Test Failed: Determinant of [[1,2,3],[4,5,6],[7,8,9]] should be 0."); + console.log("Test Passed!"); + process.exit(0); + } catch (e) { + console.error("Test Execution Error:", e.message); + process.exit(1); + } +} +runTest(); +` +};