Skip to content

fix: generalize test_document/test_statement into Helper.pm#446

Draft
toddr-bot wants to merge 2 commits into
masterfrom
koan.toddr.bot/fix-issue-445
Draft

fix: generalize test_document/test_statement into Helper.pm#446
toddr-bot wants to merge 2 commits into
masterfrom
koan.toddr.bot/fix-issue-445

Conversation

@toddr-bot

@toddr-bot toddr-bot commented May 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

Extracts the duplicated test_document and test_statement helper functions from five test files into the shared t/lib/Helper.pm module, eliminating ~100 lines of copy-pasted code.

Fixes #445

Changes

  • Added test_document and test_statement to Helper.pm with @EXPORT_OK
  • Added internal _one_line_explain and _main_level_line diagnostic helpers
  • Updated t/feature_tracking.t, t/signature_details.t, t/ppi_token_unknown.t, t/ppi_token_quote_literal.t, and t/marpa.t to import from Helper instead of defining locally
  • Added t/helper_test_functions.t to verify the exported functions work correctly

Test plan

  • All 53109 tests pass across 70 test files with no regressions
  • New t/helper_test_functions.t validates both functions with various inputs
  • Verified test_statement auto-wrap behavior and test_document options passthrough

Generated by Kōan /fix


Quality Report

Changes: 7 files changed, 183 insertions(+), 200 deletions(-)

Code scan: 1 issue(s) found

  • t/lib/Helper.pm:156 — TODO comment

Tests: skipped

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

toddr-bot and others added 2 commits May 4, 2026 13:02
…Helper

Adds tests verifying that Helper.pm exports test_document and
test_statement functions with correct behavior:
- Export availability checks
- test_statement with explicit Statement class in expected
- test_statement with auto-wrapping (no Statement prefix)
- test_document with simple code
- test_document with PPI::Document options (feature_mods)

Marked $TODO since the functions are not yet extracted from
individual test files into the shared module.

See #445 for context on generalizing these test helpers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract duplicate test_document and test_statement functions from five
test files into the shared t/lib/Helper.pm module. Both functions parse
code, extract significant elements as class/content pairs, and compare
against expected arrays with helpful diagnostics on failure.

test_document accepts an optional leading arrayref of PPI::Document
options. test_statement auto-wraps expected arrays that don't start with
PPI::Statement.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@wchristian

Copy link
Copy Markdown
Member

Try and deduplicate the internals of test_document and test_statement.

@toddr-bot fix

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.

generalize test_document/test_statement

2 participants