1BEGIN { 2 if($ENV{PERL_CORE}) { 3 chdir 't'; 4 @INC = '../lib'; 5 } 6} 7 8use strict; 9use Test; 10BEGIN { plan tests => 14 }; 11 12#use Pod::Simple::Debug (6); 13 14use Pod::Simple::DumpAsXML; 15use Pod::Simple::XMLOutStream; 16print "# Pod::Simple version $Pod::Simple::VERSION\n"; 17 18$Pod::Simple::XMLOutStream::ATTR_PAD = ' '; 19$Pod::Simple::XMLOutStream::SORT_ATTRS = 1; # for predictably testable output 20 21#sub e ($$) { Pod::Simple::DumpAsXML->_duo(@_) } 22 23$Pod::Simple::XMLOutStream::ATTR_PAD = ' '; 24$Pod::Simple::XMLOutStream::SORT_ATTRS = 1; # for predictably testable output 25 26my $x = 'Pod::Simple::XMLOutStream'; 27 28ok 1; 29 30print "# Testing exceptions being thrown...\n"; 31 32eval { $x->new->accept_directive('head1') }; 33if($@) { ok 1 } # print " # Good: exception thrown: $@\n" } 34else { ok 0,1, 'No exception thrown!' } 35 36eval { $x->new->accept_directive('I like pie') }; 37if($@) { ok 1 } # print " # Good: exception thrown: $@\n" } 38else { ok 0,1, 'No exception thrown!' } 39 40#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 41# print "Testing basic directive behavior...\n"; 42 43sub Pd { shift->accept_directive_as_data( 'freepies') } 44sub Pv { shift->accept_directive_as_verbatim( 'freepies') } 45sub Pp { shift->accept_directive_as_processed('freepies') } 46 47ok( $x->_out( "\n=freepies Mmmmpie\n\n") => '/POD ERROR/' ); 48 49ok( $x->_out(\&Pp, "\n=freepies Mmmmpie\n\n"), 50 '<Document><freepies>Mmmmpie</freepies></Document>' 51); 52ok( $x->_out(\&Pv, "\n=freepies Mmmmpie\n\n"), 53 '<Document><freepies xml:space="preserve">Mmmmpie</freepies></Document>' 54); 55ok( $x->_out(\&Pd, "\n=freepies Mmmmpie\n\n"), 56 '<Document><freepies xml:space="preserve">Mmmmpie</freepies></Document>' 57); 58 59# print "Testing more complex directive behavior...\n"; 60 61ok( $x->_out(\&Pp, "\n=freepies Mmmmpie \n\tI<is good>! \n\n"), 62 '<Document><freepies>Mmmmpie <I>is good</I>!</freepies></Document>' 63); 64ok( $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>} 66); 67ok( $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>} 69); 70 71# print "Testing within larger documents...\n"; 72 73 74ok( $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>' 76); 77ok( $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>} 79); 80ok( $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>} 82); 83 84 85#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 86 87print "# Wrapping up... one for the road...\n"; 88ok 1; 89print "# --- Done with ", __FILE__, " --- \n"; 90 91 92__END__ 93 94