From 2be767d186b9ecdf59645a6c84bdfbab567851c3 Mon Sep 17 00:00:00 2001 From: umsangdon Date: Thu, 1 Oct 2026 16:32:32 +0900 Subject: [PATCH] =?UTF-8?q?fix(m02-cf):=20=ED=95=A8=EC=88=98=20=EC=83=81?= =?UTF-8?q?=EC=9E=90=20=EC=B6=9C=EB=A0=A5=20=EA=B8=B0=EB=B3=B8=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=EC=9D=84=20=EB=A1=9C=EC=A7=81=20=EC=95=88=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EA=B2=B9=EC=B9=98=EC=A7=80=20=EC=95=8A=EA=B2=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - addBox(function) 출력 이름 = 「결과 1」 「결과 2」 … (안 쓰인 가장 작은 번호) · A1 머리도 같은 이름 - 이름이 겹치면 link 가 받는 알약을 「이름 (2)」 로 만듦(이미 됨 · 시험 더함) - 시험 14개 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01VBToTCGk5dqDKeXCEP3vhk --- M02_MasterTemplete/CostFlow/M02_CF_Model.ts | 12 ++++++++--- resources/tester/test_m02_cf_model.py | 24 +++++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/M02_MasterTemplete/CostFlow/M02_CF_Model.ts b/M02_MasterTemplete/CostFlow/M02_CF_Model.ts index f6ada09ca..d19f3f431 100644 --- a/M02_MasterTemplete/CostFlow/M02_CF_Model.ts +++ b/M02_MasterTemplete/CostFlow/M02_CF_Model.ts @@ -188,13 +188,19 @@ export function addBox( ); const box: CfBox = { id, kind, name, color: BOX_COLOR[kind], unit: "-", x, y }; if (kind === "input") box.input = { mode: "variable", elements: [], variables: [] }; - if (kind === "function") + if (kind === "function") { + // 출력 이름은 로직 안에서 겹치지 않게 「결과 1」 「결과 2」 … — 다른 함수 상자의 받는 알약과 섞이지 않음 + const taken = lg.boxes.flatMap((b) => (b.func ? [b.func.output.name] : [])); + let n = 1; + while (taken.includes(`${tl("Result")} ${n}`)) n++; + const out = `${tl("Result")} ${n}`; box.func = { - sheet: { id: `s-${id}`, 이름: name, 칸: { A1: { 값: tl("Result") } } }, + sheet: { id: `s-${id}`, 이름: name, 칸: { A1: { 값: out } } }, inputs: [], variables: [], - output: { cell: "B1", name: tl("Result"), unit: "-" }, + output: { cell: "B1", name: out, unit: "-" }, }; + } if (kind === "output") box.output = { cost: "노무비", unit: "-" }; return { lg: { ...lg, boxes: [...lg.boxes, box] }, box }; } diff --git a/resources/tester/test_m02_cf_model.py b/resources/tester/test_m02_cf_model.py index 0e9ea8cce..818541127 100644 --- a/resources/tester/test_m02_cf_model.py +++ b/resources/tester/test_m02_cf_model.py @@ -322,3 +322,27 @@ def test_같은_이름_받는_알약은_번호() -> None: "out(x.boxes.find(y => y.id === g.id).func.inputs.map(i => i.port));" ) assert got == ["석공", "노무비", "석공 (2)", "할증"] + + +def test_함수_출력_기본_이름은_겹치지_않음_받는_알약은_번호() -> None: + got = _run( + "let lg = M.newLogic(); let r = add(lg, 'function'); lg = r.lg; const f1 = r.box;\n" + "r = add(lg, 'function'); lg = r.lg; const f2 = r.box;\n" + "r = add(lg, 'function'); lg = r.lg; const f3 = r.box;\n" + "lg = M.removeBox(lg, f2.id); r = add(lg, 'function'); lg = r.lg; const f4 = r.box;\n" + "lg = M.link(lg, { box: f1.id, name: '결과 1' }, { box: f3.id, name: '' }).lg;\n" + "lg = M.link(lg, { box: f4.id, name: '결과 2' }, { box: f3.id, name: '' }).lg;\n" + "r = add(lg, 'function'); lg = r.lg; const f5 = r.box;\n" + "lg = M.updateBox(lg, f5.id, { func: { ...f5.func, output: { ...f5.func.output, name: '결과 1' } } });\n" + "lg = M.link(lg, { box: f5.id, name: '결과 1' }, { box: f3.id, name: '' }).lg;\n" + "out([[f1, f3, f4, f5].map(b => [b.func.output.name, b.func.sheet.칸.A1.값])," + " lg.boxes.find(b => b.id === f3.id).func.inputs.map(i => i.port)]);" + ) + names, ports = got + assert names == [ + ["결과 1", "결과 1"], + ["결과 3", "결과 3"], + ["결과 2", "결과 2"], + ["결과 4", "결과 4"], + ] + assert ports == ["결과 1", "결과 2", "결과 1 (2)"]