Skip to content

test: add comprehensive unit tests for Template::Context#446

Draft
toddr-bot wants to merge 1 commit into
mainfrom
koan.toddr.bot/test-context
Draft

test: add comprehensive unit tests for Template::Context#446
toddr-bot wants to merge 1 commit into
mainfrom
koan.toddr.bot/test-context

Conversation

@toddr-bot
Copy link
Copy Markdown
Contributor

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

What

79 unit tests for Template::Context, the runtime engine that ties all TT components together.

Why

Context is the central module handling template resolution, processing, plugin/filter loading, exception handling, and variable scoping — yet it only had integration-style tests via template processing. Direct unit tests catch edge cases and serve as executable documentation.

How

Tests exercise every public method directly:

  • Constructor: VARIABLES, PRE_DEFINE, STASH, BLOCKS, TRIM, EVAL_PERL, RECURSION, PREFIX_MAP, EXPOSE_BLOCKS, DEBUG
  • template(): Document/CODE passthrough, BLOCKS cache, BLKSTACK ordering, provider chain, prefix routing, error on not-found
  • process(): code blocks, params (localized vs not), TRIM, multiple templates, exception propagation, stash declone on error
  • include(): stash localization verified
  • insert(): single/multiple files, prefix routing, errors
  • throw(): exception object, type+info, type+info+output, single message, empty/undef
  • catch(): exception passthrough, output buffer, plain string coercion
  • localise/delocalise: clone creation, nested scoping
  • visit/leave: BLKSTACK LIFO ordering
  • reset(): BLKSTACK clear + INIT_BLOCKS restore
  • define_block/filter/vmethod/view/views: all forms
  • filter(): caching, alias, args bypass, unknown error
  • plugin(): standard load, unknown error
  • debugging(): on/off/format/msg
  • AUTOLOAD: read-only member access, warning for undefined
  • DESTROY: circular reference cleanup

Testing

perl -Ilib t/unit-context.t   # 79 subtests, all pass
make test                      # full suite passes

🤖 Generated with Claude Code


Quality Report

Changes: 1 file changed, 950 insertions(+)

Code scan: 1 issue(s) found

  • t/unit-context.t:0 — 950 lines added

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

79 subtests covering the full public API: constructor configuration,
template() resolution (blocks, blkstack, providers, prefixes),
process()/include()/insert(), throw()/catch() argument forms,
localise/delocalise, visit/leave, reset, define_block/filter/vmethod/view,
filter caching, plugin loading, debugging, AUTOLOAD, and DESTROY.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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