"""B09 사용자 식 셈 — Q 식 편집 칸이 받는 식(PLAN 12장 2차 ③ · STmate `wM_Edit_San` 함수).""" from __future__ import annotations from decimal import Decimal import pytest from B09_Estimation.B09_Estimation_Expression import ExpressionError, evaluate def test_실무_Q_식을_그대로_센다() -> None: # 18번 §2.2 — 3600 × q 0.2 × K 0.7 × f 0.85 × E 0.55 ÷ Cm 15 = 15.708 assert evaluate("3600*0.2*0.7*ROUND(1/1.175,2)*0.55/15") == Decimal("15.708") # 울진 대흥 제15호표 되메우기 Q 68.04 assert evaluate("ROUND(3600*0.7*0.9*(1/1.25)*0.75/20, 2)") == Decimal("68.04") assert evaluate("INT(7.9) + SQRT(16) - ROUNDDOWN(1.239, 2)") == Decimal("9.77") assert evaluate("60 ÷ 4 × 0.45 × 0.8") == Decimal("5.40") @pytest.mark.parametrize("text", ["__import__('os')", "a+1", "1/0", "2**3", "", "ROUND(1)"]) def test_모르는_글·0_나누기·빈_식은_거절한다(text: str) -> None: with pytest.raises(ExpressionError): evaluate(text)