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