Advance M8-M11 parity workflows
This commit is contained in:
47
web/tests/unit/nanovdb-progressive-redraw.test.mjs
Normal file
47
web/tests/unit/nanovdb-progressive-redraw.test.mjs
Normal file
@@ -0,0 +1,47 @@
|
||||
import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
import ts from "typescript";
|
||||
|
||||
const repoRoot = path.resolve(import.meta.dirname, "../../..");
|
||||
const sourcePath = path.join(repoRoot, "web/protocol/nanovdb-progressive-redraw.ts");
|
||||
const transpiled = ts.transpileModule(fs.readFileSync(sourcePath, "utf8"), {
|
||||
compilerOptions: { module: ts.ModuleKind.ES2022, target: ts.ScriptTarget.ES2022 },
|
||||
fileName: sourcePath,
|
||||
reportDiagnostics: true,
|
||||
});
|
||||
assert.deepEqual(transpiled.diagnostics, []);
|
||||
const moduleUrl = "data:text/javascript;base64," + Buffer.from(transpiled.outputText).toString("base64");
|
||||
const redraw = await import(moduleUrl);
|
||||
|
||||
test("M8-10 validates a bounded progressive redraw budget", () => {
|
||||
assert.equal(redraw.NANOVDB_PROGRESSIVE_REDRAW_MAX_FRAMES, 32);
|
||||
assert.equal(redraw.validateNanoVDBProgressiveRedrawLimit(1), 1);
|
||||
assert.equal(redraw.validateNanoVDBProgressiveRedrawLimit(1024), 1024);
|
||||
for (const value of [0, 1.5, 1025, Number.POSITIVE_INFINITY]) {
|
||||
assert.throws(() => redraw.validateNanoVDBProgressiveRedrawLimit(value), /NANOVDB_INVALID_ARGUMENT/);
|
||||
}
|
||||
});
|
||||
|
||||
test("M8-10 caps repeated successful uploads with a stable error code", () => {
|
||||
assert.deepEqual(redraw.consumeNanoVDBProgressiveRedrawBudget(0, 2), {
|
||||
allowed: true,
|
||||
redrawCount: 1,
|
||||
capped: false,
|
||||
errorCode: null,
|
||||
});
|
||||
assert.deepEqual(redraw.consumeNanoVDBProgressiveRedrawBudget(1, 2), {
|
||||
allowed: true,
|
||||
redrawCount: 2,
|
||||
capped: true,
|
||||
errorCode: "NANOVDB_PROGRESSIVE_REDRAW_LIMIT",
|
||||
});
|
||||
assert.deepEqual(redraw.consumeNanoVDBProgressiveRedrawBudget(2, 2), {
|
||||
allowed: false,
|
||||
redrawCount: 2,
|
||||
capped: true,
|
||||
errorCode: "NANOVDB_PROGRESSIVE_REDRAW_LIMIT",
|
||||
});
|
||||
assert.throws(() => redraw.consumeNanoVDBProgressiveRedrawBudget(-1, 2), /NANOVDB_INVALID_ARGUMENT/);
|
||||
});
|
||||
Reference in New Issue
Block a user