Test::XML::Twig(3pm)
π Test::XML::Twig β bestie edition π
okay so this is the Test::XML::Twig(3pm) manual page, and no bc you're gonna need it. This module is literally just for testing XML::Twig handlers β¨ and it's giving "small but mighty." Lowkey obsessed with how useful this is.
β¨ NAME β¨
Test::XML::Twig β Test XML::Twig handlers π
πΈ SYNOPSIS πΈ
bestie, here's the whole vibe:
use Test::XML::Twig tests => 2;
use My::Twig qw( handler );
test_twig_handler(
\&handler,
'<foo/>', '<bar/>',
'turns foo to bar',
);
test_twig_handlers(
{ twig_handlers => { 'foo' => \&handler } },
'<foo/>', '<bar/>',
'turns foo into bar',
);
that's it. that's the whole thing. iconic. π
π¦ DESCRIPTION π¦
This module is for testing XML::Twig handlers. periodt. π
π FUNCTIONS π
all functions are exported π«Ά (not me handing you everything for free fr fr)
get_twig ( INPUT [, ARGS ] )
Returns a parsed twig of INPUT, or undef on parse failure. π
Optionally, ARGS may be supplied as a set of hash-like parameters to be passed into the twig constructor. slay.
test_twig_handler ( HANDLER, INPUT, EXPECTED, TESTNAME [, COND ] )
Parse INPUT, using HANDLER as a twig_handler β i.e: it gets called after the parse tree has been built. π§
Tests that the result is the same as EXPECTED (which can be either a string of XML or a quoted regex). HANDLER must be a code ref. no code ref, no dice bestie.
Optionally, COND can be supplied. Instead of the handler being called with the root element of INPUT, COND will be used with first_child() to select an alternative element. cute lil detour β¨
Returns true / false depending upon test success. β β
test_twig_handlers ( ARGS, INPUT, EXPECTED, TESTNAME )
This is similar to test_twig_handler(), but with more flexibility. main character energy honestly π
The first argument, ARGS, is a hash reference which can be used to specify any of the ordinary parameters to twig's constructor. This lets you test things like start_tag_handlers, as well as multiple twig_handlers together. so many options, so little time π
π SEE ALSO π
Test::More, Test::XML, XML::Twig.
(go read them, iykyk π)
π AUTHOR π
Dominic Mitchell, <cpan2 (at) semantico.com> π«Ά
β COPYRIGHT AND LICENSE β
Copyright 2002 by semantico
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
fr fr, that license is the real one β same terms as Perl itself, don't come for me π
okay that's the whole page bestie, you ate it up, go write some tests π β¨
this was brought to you by perl v5.34.0 on 2022-06-18, straight out of the Test::XML::Twig(3pm) manual πΈ mwah, bye π¦
π¦ where this page comes from
- debian bookworm: libtest-xml-perl 0.08-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libtest-xml-perl 0.08-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtest-xml-perl 0.08-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms