Files
workinf_Blender_Wasm/web/tests/unit/ply-negative.test.mjs
mes123456 380cbed4ff
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
Checkpoint web parity through Chromium input tasks
2026-08-19 10:39:03 -04:00

30 lines
1.6 KiB
JavaScript

import assert from "node:assert/strict";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { pathToFileURL } from "node:url";
import test from "node:test";
import ts from "typescript";
const root = path.resolve(import.meta.dirname, "../../..");
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "ply-negative-unit-"));
const sourcePath = path.join(root, "web/protocol/ply-import.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 modulePath = path.join(temporary, "ply-import.mjs");
fs.writeFileSync(modulePath, transpiled.outputText);
const protocol = await import(pathToFileURL(modulePath));
const fixtureRoot = path.join(root, "tests/files/web/m12_ply_negative_v1");
const bytes = (name) => { const value = fs.readFileSync(path.join(fixtureRoot, name)); return value.buffer.slice(value.byteOffset, value.byteOffset + value.byteLength); };
test("M12-07I blocks big-endian PLY with a stable format code", () => {
assert.throws(() => protocol.importPLY(bytes("big-endian.ply")), /PLY_FORMAT_UNSUPPORTED/);
});
test("M12-07I blocks malformed lists and oversized element counts", () => {
assert.throws(() => protocol.importPLY(bytes("malformed-list-ascii.ply")), /PLY_DATA_TRUNCATED/);
assert.throws(() => protocol.importPLY(bytes("oversized-count-ascii.ply")), /PLY_IMPORT_BUDGET_EXCEEDED: vertex/);
});
test.after(() => fs.rmSync(temporary, { recursive: true, force: true }));