Skip to content

test: add comprehensive unit tests for Template::Directive#444

Merged
toddr merged 1 commit into
mainfrom
koan.toddr.bot/test-directive
May 26, 2026
Merged

test: add comprehensive unit tests for Template::Directive#444
toddr merged 1 commit into
mainfrom
koan.toddr.bot/test-directive

Conversation

@toddr-bot

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

Copy link
Copy Markdown
Contributor

What: Adds 53 unit tests for Template::Directive, the code generator
that transforms parse trees into Perl code strings.

Why: Every TT directive flows through this module, yet it had zero
dedicated tests. This is the only core lib/Template/*.pm module
(alongside Plugin.pm) without a dedicated test file.

How: Tests each factory method by calling it directly with structured
input and verifying the generated Perl code contains the expected tokens
and structure. Covers:

  • Text quoting/escaping (text, textblock, quoted)
  • Identifier resolution (ident, identref) including NAMESPACE dispatch and TRACE_VARS
  • Assignment and args (assign, args, set, default)
  • Control flow (if, foreach, while, switch)
  • Error handling (try/catch, throw)
  • Template composition (include, process, insert, wrapper, filter)
  • Code blocks (macro, capture, view, perl, rawperl)
  • Package variables ($WHILE_MAX, $PRETTY, $OUTPUT)
  • Compilation check: verifies template() output compiles to a CODE ref

Testing: All 123 test files pass (3,244 subtests).

🤖 Generated with Claude Code


Quality Report

Changes: 1 file changed, 685 insertions(+)

Code scan: 1 issue(s) found

  • t/directive_methods.t:0 — 685 lines added

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

Template::Directive is the code generator that transforms parse trees
into Perl code strings — every TT directive flows through it, yet it
had zero dedicated tests. This adds 53 subtests covering all factory
methods: text quoting/escaping, identifier resolution, assignment,
control flow (if/foreach/while/switch), try/catch, macro, wrapper,
filter, capture, view, perl blocks, and edge cases for NAMESPACE
dispatch, TRACE_VARS, $PRETTY mode, and $WHILE_MAX.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@toddr toddr marked this pull request as ready for review May 26, 2026 12:27
@toddr toddr merged commit 6ac5b31 into main May 26, 2026
78 checks passed
@toddr toddr deleted the koan.toddr.bot/test-directive branch May 26, 2026 12:27
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.

2 participants