- 헬퍼 동작 그대로(풀이 함수 본문은 옮겨 담음) · 제품 코드 안 고침 - 확인: 이 묶음 헬퍼를 쓰는 시험 218 개 전 218 통과 → 후 218 통과 (시험별 junit 대조 · 어긋남 0) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
36 lines
1.5 KiB
JavaScript
36 lines
1.5 KiB
JavaScript
/* PLAN 322-1 구조물 표 거울 시험 헬퍼 — 진짜 `common_util_structure_catalog.ts` 를 그 자리에서 트랜스파일해
|
|
* 견본 정의마다 `resolveCatalog` 한 벌 · 실제 정의로 `cardTitle` · `listPick` 을 표준출력 JSON 으로.
|
|
* 입력 = argv[2] JSON `{cases: {이름: 정의|null}, definition, titles: [[typeId, options, defaults]]}`.
|
|
* 짝 = `test_322_1_catalog_mirror.py`.
|
|
*/
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const ROOT = path.join(__dirname, "..", "..");
|
|
const { makeLoader } = require("./helper_ts_stub_loader.cjs");
|
|
|
|
const { loadTs } = makeLoader({
|
|
root: ROOT,
|
|
interop: true,
|
|
cache: false,
|
|
requireFor: (full) => (spec) => loadTs(path.join(path.dirname(full), spec)),
|
|
});
|
|
|
|
const input = JSON.parse(fs.readFileSync(process.argv[2], "utf8"));
|
|
const catalog = loadTs(path.join(ROOT, "common_util", "common_util_structure_catalog.ts"));
|
|
const rows = (map) => Object.fromEntries([...map].map(([id, row]) => [id, row]));
|
|
const out = { cases: {} };
|
|
for (const [name, definition] of Object.entries(input.cases))
|
|
out.cases[name] = rows(catalog.resolveCatalog(definition));
|
|
catalog.useCatalogDefinition(input.definition);
|
|
out.titles = input.titles.map(([id, options, defaults]) =>
|
|
catalog.cardTitle(id, options, defaults),
|
|
);
|
|
out.pick = Object.fromEntries(
|
|
input.definition.types.map((t) => [
|
|
t.type_id,
|
|
[catalog.listPick("b05")(t), catalog.listPick("b06")(t)],
|
|
]),
|
|
);
|
|
out.kinds = [...catalog.pipeTitleKinds()].sort();
|
|
process.stdout.write(JSON.stringify(out));
|