From 2c134b440fd8bf0cc85019797c77b792ce687f4c Mon Sep 17 00:00:00 2001 From: umsangdon Date: Thu, 1 Oct 2026 21:21:30 +0900 Subject: [PATCH] =?UTF-8?q?fix(M02):=20=ED=9D=90=EB=A6=84=EB=8F=84=20restP?= =?UTF-8?q?arts=20=E2=80=94=20=EC=89=BC=EC=9D=B4=20=EA=B7=B8=20=EC=83=81?= =?UTF-8?q?=EC=9E=90=EC=97=90=20=EA=B1=B8=EB=A0=B8=EB=82=98=EB=8A=94=20lin?= =?UTF-8?q?k=20=EC=99=80=20=EB=AC=B4=EA=B4=80=20=C2=B7=20=EB=B9=88=20?= =?UTF-8?q?=EA=B0=92=20=ED=8C=90=EC=A0=95=EC=9D=80=20=EB=82=B4=EB=B3=B4?= =?UTF-8?q?=EB=82=B4=EB=8A=94=20=EC=95=8C=EC=95=BD=20=EA=B0=92=EB=A7=8C(PL?= =?UTF-8?q?AN=2035-9=20=EB=B8=8C=EB=A0=88=EC=9D=B8=20=EC=9E=AC=EA=B2=80?= =?UTF-8?q?=EC=A6=9D)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 지반 견본(토사) 꼴 시험: 흐림 = 브레이커로 깨기 하나 · 1㎥ 경비 · 경비는 안 흐림 - 시험 test_m02_df_diagram_parts.py 7 통과 · DataFlow 전부 검사 초록 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Ly2oHAaTDYRjcniAmHR81z --- .../DataFlow/M02_DF_Diagram_Parts.ts | 5 +- resources/tester/test_m02_df_diagram_parts.py | 100 ++++++++++++++++++ 2 files changed, 103 insertions(+), 2 deletions(-) diff --git a/M02_MasterTemplete/DataFlow/M02_DF_Diagram_Parts.ts b/M02_MasterTemplete/DataFlow/M02_DF_Diagram_Parts.ts index c96fe7fe4..cf0616712 100644 --- a/M02_MasterTemplete/DataFlow/M02_DF_Diagram_Parts.ts +++ b/M02_MasterTemplete/DataFlow/M02_DF_Diagram_Parts.ts @@ -322,8 +322,9 @@ export function restParts( for (const b of lg.boxes) { const incoming = lg.links.filter((l) => l.to.box === b.id); const allRest = incoming.length > 0 && incoming.every((l) => links.has(l.id)); - const outs = Object.values(values[b.id] ?? {}); - const hit = rests.some((k) => !k.link && k.box === b.id); + // 내보내는 알약 값만(들어온 값은 빼고) · 쉼이 그 상자에 걸렸나(Eval 쉼 줄은 link 가 늘 있음) + const outs = portsOut(b).map((p) => values[b.id]?.[p.name]); + const hit = rests.some((k) => k.box === b.id); if (allRest || (hit && outs.every(empty))) boxes.add(b.id); } return { links, pills, boxes }; diff --git a/resources/tester/test_m02_df_diagram_parts.py b/resources/tester/test_m02_df_diagram_parts.py index f5842893e..ae8248233 100644 --- a/resources/tester/test_m02_df_diagram_parts.py +++ b/resources/tester/test_m02_df_diagram_parts.py @@ -304,3 +304,103 @@ def test_쉼은_일부면_선과_받는_알약만_모두면_상자도(): assert every["boxes"] == ["f"] # 상자에 걸린 쉼 — 내보내는 값이 있으면 안 흐림 · 모두 빈 값이면 흐림 assert filled["boxes"] == [] and empty["boxes"] == ["m"] + + +def test_지반_토사_쉼_흐림은_브레이커로_깨기_하나(): + def fn(id_, name, ins, out): + return { + "id": id_, + "kind": "function", + "name": name, + "color": "", + "unit": "-", + "x": 0, + "y": 0, + "func": { + "sheet": {}, + "inputs": [{"port": p, "cell": f"B{i + 1}"} for i, p in enumerate(ins)], + "variables": [], + "output": {"cell": "B9", "name": out, "unit": "원"}, + }, + } + + gate = {"kind": "gate", "from": port("ig", "지반"), "op": "=", "value": "암"} + ground = { + "key": None, + "name": "지반", + "resultUnit": "원/㎥", + "userElements": [], + "boxes": [ + { + "id": "ig", + "kind": "input", + "name": "지반 · 굴착량", + "color": "", + "unit": "-", + "x": 0, + "y": 0, + "input": { + "mode": "variable", + "elements": [], + "variables": [ + {"name": "지반", "type": "choice", "unit": "-", "example": "토사"}, + {"name": "굴착량", "type": "number", "unit": "㎥", "example": 1}, + ], + }, + }, + fn("exc", "굴삭기로 파기", ["굴착량", "시간당 경비"], "굴삭기 경비"), + fn("brk", "브레이커로 깨기", ["굴착량", "시간당 경비"], "브레이커 경비"), + fn("sum", "1㎥ 경비", ["굴삭기 경비", "브레이커 경비", "굴착량"], "1㎥ 경비"), + { + "id": "out", + "kind": "output", + "name": "경비", + "color": "", + "unit": "원", + "x": 0, + "y": 0, + "output": {"cost": "경비", "unit": "원"}, + }, + ], + "links": [ + { + "id": "l1", + "from": port("ig", "굴착량"), + "to": port("exc", "굴착량"), + "rule": {**gate, "op": "≠"}, + }, + {"id": "l2", "from": port("ig", "굴착량"), "to": port("brk", "굴착량"), "rule": gate}, + {"id": "l5", "from": port("exc", "굴삭기 경비"), "to": port("sum", "굴삭기 경비")}, + {"id": "l6", "from": port("brk", "브레이커 경비"), "to": port("sum", "브레이커 경비")}, + {"id": "l7", "from": port("ig", "굴착량"), "to": port("sum", "굴착량")}, + {"id": "l8", "from": port("sum", "1㎥ 경비"), "to": port("out", "값")}, + ], + } + # Eval 쉼 줄은 link 가 늘 있음 — 조건 선 l2(받는 상자 브레이커) · 빈 값이 흘러간 l6(받는 상자 1㎥ 경비) + rests = [ + { + "kind": "통과 안 됨", + "level": "쉼", + "box": "brk", + "port": "굴착량", + "link": "l2", + "text": "암이 아님", + }, + { + "kind": "통과 안 됨", + "level": "쉼", + "box": "sum", + "port": "브레이커 경비", + "link": "l6", + "text": "쉼", + }, + ] + values = { + "brk": {"시간당 경비": 80000, "굴착량": None, "브레이커 경비": None}, + "sum": {"굴삭기 경비": 2000, "브레이커 경비": None, "굴착량": 1, "1㎥ 경비": 2000}, + "out": {"값": 2000}, + } + [got] = run([{"op": "restParts", "lg": ground, "rests": rests, "values": values}]) + assert got["boxes"] == ["brk"] + assert got["links"] == ["l2", "l6"] + assert got["pills"] == ["brk|굴착량", "sum|브레이커 경비"]