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