Skip to content

Keep specs to unit tests and move lexer scenarios to PHPUnit - #161

Merged
chrisjenkinson merged 3 commits into
masterfrom
claude/unit-specs
Sep 25, 2026
Merged

chrisjenkinson merged 3 commits into
masterfrom
claude/unit-specs

Conversation

@chrisjenkinson

@chrisjenkinson chrisjenkinson commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

LexerSpec had become an integration test. Most of its examples built real states and regex matchers, so they exercised AbstractState, RegexFinder, Cursor and Token as well as the lexer. This separates the two kinds of test:

  • The end-to-end lexer scenarios move to a PHPUnit test, tests/Lexer/LexerTest.php, next to the existing NodeTraverserTest. They cover lookahead state switches, zero-length loops, idempotent tokenising, and token and error positions, including from a given start position.
  • LexerSpec now uses state and token doubles and specifies only the lexer's own behaviour: the state stack, moving the cursor forward, where the cursor starts, detecting zero-length loops, and resetting between calls.
  • SimpleNodeSpec's export example uses node doubles, so it checks only that a node exports its own attributes and children.

Value objects such as TokenPosition and MatchedText are still used directly in specs.

@chrisjenkinson
chrisjenkinson merged commit 9a92d8d into master Sep 25, 2026
4 checks passed
@chrisjenkinson
chrisjenkinson deleted the claude/unit-specs branch September 25, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant