mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-14 08:37:56 +00:00
Feat: Reorganizing tests into subdirectories
This commit is contained in:
30
tests/2_convex_hull/test.js
Normal file
30
tests/2_convex_hull/test.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
module.exports = {
|
||||||
|
prompt: `
|
||||||
|
// Write an async JavaScript function 'findConvexHull' that finds the convex hull of a set of 2D points using the Monotone Chain algorithm.
|
||||||
|
// - The function must accept an array of points, e.g., [{x: 0, y: 3}, {x: 1, y: 1}, ...].
|
||||||
|
// - 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.
|
||||||
|
`,
|
||||||
|
harness: `
|
||||||
|
const assert = require('assert');
|
||||||
|
async function runTest() {
|
||||||
|
const points = [
|
||||||
|
{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}
|
||||||
|
];
|
||||||
|
try {
|
||||||
|
const hull = await findConvexHull(points);
|
||||||
|
assert.deepStrictEqual(hull, expectedHull, "Test Failed: Convex hull does not match expected output.");
|
||||||
|
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