1BEGIN { 2 if($ENV{PERL_CORE}) { 3 chdir 't'; 4 @INC = '../lib'; 5 } 6} 7 8use strict; 9use Test; 10BEGIN { plan tests => 8 }; 11 12my $d; 13#use Pod::Simple::Debug (\$d, 0); 14 15ok 1; 16 17use Pod::Simple::XMLOutStream; 18use Pod::Simple::DumpAsXML; 19use Pod::Simple::DumpAsText; 20 21my @from = ( 22 'Pod::Simple::XMLOutStream' 23 => '<Document><head1>I LIKE PIE</head1></Document>', 24 25 'Pod::Simple::DumpAsXML' 26 => "<Document>\n <head1>\n I LIKE PIE\n </head1>\n</Document>\n", 27 28 'Pod::Simple::DumpAsText' 29 => "++Document\n ++head1\n * \"I LIKE PIE\"\n --head1\n--Document\n", 30 31); 32 33 34# Might as well test all the classes... 35while(@from) { 36 my($x => $expected) = splice(@from, 0,2); 37 my $more = ''; 38 print "#Testing via class $x, version ", $x->VERSION(), "\n"; 39 my $p = $x->new; 40 my($got, $exp); 41 ok scalar($got = $x->_out( 42 # Mutor: 43 sub { 44 $_[0]->code_handler(sub { $more .= $_[1] . ":" . $_[0] . "\n" } ); 45 $_[0]->cut_handler( sub { $more .= "~" . $_[1] . ":" . $_[0]. "\n" } ); 46 $_[0]->pod_handler( sub { $more .= "+" . $_[1] . ":" . $_[0]. "\n" } ); 47 $_[0]->whiteline_handler( 48 sub { $more .= "=" . $_[1] . ":" . $_[0]. "\n" } ); 49 } => join "\n", 50 " ", # space outside pod 51 "\t# This is handy...", 52 "=pod text", 53 "\t", # tab inside pod 54 "=cut more text", 55 "\t", # tab outside pod 56 "=pod", 57 " \t ", # spaces and tabs inside pod 58 "=head1 I LIKE PIE", 59 " ", # space inside pod 60 "=cut", 61 "use Test::Harness;", 62 "runtests(sort glob 't/*.t');", 63 "", 64 "", 65 )) 66 => scalar($exp = $expected); 67 ; 68 unless($got eq $exp) { 69 print '# Got vs exp:\n# ', Pod::Simple::BlackBox::pretty($got), 70 "\n# ",Pod::Simple::BlackBox::pretty($exp),"\n"; 71 } 72 73 ok scalar($got = $more), scalar($exp = join "\n" => 74 "1: ", 75 "2:\t# This is handy...", 76 "=4:\t", 77 "+3:=pod text", 78 "~5:=cut more text", 79 "6:\t", 80 "=8: \t ", 81 "+7:=pod", 82 "=10: ", 83 "~11:=cut", 84 "12:use Test::Harness;", 85 "13:runtests(sort glob 't/*.t');", 86 "14:", 87 "", 88 ); 89 unless($got eq $exp) { 90 print '# Got vs exp:\n# ', Pod::Simple::BlackBox::pretty($got), 91 "\n# ",Pod::Simple::BlackBox::pretty($exp),"\n"; 92 } 93} 94 95 96print "# Wrapping up... one for the road...\n"; 97ok 1; 98print "# --- Done with ", __FILE__, " --- \n"; 99 100