Skip to content

test: lexer advanced unit tests and full integration test suite#50

Merged
henrylee97 merged 4 commits into
masterfrom
claude/stupefied-knuth-c26b4e
May 13, 2026
Merged

test: lexer advanced unit tests and full integration test suite#50
henrylee97 merged 4 commits into
masterfrom
claude/stupefied-knuth-c26b4e

Conversation

@henrylee97

Copy link
Copy Markdown
Member

Summary

  • Add tests/test_lexer_advanced.py (22 tests): unit tests for lexer
    scenarios not covered by the existing suite — multiline lineno/offset
    tracking, block-comment and string-literal state machines, user_state
    threading, and error-position accuracy
  • Add tests/test_integration.py (52 tests): end-to-end tests for a
    realistic "Expr" DSL built with both the lexer and the parser, covering
    multi-level operator precedence, right-associative exponentiation, unary
    negation via prec_token, boolean operators, comparisons, let bindings,
    conditional expressions, and error reporting

Test plan

  • All 135 tests pass (pytest tests/ -q)
  • pyright strict: 0 errors (pyright tests/test_lexer_advanced.py tests/test_integration.py)
  • No formatting changes needed (black reports files unchanged)

henrylee97 and others added 3 commits May 13, 2026 03:44
…es, and edge cases

Covers scenarios not in test_lexer.py:
- Multiline lineno/offset accuracy (blank lines, leading whitespace, tabs)
- Block-comment state machine (/* ... */ skipping, multiline, unclosed behavior)
- String-literal state machine (quoted tokens, empty string, offset)
- user_state threading across tokens and per-lex() factory invocation
- Edge cases: empty input, single-char position, LexingError with correct position

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…eline

Defines a small expression language (integer literals, variables, arithmetic,
boolean operators, comparisons, let binding, if/then/else) and exercises the
complete Plare pipeline in 52 tests:

- Multi-level operator precedence (or < and < not < cmp < +/- < */÷ < **)
- Right-associative exponentiation: 2**3**2 == 512
- Unary minus via prec_token (UMINUS prec=6 < POW prec=7, so -2**2 == -4)
- Let binding with shadowing and body extension
- If/else with condition expressions and else-body extension
- LexingError and ParsingError with position and expected-token metadata

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@henrylee97 henrylee97 self-assigned this May 13, 2026
@henrylee97 henrylee97 added the test Tests for verifying expected behavior. label May 13, 2026
@henrylee97
henrylee97 requested a review from Copilot May 13, 2026 03:49
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown

Pytest Report

Test Results

  • Tests: 135
  • Errors: 0
  • Failures: 0
  • Skipped: 0

Comment by ✨sambyeol/publish-pytest-action

@github-actions

Copy link
Copy Markdown

Pytest Report

Test Results

  • Tests: 135
  • Errors: 0
  • Failures: 0
  • Skipped: 0

Comment by ✨sambyeol/publish-pytest-action

@github-actions

Copy link
Copy Markdown

Super-linter summary

Language Validation result
PYTHON_BLACK Pass ✅
PYTHON_ISORT Pass ✅
YAML Pass ✅

All files and directories linted successfully

For more information, see the GitHub Actions workflow run

Powered by Super-linter

@github-actions

Copy link
Copy Markdown

Super-linter summary

Language Validation result
PYTHON_BLACK Pass ✅
PYTHON_ISORT Pass ✅
YAML Pass ✅

All files and directories linted successfully

For more information, see the GitHub Actions workflow run

Powered by Super-linter

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands the project’s test suite by adding advanced unit tests for the lexer and an end-to-end integration suite that exercises both the lexer and LALR parser together via a realistic “Expr” DSL, with particular emphasis on position tracking and precedence/associativity behavior.

Changes:

  • Add tests/test_lexer_advanced.py to cover multiline lineno/offset tracking, lexer state-machine transitions (block comments / string literals), user_state threading, and LexingError position accuracy.
  • Add tests/test_integration.py to validate full lexer+parser pipelines (precedence, associativity, %prec-style override via prec_token, boolean operators, let/if constructs) and error reporting.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/test_lexer_advanced.py Adds targeted lexer unit tests for multiline position tracking, state-machine flows, user state threading, and error position reporting.
tests/test_integration.py Adds an end-to-end Expr DSL integration suite validating lexer+parser behavior across precedence/associativity, control-flow constructs, and error cases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@henrylee97
henrylee97 merged commit fb0a183 into master May 13, 2026
7 checks passed
@henrylee97
henrylee97 deleted the claude/stupefied-knuth-c26b4e branch May 13, 2026 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Tests for verifying expected behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants