summaryrefslogtreecommitdiff
path: root/ext/Pod-Simple/t/cbacks.t
blob: 4c15c82f7ecb519fb1af27ba0eb05a8d5d551ac0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
BEGIN {
    if($ENV{PERL_CORE}) {
        chdir 't';
        @INC = '../lib';
    }
}

use strict;
use Test;
BEGIN { plan tests => 8 };

my $d;
#use Pod::Simple::Debug (\$d, 0);

ok 1;

use Pod::Simple::XMLOutStream;
use Pod::Simple::DumpAsXML;
use Pod::Simple::DumpAsText;

my @from = (
 'Pod::Simple::XMLOutStream'
  => '<Document><head1>I LIKE PIE</head1></Document>',
   
 'Pod::Simple::DumpAsXML'
  => "<Document>\n  <head1>\n    I LIKE PIE\n  </head1>\n</Document>\n",
   
 'Pod::Simple::DumpAsText'
  => "++Document\n  ++head1\n    * \"I LIKE PIE\"\n  --head1\n--Document\n",

);


# Might as well test all the classes...
while(@from) {
  my($x => $expected) = splice(@from, 0,2);
  my $more = '';
  print "#Testing via class $x, version ", $x->VERSION(), "\n";
  my $p = $x->new;
  my($got, $exp);
  ok scalar($got = $x->_out(
    # Mutor:
    sub {
     $_[0]->code_handler(sub { $more .= $_[1] . ":" . $_[0] . "\n"       } );
     $_[0]->cut_handler( sub { $more .= "~" . $_[1] . ":" .  $_[0]. "\n" } );
    } => join "\n",
    "",
    "\t# This is handy...",
    "=head1 I  LIKE   PIE",
    "",
    "=cut",
    "use Test::Harness;",
    "runtests(sort glob 't/*.t');",
    "",
    "",
   ))
    => scalar($exp = $expected);
  ;
  unless($got eq $exp) {
    print '# Got vs exp:\n# ', Pod::Simple::BlackBox::pretty($got),
     "\n# ",Pod::Simple::BlackBox::pretty($exp),"\n";
  }
  
  ok scalar($got = $more), scalar($exp = join "\n" =>
   "1:",
   "2:\t# This is handy...",
   "~5:=cut",
   "6:use Test::Harness;",
   "7:runtests(sort glob 't/*.t');",
   "8:",
   "",
  );
  unless($got eq $exp) {
   print '# Got vs exp:\n# ', Pod::Simple::BlackBox::pretty($got),
    "\n# ",Pod::Simple::BlackBox::pretty($exp),"\n";
  }
}


print "# Wrapping up... one for the road...\n";
ok 1;
print "# --- Done with ", __FILE__, " --- \n";