10 BEGIN { plan tests => 14 };
12 #use Pod::Simple::Debug (6);
14 use Pod::Simple::DumpAsXML;
15 use Pod::Simple::XMLOutStream;
16 print "# Pod::Simple version $Pod::Simple::VERSION\n";
18 $Pod::Simple::XMLOutStream::ATTR_PAD = ' ';
19 $Pod::Simple::XMLOutStream::SORT_ATTRS = 1; # for predictably testable output
21 #sub e ($$) { Pod::Simple::DumpAsXML->_duo(@_) }
23 $Pod::Simple::XMLOutStream::ATTR_PAD = ' ';
24 $Pod::Simple::XMLOutStream::SORT_ATTRS = 1; # for predictably testable output
26 my $x = 'Pod::Simple::XMLOutStream';
30 print "# Testing exceptions being thrown...\n";
32 eval { $x->new->accept_directive('head1') };
33 if($@) { ok 1 } # print " # Good: exception thrown: $@\n" }
34 else { ok 0,1, 'No exception thrown!' }
36 eval { $x->new->accept_directive('I like pie') };
37 if($@) { ok 1 } # print " # Good: exception thrown: $@\n" }
38 else { ok 0,1, 'No exception thrown!' }
40 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
41 # print "Testing basic directive behavior...\n";
43 sub Pd { shift->accept_directive_as_data( 'freepies') }
44 sub Pv { shift->accept_directive_as_verbatim( 'freepies') }
45 sub Pp { shift->accept_directive_as_processed('freepies') }
47 ok( $x->_out( "\n=freepies Mmmmpie\n\n") => '/POD ERROR/' );
49 ok( $x->_out(\&Pp, "\n=freepies Mmmmpie\n\n"),
50 '<Document><freepies>Mmmmpie</freepies></Document>'
52 ok( $x->_out(\&Pv, "\n=freepies Mmmmpie\n\n"),
53 '<Document><freepies xml:space="preserve">Mmmmpie</freepies></Document>'
55 ok( $x->_out(\&Pd, "\n=freepies Mmmmpie\n\n"),
56 '<Document><freepies xml:space="preserve">Mmmmpie</freepies></Document>'
59 # print "Testing more complex directive behavior...\n";
61 ok( $x->_out(\&Pp, "\n=freepies Mmmmpie \n\tI<is good>! \n\n"),
62 '<Document><freepies>Mmmmpie <I>is good</I>!</freepies></Document>'
64 ok( $x->_out(\&Pd, "\n=freepies Mmmmpie \n\tI<is good>! \n\n"),
65 qq{<Document><freepies xml:space="preserve">Mmmmpie \n\tI<is good>! </freepies></Document>}
67 ok( $x->_out(\&Pv, "\n=freepies Mmmmpie \n\tI<is good>! \n\n"),
68 qq{<Document><freepies xml:space="preserve">Mmmmpie \n I<is good>! </freepies></Document>}
71 # print "Testing within larger documents...\n";
74 ok( $x->_out(\&Pp, "\n=head1 NAME\n\nPie Consortium -- me gustan pasteles\n\n=freepies Mmmmpie \n\tI<is good>! \n\nGoody!"),
75 '<Document><head1>NAME</head1><Para>Pie Consortium -- me gustan pasteles</Para><freepies>Mmmmpie <I>is good</I>!</freepies><Para>Goody!</Para></Document>'
77 ok( $x->_out(\&Pd, "\n=head1 NAME\n\nPie Consortium -- me gustan pasteles\n\n=freepies Mmmmpie \n\tI<is good>! \n\nGoody!"),
78 qq{<Document><head1>NAME</head1><Para>Pie Consortium -- me gustan pasteles</Para><freepies xml:space="preserve">Mmmmpie \n\tI<is good>! </freepies><Para>Goody!</Para></Document>}
80 ok( $x->_out(\&Pv, "\n=head1 NAME\n\nPie Consortium -- me gustan pasteles\n\n=freepies Mmmmpie \n\tI<is good>! \n\nGoody!"),
81 qq{<Document><head1>NAME</head1><Para>Pie Consortium -- me gustan pasteles</Para><freepies xml:space="preserve">Mmmmpie \n I<is good>! </freepies><Para>Goody!</Para></Document>}
85 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
87 print "# Wrapping up... one for the road...\n";
89 print "# --- Done with ", __FILE__, " --- \n";