diff options
Diffstat (limited to 'ext/Pod-Simple/t/for.t')
-rw-r--r-- | ext/Pod-Simple/t/for.t | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/ext/Pod-Simple/t/for.t b/ext/Pod-Simple/t/for.t new file mode 100644 index 0000000000..158cdc2b58 --- /dev/null +++ b/ext/Pod-Simple/t/for.t @@ -0,0 +1,107 @@ +BEGIN { + if($ENV{PERL_CORE}) { + chdir 't'; + @INC = '../lib'; + } +} + +use strict; +use Test; +BEGIN { plan tests => 21 }; + +#use Pod::Simple::Debug (5); + +ok 1; + +use Pod::Simple::DumpAsXML; +use Pod::Simple::XMLOutStream; +print "# Pod::Simple version $Pod::Simple::VERSION\n"; +sub e ($$) { Pod::Simple::DumpAsXML->_duo(@_) } + +my $x = 'Pod::Simple::XMLOutStream'; +$Pod::Simple::XMLOutStream::ATTR_PAD = ' '; +$Pod::Simple::XMLOutStream::SORT_ATTRS = 1; # for predictably testable output + + +sub moj {shift->accept_target('mojojojo')} +sub mojtext {shift->accept_target_as_text('mojojojo')} +sub any {shift->accept_target('*')} + +#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +ok( $x->_out( "=pod\n\nI like pie.\n\n=for mojojojo stuff\n\nYup.\n"), + '<Document><Para>I like pie.</Para><Para>Yup.</Para></Document>' +); +ok( $x->_out( "=pod\n\nI like pie.\n\n=for psketti,mojojojo,crunk stuff\n\nYup.\n"), + '<Document><Para>I like pie.</Para><Para>Yup.</Para></Document>' +); +ok( $x->_out( "=pod\n\nI like pie.\n\n=for mojojojo I<stuff>\n\nYup.\n"), + '<Document><Para>I like pie.</Para><Para>Yup.</Para></Document>' +); +ok( $x->_out( "=pod\n\nI like pie.\n\n=for psketti,mojojojo,crunk I<stuff>\n\nYup.\n"), + '<Document><Para>I like pie.</Para><Para>Yup.</Para></Document>' +); +ok( $x->_out( "=pod\n\nI like pie.\n\n=for :psketti,mojojojo,crunk I<stuff>\n\nYup.\n"), + '<Document><Para>I like pie.</Para><Para>Yup.</Para></Document>' +); + +print "# Testing accept_target ...\n"; + +ok( $x->_out( \&moj, "=pod\n\nI like pie.\n\n=for crunk stuff\n\nYup.\n"), + '<Document><Para>I like pie.</Para><Para>Yup.</Para></Document>' +); +ok( $x->_out( \&moj, "=pod\n\nI like pie.\n\n=for mojojojo I<stuff>\n\nYup.\n"), + '<Document><Para>I like pie.</Para><for target="mojojojo" target_matching="mojojojo"><Data xml:space="preserve">I<stuff></Data></for><Para>Yup.</Para></Document>' +); +ok( $x->_out( \&moj, "=pod\n\nI like pie.\n\n=for psketti,mojojojo,crunk I<stuff>\n\nYup.\n"), + '<Document><Para>I like pie.</Para><for target="psketti,mojojojo,crunk" target_matching="mojojojo"><Data xml:space="preserve">I<stuff></Data></for><Para>Yup.</Para></Document>' +); +ok( $x->_out( \&moj, "=pod\n\nI like pie.\n\n=for :mojojojo I<stuff>\n\nYup.\n"), + '<Document><Para>I like pie.</Para><for target=":mojojojo" target_matching="mojojojo"><Para><I>stuff</I></Para></for><Para>Yup.</Para></Document>' +); +ok( $x->_out( \&moj, "=pod\n\nI like pie.\n\n=for :psketti,mojojojo,crunk I<stuff>\n\nYup.\n"), + '<Document><Para>I like pie.</Para><for target=":psketti,mojojojo,crunk" target_matching="mojojojo"><Para><I>stuff</I></Para></for><Para>Yup.</Para></Document>' +); + +print "# Testing accept_target_as_text ...\n"; + +ok( $x->_out( \&mojtext, "=pod\n\nI like pie.\n\n=for mojojojo I<stuff>\n\nYup.\n"), + '<Document><Para>I like pie.</Para><for target="mojojojo" target_matching="mojojojo"><Para><I>stuff</I></Para></for><Para>Yup.</Para></Document>' +); +ok( $x->_out( \&mojtext, "=pod\n\nI like pie.\n\n=for psketti,mojojojo,crunk I<stuff>\n\nYup.\n"), + '<Document><Para>I like pie.</Para><for target="psketti,mojojojo,crunk" target_matching="mojojojo"><Para><I>stuff</I></Para></for><Para>Yup.</Para></Document>' +); +ok( $x->_out( \&mojtext, "=pod\n\nI like pie.\n\n=for :mojojojo I<stuff>\n\nYup.\n"), + '<Document><Para>I like pie.</Para><for target=":mojojojo" target_matching="mojojojo"><Para><I>stuff</I></Para></for><Para>Yup.</Para></Document>' +); +ok( $x->_out( \&mojtext, "=pod\n\nI like pie.\n\n=for :psketti,mojojojo,crunk I<stuff>\n\nYup.\n"), + '<Document><Para>I like pie.</Para><for target=":psketti,mojojojo,crunk" target_matching="mojojojo"><Para><I>stuff</I></Para></for><Para>Yup.</Para></Document>' +); + + + +print "# Testing accept_target(*) ...\n"; + +ok( $x->_out( \&any, "=pod\n\nI like pie.\n\n=for mojojojo I<stuff>\n\nYup.\n"), + '<Document><Para>I like pie.</Para><for target="mojojojo" target_matching="*"><Data xml:space="preserve">I<stuff></Data></for><Para>Yup.</Para></Document>' +); +ok( $x->_out( \&any, "=pod\n\nI like pie.\n\n=for mojojojo I<stuff>\n\nYup.\n"), + '<Document><Para>I like pie.</Para><for target="mojojojo" target_matching="*"><Data xml:space="preserve">I<stuff></Data></for><Para>Yup.</Para></Document>' +); +ok( $x->_out( \&any, "=pod\n\nI like pie.\n\n=for psketti,mojojojo,crunk I<stuff>\n\nYup.\n"), + '<Document><Para>I like pie.</Para><for target="psketti,mojojojo,crunk" target_matching="*"><Data xml:space="preserve">I<stuff></Data></for><Para>Yup.</Para></Document>' +); +ok( $x->_out( \&any, "=pod\n\nI like pie.\n\n=for :mojojojo I<stuff>\n\nYup.\n"), + '<Document><Para>I like pie.</Para><for target=":mojojojo" target_matching="*"><Para><I>stuff</I></Para></for><Para>Yup.</Para></Document>' +); +ok( $x->_out( \&any, "=pod\n\nI like pie.\n\n=for :psketti,mojojojo,crunk I<stuff>\n\nYup.\n"), + '<Document><Para>I like pie.</Para><for target=":psketti,mojojojo,crunk" target_matching="*"><Para><I>stuff</I></Para></for><Para>Yup.</Para></Document>' +); + + + + +print "# Wrapping up... one for the road...\n"; +ok 1; +print "# --- Done with ", __FILE__, " --- \n"; + |