2.1 KiB
STATUS-lex
Commit: 7ac5cdaded6af3b635d6d638f9c20082b5648393
Gate Verification
D1 — numbers
What: Integers and floats tokenize to NUMBER with correct value type (int/float). EOF appended.
Command: python -m unittest calc.test_lexer.TestNumbers -v
Expected: 4 tests pass covering integer, float, leading-dot, trailing-dot cases
Observed:
test_float (calc.test_lexer.TestNumbers.test_float) ... ok
test_float_leading_dot (calc.test_lexer.TestNumbers.test_float_leading_dot) ... ok
test_float_trailing_dot (calc.test_lexer.TestNumbers.test_float_trailing_dot) ... ok
test_integer (calc.test_lexer.TestNumbers.test_integer) ... ok
Result: PASS
D2 — operators & parens
What: + - * / ( ) tokenize to PLUS MINUS STAR SLASH LPAREN RPAREN; 1+2*3 yields NUMBER PLUS NUMBER STAR NUMBER EOF.
Command: python -c "from calc.lexer import tokenize; print([(t.kind,t.value) for t in tokenize('3.5*(1-2)')])"
Expected: [('NUMBER', 3.5), ('STAR', '*'), ('LPAREN', '('), ('NUMBER', 1), ('MINUS', '-'), ('NUMBER', 2), ('RPAREN', ')'), ('EOF', None)]
Observed:
[('NUMBER', 3.5), ('STAR', '*'), ('LPAREN', '('), ('NUMBER', 1), ('MINUS', '-'), ('NUMBER', 2), ('RPAREN', ')'), ('EOF', None)]
Result: PASS
D3 — whitespace & errors
What: Spaces/tabs between tokens are skipped; invalid chars raise LexError with char and position.
Command 1: python -c "from calc.lexer import tokenize; tokenize('1 @ 2')" → must raise LexError
Observed:
calc.lexer.LexError: unexpected character '@' at position 2
Result: PASS
Command 2: python -m unittest calc.test_lexer.TestWhitespaceAndErrors -v
Observed: 6 tests pass (whitespace_skipped, tab_skipped, invalid_at_raises, invalid_dollar_raises, invalid_letter_raises, invalid_position_in_message)
Result: PASS
D4 — tests green
What: python -m unittest -q passes with 0 failures covering D1–D3 including " 12 + 3 ", "3.5*(1-2)", "1 @ 2" raising LexError.
Command: python -m unittest -q
Expected: Ran N tests in X.XXXs / OK
Observed:
Ran 14 tests in 0.000s
OK
Result: PASS