1use strict; 2use warnings; 3use Test::More tests => 12; 4 5#use Pod::Simple::Debug (6); 6 7use Pod::Simple::DumpAsXML; 8use Pod::Simple::XMLOutStream; 9 10$Pod::Simple::XMLOutStream::ATTR_PAD = ' '; 11$Pod::Simple::XMLOutStream::SORT_ATTRS = 1; # for predictably testable output 12 13$Pod::Simple::XMLOutStream::ATTR_PAD = ' '; 14$Pod::Simple::XMLOutStream::SORT_ATTRS = 1; # for predictably testable output 15 16my $x = 'Pod::Simple::XMLOutStream'; 17 18print "# Testing exceptions being thrown...\n"; 19 20eval { $x->new->accept_directive('head1') }; 21if($@) { ok 1 } # print " # Good: exception thrown: $@\n" } 22else { ok 0, 'No exception thrown!' } 23 24eval { $x->new->accept_directive('I like pie') }; 25if($@) { ok 1 } # print " # Good: exception thrown: $@\n" } 26else { ok 0, 'No exception thrown!' } 27 28#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 29# print "Testing basic directive behavior...\n"; 30 31sub Pd { shift->accept_directive_as_data( 'freepies') } 32sub Pv { shift->accept_directive_as_verbatim( 'freepies') } 33sub Pp { shift->accept_directive_as_processed('freepies') } 34 35like( $x->_out( "\n=freepies Mmmmpie\n\n") => qr/POD ERROR/ ); 36 37is( $x->_out(\&Pp, "\n=freepies Mmmmpie\n\n"), 38 '<Document><freepies>Mmmmpie</freepies></Document>' 39); 40is( $x->_out(\&Pv, "\n=freepies Mmmmpie\n\n"), 41 '<Document><freepies xml:space="preserve">Mmmmpie</freepies></Document>' 42); 43is( $x->_out(\&Pd, "\n=freepies Mmmmpie\n\n"), 44 '<Document><freepies xml:space="preserve">Mmmmpie</freepies></Document>' 45); 46 47# print "Testing more complex directive behavior...\n"; 48 49is( $x->_out(\&Pp, "\n=freepies Mmmmpie \n\tI<is good>! \n\n"), 50 '<Document><freepies>Mmmmpie <I>is good</I>!</freepies></Document>' 51); 52is( $x->_out(\&Pd, "\n=freepies Mmmmpie \n\tI<is good>! \n\n"), 53 qq{<Document><freepies xml:space="preserve">Mmmmpie \n\tI<is good>! </freepies></Document>} 54); 55is( $x->_out(\&Pv, "\n=freepies Mmmmpie \n\tI<is good>! \n\n"), 56 qq{<Document><freepies xml:space="preserve">Mmmmpie \n I<is good>! </freepies></Document>} 57); 58 59# print "Testing within larger documents...\n"; 60 61 62is( $x->_out(\&Pp, "\n=head1 NAME\n\nPie Consortium -- me gustan pasteles\n\n=freepies Mmmmpie \n\tI<is good>! \n\nGoody!"), 63 '<Document><head1>NAME</head1><Para>Pie Consortium -- me gustan pasteles</Para><freepies>Mmmmpie <I>is good</I>!</freepies><Para>Goody!</Para></Document>' 64); 65is( $x->_out(\&Pd, "\n=head1 NAME\n\nPie Consortium -- me gustan pasteles\n\n=freepies Mmmmpie \n\tI<is good>! \n\nGoody!"), 66 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>} 67); 68is( $x->_out(\&Pv, "\n=head1 NAME\n\nPie Consortium -- me gustan pasteles\n\n=freepies Mmmmpie \n\tI<is good>! \n\nGoody!"), 69 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>} 70); 71