test: add comprehensive unit tests for Template::Directive#444
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What: Adds 53 unit tests for
Template::Directive, the code generatorthat 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/*.pmmodule(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,textblock,quoted)ident,identref) including NAMESPACE dispatch and TRACE_VARSassign,args,set,default)if,foreach,while,switch)try/catch,throw)include,process,insert,wrapper,filter)macro,capture,view,perl,rawperl)$WHILE_MAX,$PRETTY,$OUTPUT)template()output compiles to a CODE refTesting: 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 addedTests: passed (OK)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline