11 BEGIN { plan tests => 13 };
13 #use Pod::Simple::Debug (6);
17 use Pod::Simple::DumpAsXML;
18 use Pod::Simple::XMLOutStream;
19 print "# Pod::Simple version $Pod::Simple::VERSION\n";
20 sub e ($$) { Pod::Simple::DumpAsXML->_duo(@_) }
22 my $x = 'Pod::Simple::XMLOutStream';
23 sub accept_N { $_[0]->accept_codes('N') }
25 print "# Some sanity tests...\n";
26 ok( $x->_out( "=pod\n\nI like pie.\n"), # without acceptor
27 '<Document><Para>I like pie.</Para></Document>'
29 ok( $x->_out( \&accept_N, "=pod\n\nI like pie.\n"),
30 '<Document><Para>I like pie.</Para></Document>'
32 ok( $x->_out( "=pod\n\nB<foo\t>\n"), # without acceptor
33 '<Document><Para><B>foo </B></Para></Document>'
35 ok( $x->_out( \&accept_N, "=pod\n\nB<foo\t>\n"),
36 '<Document><Para><B>foo </B></Para></Document>'
39 print "# Some real tests...\n";
41 ok( $x->_out( \&accept_N, "=pod\n\nN<foo\t>\n"),
42 '<Document><Para><N>foo </N></Para></Document>'
44 ok( $x->_out( \&accept_N, "=pod\n\nB<N<foo\t>>\n"),
45 '<Document><Para><B><N>foo </N></B></Para></Document>'
47 ok( $x->_out( "=pod\n\nB<N<foo\t>>\n") # without the mutor
48 ne '<Document><Para><B><N>foo </N></B></Para></Document>'
49 # make sure it DOESN'T pass thru the N<...> when not accepted
51 ok( $x->_out( \&accept_N, "=pod\n\nB<pieF<zorch>N<foo>I<pling>>\n"),
52 '<Document><Para><B>pie<F>zorch</F><N>foo</N><I>pling</I></B></Para></Document>'
55 print "# Tests of nonacceptance...\n";
58 my($large, $small) = @_;
59 print("# supahstring is undef\n"),
60 return '' unless defined $large;
61 print("# supahstring $large is smaller than target-starter $small\n"),
62 return '' if length($large) < length($small);
63 if( substr($large, 0, length($small)) eq $small ) {
64 #print "# Supahstring $large\n# indeed starts with $small\n";
67 print "# Supahstring $large\n# !starts w/ $small\n";
73 ok( starts_with( $x->_out( "=pod\n\nB<N<foo\t>>\n"), # without the mutor
74 '<Document><Para><B>foo </B></Para>'
75 # make sure it DOESN'T pass thru the N<...>, when not accepted
78 ok( starts_with( $x->_out( "=pod\n\nB<pieF<zorch>N<foo>I<pling>>\n"), # !mutor
79 '<Document><Para><B>pie<F>zorch</F>foo<I>pling</I></B></Para>'
80 # make sure it DOESN'T pass thru the N<...>, when not accepted
83 ok( starts_with( $x->_out( "=pod\n\nB<pieF<zorch>N<C<foo>>I<pling>>\n"), # !mutor
84 '<Document><Para><B>pie<F>zorch</F><C>foo</C><I>pling</I></B></Para>'
85 # make sure it DOESN'T pass thru the N<...>, when not accepted
92 print "# Wrapping up... one for the road...\n";
94 print "# --- Done with ", __FILE__, " --- \n";