diff --git a/resources/master_data/scripts/master_text.py b/resources/master_data/scripts/master_text.py index 8acea2af..49b69247 100644 --- a/resources/master_data/scripts/master_text.py +++ b/resources/master_data/scripts/master_text.py @@ -260,7 +260,12 @@ def _formula_pieces(text, env: dict, master, name_of: dict, alias_by_name: dict) # ── 줄 세우기 ───────────────────────────────────────────────────────── def _env_of(master, row: dict, given: dict, depth: int = 0) -> dict: - """입력 + 중간 — `run` 과 같은 차례로 다시 셈(덧줄 전 상태).""" + """입력 + 중간 — `run` 과 같은 차례로 다시 셈(덧줄 전 상태). + 아직 안 고른 입력이 있으면(값 넣기 전) 받은 것만 담아 돌려줌 — 이름 식은 값 없이도 지어짐 + (고른 값이 틀린 경우(고르기·범위 밖)는 지금처럼 그대로 막힘 — `mf._inputs` 가 걸러냄).""" + specs = row.get("입력", []) + if any(spec["이름"] not in given for spec in specs): + return {spec["이름"]: given[spec["이름"]] for spec in specs if spec["이름"] in given} env = mf._inputs(row, given) for step in row.get("중간", []): env[step["이름"]] = mf.evaluate(mf.parse(step["식"]), env, master, depth) diff --git a/resources/tester/test_m01_text.py b/resources/tester/test_m01_text.py index b83e6fb3..36b2d5cd 100644 --- a/resources/tester/test_m01_text.py +++ b/resources/tester/test_m01_text.py @@ -136,9 +136,20 @@ def test_이름_꼴_식은_요소_이름과_별칭으로_적힌다(client: TestC assert extra["이름글"] == "노무비 * 5 % = 공구손료및경장비" -def test_멈추는_로직은_까닭_한_줄(client: TestClient) -> None: +def test_입력_없어도_이름_식은_보임(client: TestClient) -> None: + """값을 고르기 전(PLAN 2-5) — 멈추지 않고 왼쪽 이름 식은 그대로, 글·금액만 빔.""" got = client.post("/api/m01/text", json={"key": STACK, "inputs": {}}).json() - assert got["ok"] is False and "입력" in got["reason"] + assert got["ok"] is True + one = got["groups"][0]["줄"][0] + assert one["이름글"] and "석공노임" in one["이름글"] + assert one["글"] == "" and one["금액"] is None + + +def test_고른_값이_틀리면_그대로_막힘(client: TestClient) -> None: + """값을 넣었는데 틀린 경우(고르기 밖)는 지금처럼 멈춤 — 안 고른 것과 다름.""" + bad = dict(_inputs(STACK), 뒷길이=999) + got = client.post("/api/m01/text", json={"key": STACK, "inputs": bad}).json() + assert got["ok"] is False and "고르기" in got["reason"] def test_끝수는_줄이_아니라_소계에_붙는다(client: TestClient) -> None: