mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-14 00:27:55 +00:00
Refactor: Make test harness browser-compatible
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
export default {
|
export default {
|
||||||
|
functionName: 'calculateDeterminant',
|
||||||
prompt: `
|
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.
|
// 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 the library's built-in 'det' function to perform the calculation.
|
// - You MUST use the library's built-in 'det' function to perform the calculation.
|
||||||
// - The function should return the determinant value.
|
// - The function should return the determinant value.
|
||||||
`,
|
`,
|
||||||
harness: `
|
runTest: async (calculateDeterminant) => {
|
||||||
import assert from 'assert';
|
const assert = {
|
||||||
async function runTest() {
|
strictEqual: (a, e, m) => { if (a !== e) throw new Error(m || `FAIL: ${a} !== ${e}`) },
|
||||||
|
};
|
||||||
const matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
|
const matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
|
||||||
try {
|
|
||||||
const det = await calculateDeterminant(matrix);
|
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.");
|
assert.strictEqual(det, 0, "Test Failed: Determinant should be 0.");
|
||||||
console.log("Test Passed!");
|
|
||||||
process.exit(0);
|
|
||||||
} catch (e) {
|
|
||||||
console.error("Test Execution Error:", e.message);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
runTest();
|
|
||||||
`
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user