SYNOPSIS

  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',
  );

DESCRIPTION

This module is for testing XML::Twig handlers.

FUNCTIONS

All functions are exported.

get_twig ( \s-1INPUT\s0 [, \s-1ARGS\s0 ] )

Return a parsed twig of \s-1INPUT\s0, or undef on parse failure. Optionally, \s-1ARGS\s0 may be supplied as a set of hash-like parameters to be passed into the twig constructor.

test_twig_handler ( \s-1HANDLER\s0, \s-1INPUT\s0, \s-1EXPECTED\s0, \s-1TESTNAME\s0 [, \s-1COND\s0 ] )

Parse \s-1INPUT\s0, using \s-1HANDLER\s0 as a twig_handler (i.e: it gets called after the parse tree has been built). Tests that the result is the same as \s-1EXPECTED\s0 (which can be either a string of \s-1XML\s0 or a quoted regex). \s-1HANDLER\s0 must be a code ref. Optionally, \s-1COND\s0 can be supplied. Instead of the handler being called with the root element of \s-1INPUT\s0, \s-1COND\s0 will be used with first_child() to select an alternative element. Returns true / false depending upon test success.

test_twig_handlers ( \s-1ARGS\s0, \s-1INPUT\s0, \s-1EXPECTED\s0, \s-1TESTNAME\s0 )

This is similiar to test_twig_handler(), but with more flexibility. The first argument, \s-1ARGS\s0, 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.

RELATED TO Test::XML::Twig…

Test::More, Test::XML, XML::Twig.

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.