Merge remote-tracking branch 'origin/sub_laptop_3' into main_laptop_1
This commit is contained in:
@@ -31,6 +31,9 @@ const m = box.exports;
|
||||
if (j.name === "wouldCycle") {
|
||||
const graph = j.args[2];
|
||||
out.push(await m.wouldCycle(j.args[0], j.args[1], async (k) => graph[k] ?? null));
|
||||
} else if (j.name === "fillTemplate") {
|
||||
const vals = j.args[2];
|
||||
out.push(m.fillTemplate(j.args[0], j.args[1], (p) => vals[`${p.box}.${p.name}`]));
|
||||
} else out.push(await m[j.name](...j.args));
|
||||
}
|
||||
process.stdout.write(JSON.stringify(out));
|
||||
@@ -266,3 +269,38 @@ def test_옛_줄_입력과_자동값으로_다른_로직_입력을_읽음():
|
||||
{"name": "쌓기", "unit": "-"},
|
||||
]
|
||||
assert ref["examples"] == {"뒷길이": 25, "돌": "깬잡석"} # 빈 글 · 입력에 없는 이름은 뺌
|
||||
|
||||
|
||||
def test_검색어_틀_자리와_채움():
|
||||
tpl = "레미콘 {굵은골재최대치수}-{강도}-{슬럼프}"
|
||||
assert call("templateSlots", tpl) == ["굵은골재최대치수", "강도", "슬럼프"]
|
||||
assert call("templateSlots", "{a} {a} {b}") == ["a", "b"] # 겹친 자리는 한 번
|
||||
slots = [
|
||||
{"name": "굵은골재최대치수", "from": {"box": "b2", "name": "굵은"}},
|
||||
{"name": "강도", "from": {"box": "b2", "name": "강도"}},
|
||||
{"name": "슬럼프", "from": {"box": "b2", "name": "슬럼프"}},
|
||||
]
|
||||
values = {"b2.굵은": 25, "b2.강도": 18, "b2.슬럼프": 120}
|
||||
got = call("fillTemplate", tpl, slots, values)
|
||||
assert got == {"text": "레미콘 25-18-120", "missing": []}
|
||||
part = call("fillTemplate", tpl, slots, {"b2.굵은": 25, "b2.강도": ""})
|
||||
assert part["missing"] == ["강도", "슬럼프"]
|
||||
assert part["text"] == "레미콘 25-{강도}-{슬럼프}" # 빈 자리는 그대로 둠
|
||||
|
||||
|
||||
def test_검색어_틀_규칙과_검사():
|
||||
slots = [{"name": "a", "from": {"box": "b2", "name": "굵은"}}]
|
||||
rule = call("templateRule", "레미콘 {a}", slots)
|
||||
assert (
|
||||
rule["field"] == "검색어"
|
||||
and rule["template"] == "레미콘 {a}"
|
||||
and rule["from"] == slots[0]["from"]
|
||||
)
|
||||
el = call("materialElement", "rule", "콘크리트", {"구분": "레미콘"}, {"rule": rule})
|
||||
assert call("checkMaterial", el, []) is None
|
||||
no_slot = call("templateRule", "레미콘", [])
|
||||
bad = call("materialElement", "rule", "콘크리트", {"구분": "레미콘"}, {"rule": no_slot})
|
||||
assert "자리" in call("checkMaterial", bad, [])
|
||||
short = call("templateRule", "레미콘 {a}-{b}", slots) # 자리 둘인데 알약은 하나
|
||||
two = call("materialElement", "rule", "콘크리트", {}, {"rule": short})
|
||||
assert "알약" in call("checkMaterial", two, [])
|
||||
|
||||
Reference in New Issue
Block a user