From ac1224220b78d1d56d9a48ab1ceca373cd1f6562 Mon Sep 17 00:00:00 2001 From: umsangdon Date: Wed, 23 Sep 2026 05:48:57 +0900 Subject: [PATCH] =?UTF-8?q?fix(M01):=20=EC=84=A4=EA=B3=84=20=EC=9E=85?= =?UTF-8?q?=EB=A0=A5=20=EB=B9=84=EC=96=B4=EB=8F=84=20=ED=85=8D=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=88=98=EC=8B=9D=20=EC=9D=B4=EB=A6=84=20=EC=8B=9D?= =?UTF-8?q?=EC=9D=80=20=EB=B3=B4=EC=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit master_text._env_of 가 입력을 못 갖추면(값 넣기 전) 받은 것만 담고 중간은 건너뛰어 lines() 가 ok:false 로 일찍 안 죽고 이름 식·조각까지 짓게 함 고른 값이 틀린 경우(고르기·범위 밖)는 지금처럼 그대로 멈춤 — 구분해 시험 둘로 확인 --- resources/master_data/scripts/master_text.py | 7 ++++++- resources/tester/test_m01_text.py | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) 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: