4
BEGIN { plan tests => 13 };
6
#use Pod::Simple::Debug (6);
10
use Pod::Simple::DumpAsXML;
11
use Pod::Simple::XMLOutStream;
12
print "# Pod::Simple version $Pod::Simple::VERSION\n";
13
sub e ($$) { Pod::Simple::DumpAsXML->_duo(@_) }
15
my $x = 'Pod::Simple::XMLOutStream';
16
sub accept_N { $_[0]->accept_codes('N') }
18
print "# Some sanity tests...\n";
19
ok( $x->_out( "=pod\n\nI like pie.\n"), # without acceptor
20
'<Document><Para>I like pie.</Para></Document>'
22
ok( $x->_out( \&accept_N, "=pod\n\nI like pie.\n"),
23
'<Document><Para>I like pie.</Para></Document>'
25
ok( $x->_out( "=pod\n\nB<foo\t>\n"), # without acceptor
26
'<Document><Para><B>foo </B></Para></Document>'
28
ok( $x->_out( \&accept_N, "=pod\n\nB<foo\t>\n"),
29
'<Document><Para><B>foo </B></Para></Document>'
32
print "# Some real tests...\n";
34
ok( $x->_out( \&accept_N, "=pod\n\nN<foo\t>\n"),
35
'<Document><Para><N>foo </N></Para></Document>'
37
ok( $x->_out( \&accept_N, "=pod\n\nB<N<foo\t>>\n"),
38
'<Document><Para><B><N>foo </N></B></Para></Document>'
40
ok( $x->_out( "=pod\n\nB<N<foo\t>>\n") # without the mutor
41
ne '<Document><Para><B><N>foo </N></B></Para></Document>'
42
# make sure it DOESN'T pass thru the N<...> when not accepted
44
ok( $x->_out( \&accept_N, "=pod\n\nB<pieF<zorch>N<foo>I<pling>>\n"),
45
'<Document><Para><B>pie<F>zorch</F><N>foo</N><I>pling</I></B></Para></Document>'
48
print "# Tests of nonacceptance...\n";
51
my($large, $small) = @_;
52
print("# supahstring is undef\n"),
53
return '' unless defined $large;
54
print("# supahstring $large is smaller than target-starter $small\n"),
55
return '' if length($large) < length($small);
56
if( substr($large, 0, length($small)) eq $small ) {
57
#print "# Supahstring $large\n# indeed starts with $small\n";
60
print "# Supahstring $large\n# !starts w/ $small\n";
66
ok( starts_with( $x->_out( "=pod\n\nB<N<foo\t>>\n"), # without the mutor
67
'<Document><Para><B>foo </B></Para>'
68
# make sure it DOESN'T pass thru the N<...>, when not accepted
71
ok( starts_with( $x->_out( "=pod\n\nB<pieF<zorch>N<foo>I<pling>>\n"), # !mutor
72
'<Document><Para><B>pie<F>zorch</F>foo<I>pling</I></B></Para>'
73
# make sure it DOESN'T pass thru the N<...>, when not accepted
76
ok( starts_with( $x->_out( "=pod\n\nB<pieF<zorch>N<C<foo>>I<pling>>\n"), # !mutor
77
'<Document><Para><B>pie<F>zorch</F><C>foo</C><I>pling</I></B></Para>'
78
# make sure it DOESN'T pass thru the N<...>, when not accepted
85
print "# Wrapping up... one for the road...\n";
87
print "# --- Done with ", __FILE__, " --- \n";