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 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