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