2.1 KiB
2.1 KiB
STATUS — eval phase
Commit: c6086a4
Gate verification
D1 — arithmetic (precedence, parens, unary minus)
Command: python -m unittest calc.test_evaluator.TestArithmetic -v
Expected: 5 tests pass
Observed:
test_add_mul_precedence (calc.test_evaluator.TestArithmetic) ... ok # 2+3*4=14
test_left_associative_subtraction (calc.test_evaluator.TestArithmetic) ... ok # 8-3-2=3
test_parens (calc.test_evaluator.TestArithmetic) ... ok # (2+3)*4=20
test_unary_minus_leading (calc.test_evaluator.TestArithmetic) ... ok # -2+5=3
test_unary_minus_rhs (calc.test_evaluator.TestArithmetic) ... ok # 2*-3=-6
PASS
D2 — division (true division + EvalError on zero)
Command: python -m unittest calc.test_evaluator.TestDivision -v
Expected: 4 tests pass, ZeroDivisionError never escapes
Observed:
test_divide_by_zero_expression_raises_eval_error ... ok
test_divide_by_zero_raises_eval_error ... ok
test_no_bare_zero_division_error ... ok
test_true_division ... ok # 7/2=3.5
PASS
D3 — result type (whole → int, fractional → float)
Command: python -m unittest calc.test_evaluator.TestResultType -v
Expected: 4 tests pass
Observed:
test_fractional_division_returns_float ... ok # 7/2 is float
test_integer_add_returns_int ... ok
test_integer_mul_returns_int ... ok
test_whole_division_returns_int ... ok # 4/2 is int
PASS
D4 — CLI
Commands and observed outputs:
| Command | Expected | Observed | Exit |
|---|---|---|---|
python calc.py "2+3*4" |
14 |
14 |
0 |
python calc.py "(2+3)*4" |
20 |
20 |
0 |
python calc.py "7/2" |
3.5 |
3.5 |
0 |
python calc.py "4/2" |
2 |
2 |
0 |
python calc.py "1/0" |
error→stderr, exit≠0 | Error: Division by zero (stderr), stdout empty |
1 |
python calc.py "1 +" |
error→stderr, exit≠0 | Error: Unexpected end of input (stderr) |
1 |
D5 — whole suite + no regression
Command: python -m unittest -q
Expected: all tests pass, 0 failures
Observed:
Ran 59 tests in 0.231s
OK
Prior lex + parse tests: included in the 59, all pass.