File: cbacks.t

package info (click to toggle)
perl 5.42.0-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 128,392 kB
  • sloc: perl: 534,963; ansic: 240,563; sh: 72,042; pascal: 6,934; xml: 2,428; yacc: 1,360; makefile: 1,197; cpp: 208; lisp: 1
file content (84 lines) | stat: -rw-r--r-- 2,123 bytes parent folder | download | duplicates (3)
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
84
use strict;
use warnings;
use Test::More tests => 6;

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

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);
  is scalar($got = $x->_out(
    # Mutor:
    sub {
     $_[0]->code_handler(sub { $more .= $_[1] . ":" . $_[0] . "\n"       } );
     $_[0]->cut_handler( sub { $more .= "~" . $_[1] . ":" .  $_[0]. "\n" } );
     $_[0]->pod_handler( sub { $more .= "+" . $_[1] . ":" .  $_[0]. "\n" } );
     $_[0]->whiteline_handler(
                         sub { $more .= "=" . $_[1] . ":" .  $_[0]. "\n" } );
    } => join "\n",
    " ", # space outside pod
    "\t# This is handy...",
    "=pod text",
    "\t", # tab inside pod
    "=cut more text",
    "\t", # tab outside pod
    "=pod",
    " \t ", # spaces and tabs inside pod
    "=head1 I  LIKE   PIE",
    " ", # space inside pod
    "=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";
  }

  is scalar($got = $more), scalar($exp = join "\n" =>
   "1: ",
   "2:\t# This is handy...",
   "=4:\t",
   "+3:=pod text",
   "~5:=cut more text",
   "6:\t",
   "=8: \t ",
   "+7:=pod",
   "=10: ",
   "~11:=cut",
   "12:use Test::Harness;",
   "13:runtests(sort glob 't/*.t');",
   "14:",
   "",
  );
  unless($got eq $exp) {
   print '# Got vs exp:\n# ', Pod::Simple::BlackBox::pretty($got),
    "\n# ",Pod::Simple::BlackBox::pretty($exp),"\n";
  }
}