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: 'findConvexHull',
|
||||||
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.
|
||||||
//
|
//
|
||||||
@@ -7,26 +8,16 @@ export default {
|
|||||||
// - You MUST use a dynamic import() to load the 'lodash' library from a CDN for sorting and uniqueness operations.
|
// - You MUST use a dynamic import() to load the 'lodash' library from a CDN for sorting and uniqueness operations.
|
||||||
// - The function should return an array of points representing the convex hull, ordered clockwise.
|
// - The function should return an array of points representing the convex hull, ordered clockwise.
|
||||||
`,
|
`,
|
||||||
harness: `
|
runTest: async (findConvexHull) => {
|
||||||
import assert from 'assert';
|
const assert = {
|
||||||
async function runTest() {
|
deepStrictEqual: (a, e, m) => { if (JSON.stringify(a) !== JSON.stringify(e)) throw new Error(m) },
|
||||||
const points = [
|
};
|
||||||
{x: 0, y: 3}, {x: 1, y: 1}, {x: 2, y: 2}, {x: 4, y: 4},
|
const points = [
|
||||||
{x: 0, y: 0}, {x: 1, y: 2}, {x: 3, y: 1}, {x: 3, y: 3}
|
{x: 0, y: 3}, {x: 1, y: 1}, {x: 2, y: 2}, {x: 4, y: 4},
|
||||||
];
|
{x: 0, y: 0}, {x: 1, y: 2}, {x: 3, y: 1}, {x: 3, y: 3}
|
||||||
const expectedHull = [
|
];
|
||||||
{x: 0, y: 0}, {x: 3, y: 1}, {x: 4, y: 4}, {x: 0, y: 3}
|
const expected = [{x: 0, y: 0}, {x: 3, y: 1}, {x: 4, y: 4}, {x: 0, y: 3}];
|
||||||
];
|
|
||||||
try {
|
|
||||||
const hull = await findConvexHull(points);
|
const hull = await findConvexHull(points);
|
||||||
assert.deepStrictEqual(hull, expectedHull, "Test Failed: Convex hull does not match expected output.");
|
assert.deepStrictEqual(hull, expected, "Test Failed: Convex hull does not match.");
|
||||||
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