diff --git a/M02_MasterTemplete/DataFlow/M02_DF_Eval.ts b/M02_MasterTemplete/DataFlow/M02_DF_Eval.ts index cb0516e43..9b6380065 100644 --- a/M02_MasterTemplete/DataFlow/M02_DF_Eval.ts +++ b/M02_MasterTemplete/DataFlow/M02_DF_Eval.ts @@ -347,7 +347,8 @@ function otherLogic( } const inner: CfValues = {}; for (const d of designInputs(other)) { - const v = d.port in arrive ? arrive[d.port] : given[d.port]; + // 값 차례 = 이어진 선 > 넘긴 값 > 상자에 둔 예시값 > 그 로직 자기 예시값(inner 에 안 넣음) + const v = d.port in arrive ? arrive[d.port] : (given[d.port] ?? ref?.examples?.[d.port]); if (v !== undefined && v !== null) (inner[d.box] ??= {})[d.port] = v; } const ev = evalLogic(other, inner, { logics: opts.logics, depth: (opts.depth ?? 0) + 1 }); diff --git a/M02_MasterTemplete/DataFlow/M02_DF_Model.ts b/M02_MasterTemplete/DataFlow/M02_DF_Model.ts index 73a18d287..f8ee64e95 100644 --- a/M02_MasterTemplete/DataFlow/M02_DF_Model.ts +++ b/M02_MasterTemplete/DataFlow/M02_DF_Model.ts @@ -64,6 +64,8 @@ export interface CfLogicRef { outputs: CfPill[]; /** 받는 알약 = 그 로직의 「설계 때 정할 것」(변수 · 재료 자리) */ designs: CfPill[]; + /** 선 없는 받는 알약의 예시값(키 = 받는 알약 이름) — 값 차례 = 이어진 선 > 넘긴 값 > 이것 > 그 로직 자기 예시값 */ + examples?: Record; } export interface CfInput { @@ -154,6 +156,8 @@ export interface CfDesign { unit: string; variable?: CfVariable; element?: CfElementRef; + /** 보일 예시값 — 변수 = variable.example · 다른 로직 = logic.examples(없으면 빈 칸 → 그 로직 자기 예시값) */ + example?: number | string | null; } /** 사용자 요소 — 그룹에 없는 새 요소(마스터에 안 씀 · `_data` 에 저장) */ @@ -567,7 +571,14 @@ export function designInputs(lg: CfLogic): CfDesign[] { for (const b of lg.boxes) { const vars = b.input?.variables ?? b.func?.variables ?? []; for (const v of vars) - out.push({ box: b.id, port: v.name, kind: "변수", unit: v.unit || "-", variable: clone(v) }); + out.push({ + box: b.id, + port: v.name, + kind: "변수", + unit: v.unit || "-", + variable: clone(v), + example: v.example, + }); for (const e of b.input?.mode === "group" ? b.input.elements : []) if (e.mode === "choice") out.push({ @@ -580,7 +591,13 @@ export function designInputs(lg: CfLogic): CfDesign[] { if (b.input?.mode === "logic") for (const d of b.input.logic?.designs ?? []) if (!lg.links.some((l) => l.to.box === b.id && l.to.name === d.name)) - out.push({ box: b.id, port: d.name, kind: "다른 로직", unit: d.unit || "-" }); + out.push({ + box: b.id, + port: d.name, + kind: "다른 로직", + unit: d.unit || "-", + example: b.input.logic?.examples?.[d.name] ?? null, + }); } return out; } diff --git a/resources/tester/test_m02_df_model.py b/resources/tester/test_m02_df_model.py index c8b0663bd..56bdf7c3d 100644 --- a/resources/tester/test_m02_df_model.py +++ b/resources/tester/test_m02_df_model.py @@ -592,3 +592,20 @@ def test_끝수_함수_출력_출력_상자() -> None: "out([a, E.evalLogic(lg, V).cost.노무비]);" ) assert got == [537000, 540000] + + +def test_다_다른_로직_받는_알약_예시값_차례() -> None: + got = _run( + LOGIC + + "lg = M.updateBox(lg, other.id, { input: { ...lg.boxes[1].input, logic: { ...lg.boxes[1].input.logic, examples: { 계수: 10, 면적: 99 } } } });\n" + "const a = E.evalLogic(lg, {}, { logics: LOGICS }).cost.경비;\n" + "const b = E.evalLogic(lg, { [other.id]: { 계수: 2 } }, { logics: LOGICS }).cost.경비;\n" + "const noEx = M.updateBox(lg, other.id, { input: { ...lg.boxes[1].input, logic: { ...lg.boxes[1].input.logic, examples: undefined } } });\n" + "out([a, b, E.evalLogic(noEx, {}, { logics: LOGICS }).cost.경비," + " M.designInputs(lg).map(d => [d.kind, d.port, d.example]), M.designInputs(noEx).map(d => d.example)]);" + ) + a, b, c, designs, plain = got + # 면적 = 이어진 선(길이 7) > 예시값 99 · 계수 = 상자 예시값 10 · 넘긴 값 2 가 이김 · 없으면 그 로직 예시값 3 + assert (a, b, c) == (70000, 14000, 21000) + assert designs == [["변수", "길이", 7], ["다른 로직", "계수", 10]] + assert plain == [7, None]