import assert from "node:assert/strict"; import path from "node:path"; import test from "node:test"; import { DOCX_REAL_WORLD_CORPUS, sortDocxRealWorldCorpusBySize, summarizeDocxReleaseGateMatrix, validateDocxRealWorldCorpus } from "./docx-real-world-corpus.mjs"; const repositoryDirectory = path.resolve(import.meta.dirname, ".."); test("冻结三份真实 Markdown 语料及必需特征", () => { const validation = validateDocxRealWorldCorpus(repositoryDirectory); assert.deepEqual(validation.failures, []); assert.equal(validation.corpus.length, 3); assert.equal(new Set(DOCX_REAL_WORLD_CORPUS.map((entry) => entry.id)).size, 3); assert.ok( DOCX_REAL_WORLD_CORPUS.some((entry) => entry.requiredFeatures.includes("json-code-indentation") ) ); assert.ok( DOCX_REAL_WORLD_CORPUS.some((entry) => entry.requiredFeatures.includes("table-math-alignment") ) ); }); test("真实 Markdown 按文件字节数稳定升序执行", () => { const corpus = sortDocxRealWorldCorpusBySize(repositoryDirectory); assert.deepEqual( corpus.map((entry) => entry.byteLength), corpus.map((entry) => entry.byteLength).toSorted((a, b) => a - b) ); assert.ok(corpus.every((entry) => entry.byteLength > 0)); }); test("发布门禁矩阵聚合为 140+420=560", () => { assert.deepEqual( summarizeDocxReleaseGateMatrix({ baselineCaseCount: 140, corpusCaseCounts: Object.fromEntries( DOCX_REAL_WORLD_CORPUS.map((entry) => [entry.id, 140]) ) }), { baselineCaseCount: 140, corpusDocumentCount: 3, corpusCaseCounts: { "changqing-tender-requirements": 140, "health-data-schema": 140, "m4n-table-design": 140 }, corpusCaseCount: 420, totalCaseCount: 560 } ); });