Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MgChuAcyBqUkhHMTXomQC7
49 lines
2.4 KiB
TypeScript
49 lines
2.4 KiB
TypeScript
/* 단위 Φ(81-5) 순수 길 시험 진입 — vite --ssr 로 번들해 Node 로 돌림(메인 판 attachUnitToFormat ·
|
|
* UNIT_PREFIX · UNIT_GROUPS 에 맞춤 — 81-3·81-4·81-5 겹침 정리).
|
|
* 결과 = JSON {pass, fail, failures} 한 줄(`test_spreadsheet_toolbar_unit.py` 가 읽음) */
|
|
import {
|
|
attachUnitToFormat,
|
|
prefixUnit,
|
|
UNIT_GROUPS,
|
|
UNIT_PREFIX,
|
|
} from "../../../A00_Common/spreadsheet/spreadsheet_toolbar";
|
|
|
|
let pass = 0;
|
|
const failures: string[] = [];
|
|
const eq = (name: string, got: unknown, want: unknown): void => {
|
|
if (JSON.stringify(got) === JSON.stringify(want)) pass += 1;
|
|
else failures.push(`${name}: ${JSON.stringify(got)} ≠ ${JSON.stringify(want)}`);
|
|
};
|
|
|
|
const PHI = "Φ";
|
|
|
|
// Φ 는 길이 묶음(UnitGroup_area) 끝 — 다른 묶음엔 안 들어감 · 앞 단위 목록에 있음
|
|
const lengthGroup = UNIT_GROUPS.find(([label]) => label === "UnitGroup_area")!;
|
|
eq("Φ = 길이 묶음 끝", lengthGroup[1][lengthGroup[1].length - 1], PHI);
|
|
eq(
|
|
"Φ 는 다른 묶음에 없음",
|
|
UNIT_GROUPS.filter(([label]) => label !== "UnitGroup_area").some((g) => g[1].includes(PHI)),
|
|
false,
|
|
);
|
|
eq("Φ 는 앞 단위 목록에 있음", UNIT_PREFIX.includes(PHI), true);
|
|
|
|
// 보통 단위(뒤에 붙음) — 지금처럼
|
|
eq("보통 단위 서식 — 뒤", attachUnitToFormat("0", "㎡"), '0"㎡"');
|
|
eq("보통 단위 서식 — 옛 단위 바꿈", attachUnitToFormat('0"㎡"', "㎝"), '0"㎝"');
|
|
|
|
// Φ(지름) — 숫자 앞(메인 판 attachUnitToFormat 이 앞/뒤를 한 함수에서 갈라 처리)
|
|
eq("Φ 서식 — 앞", attachUnitToFormat("0", PHI), '"Φ"0');
|
|
eq("Φ 서식 — 빈 코드도 0 기준", attachUnitToFormat("", PHI), '"Φ"0');
|
|
eq("Φ 서식 — 옛 Φ 바꿈(겹쳐 안 붙음)", attachUnitToFormat('"Φ"0', PHI), '"Φ"0');
|
|
eq("Φ 서식 — 뒤 단위와 공존", attachUnitToFormat('0"㎡"', PHI), '"Φ"0"㎡"');
|
|
|
|
// 앞 단위 글 — 낫표(강제 글)는 맨 앞에 두고 그 뒤에 붙임 · 이미 붙었으면 그대로(81-5 흠)
|
|
eq("Φ 글 — 숫자 앞", prefixUnit("300", PHI), "Φ300");
|
|
eq("Φ 글 — 낫표 뒤", prefixUnit("'300", PHI), "'Φ300");
|
|
eq("Φ 글 — 두 번 안 붙음", prefixUnit("Φ300", PHI), "Φ300");
|
|
eq("Φ 글 — 낫표 뒤 두 번 안 붙음", prefixUnit("'Φ300", PHI), "'Φ300");
|
|
eq("Φ 글 — 빈 칸", prefixUnit("", PHI), "Φ");
|
|
eq("Φ 글 — 식은 그대로", prefixUnit("=A1", PHI), "=A1");
|
|
|
|
console.log(JSON.stringify({ pass, fail: failures.length, failures }));
|