1Test::XML::Twig(3) User Contributed Perl Documentation Test::XML::Twig(3)
2
3
4
6 Test::XML::Twig - Test XML::Twig handlers
7
9 use Test::XML::Twig tests => 2;
10 use My::Twig qw( handler );
11
12 test_twig_handler(
13 \&handler,
14 '<foo/>', '<bar/>',
15 'turns foo to bar',
16 );
17
18 test_twig_handlers(
19 { twig_handlers => { 'foo' => \&handler } },
20 '<foo/>', '<bar/>',
21 'turns foo into bar',
22 );
23
25 This module is for testing XML::Twig handlers.
26
28 All functions are exported.
29
30 get_twig ( INPUT [, ARGS ] )
31 Return a parsed twig of INPUT, or undef on parse failure.
32 Optionally, ARGS may be supplied as a set of hash-like parameters
33 to be passed into the twig constructor.
34
35 test_twig_handler ( HANDLER, INPUT, EXPECTED, TESTNAME [, COND ] )
36 Parse INPUT, using HANDLER as a twig_handler (i.e: it gets called
37 after the parse tree has been built). Tests that the result is the
38 same as EXPECTED (which can be either a string of XML or a quoted
39 regex). HANDLER must be a code ref.
40
41 Optionally, COND can be supplied. Instead of the handler being
42 called with the root element of INPUT, COND will be used with
43 first_child() to select an alternative element.
44
45 Returns true / false depending upon test success.
46
47 test_twig_handlers ( ARGS, INPUT, EXPECTED, TESTNAME )
48 This is similiar to test_twig_handler(), but with more flexibility.
49 The first argument, ARGS, is a hash reference which can be used to
50 specify any of the ordinary parameters to twig's constructor. This
51 lets you test things like start_tag_handlers, as well as multiple
52 twig_handlers together.
53
55 Test::More, Test::XML, XML::Twig.
56
58 Dominic Mitchell, <cpan2 (at) semantico.com>
59
61 Copyright 2002 by semantico
62
63 This library is free software; you can redistribute it and/or modify it
64 under the same terms as Perl itself.
65
66
67
68perl v5.32.1 2021-01-27 Test::XML::Twig(3)