Files
VibemakerSandbox/app/test/custom-policy-contract.test.js
chenlin fc5ee4f2c6 feat: release v0.2 multi-robot simulator
Add declarative robot packages, shared simulation lifecycle and Microban ONNX/PD walking with independent head control.

Unify comic UI and chase camera; default robot packages to a 4.5m arena with real collision walls. Include regression tests, asset provenance/licenses and verification evidence.
2026-10-28 14:00:26 +08:00

45 lines
1.3 KiB
JavaScript

import test from "node:test";
import assert from "node:assert/strict";
import {
manifestIncompatibility,
normalizeMoveScript,
scriptCommandAt,
loadCustomPolicy,
} from "../src/game/custom-policy.js";
test("legacy community move validation takes dimensions from the active Package", () => {
const dimensions = { obsSize: 63, actionSize: 18 };
assert.equal(
manifestIncompatibility({ obs_len: 63, action_len: 18 }, dimensions),
null,
);
assert.match(
manifestIncompatibility({ obs_len: 61 }, dimensions),
/provides 63/,
);
assert.match(
manifestIncompatibility({ action_len: 14 }, dimensions),
/drives 18/,
);
});
test("command scripts use supplied vector length, not the old global 13", () => {
const script = normalizeMoveScript(
{
keyframes: [
{ t: 0, cmd: [0, 0, 0] },
{ t: 1, cmd: [2, 4, 6] },
],
},
3,
),
out = new Float32Array(3);
scriptCommandAt(script, 0.5, out);
assert.deepEqual(Array.from(out), [1, 2, 3]);
assert.throws(
() => normalizeMoveScript({ keyframes: [{ t: 0 }] }, undefined),
/size required/,
);
});
test("loading without a Robot Package contract fails before network access", async () => {
await assert.rejects(loadCustomPolicy("ignored"), /Package dimensions/);
});