File: accept05.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 (133 lines) | stat: -rw-r--r-- 4,664 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# Testing extend and accept_codes
use strict;
use warnings;
use Test::More tests => 22;

#use Pod::Simple::Debug (2);

use Pod::Simple::DumpAsXML;
use Pod::Simple::XMLOutStream;
print "# Pod::Simple version $Pod::Simple::VERSION\n";

BEGIN {
  require FindBin;
  unshift @INC, $FindBin::Bin . '/lib';
}
use helpers;

my $x = 'Pod::Simple::XMLOutStream';
sub accept_Q    { $_[0]->accept_codes('Q') }
sub accept_prok { $_[0]->accept_codes('prok') }
sub accept_zing_prok { $_[0]->accept_codes('zing:prok') }
sub accept_zing_superprok { $_[0]->accept_codes('z.i_ng:Prok-12') }
sub accept_zing_superduperprok {
  $_[0]->accept_codes('A');
  $_[0]->accept_codes('z.i_ng:Prok-12');
}


#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


print "# Some sanity tests...\n";
is( $x->_out( "=pod\n\nI like pie.\n"),
  '<Document><Para>I like pie.</Para></Document>'
);
is( $x->_out( "=extend N C Y,W\n\nI like pie.\n"),
  '<Document><Para>I like pie.</Para></Document>'
);
is( $x->_out( "=extend N C,F Y,W\n\nI like pie.\n"),
  '<Document><Para>I like pie.</Para></Document>'
);
is( $x->_out( "=extend N C,F,I Y,W\n\nI like pie.\n"),
  '<Document><Para>I like pie.</Para></Document>'
);


#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


print "## OK, actually trying to use an extended code...\n";

print "# extending but not accepted (so hitting fallback)\n";

is( $x->_out( "=extend N B Y,W\n\nI N<like> pie.\n"),
  '<Document><Para>I <B>like</B> pie.</Para></Document>'
);
is( $x->_out( "=extend N B,I Y,W\n\nI N<like> pie.\n"),
  '<Document><Para>I <B><I>like</I></B> pie.</Para></Document>'
);
is( $x->_out( "=extend N C,B,I Y,W\n\nI N<like> pie.\n"),
  '<Document><Para>I <C><B><I>like</I></B></C> pie.</Para></Document>'
);



print "# extending to one-letter accepted (not hitting fallback)\n";

is( $x->_out( \&accept_Q, "=extend N B Y,Q,A,bzroch\n\nI N<like> pie.\n"),
  '<Document><Para>I <Q>like</Q> pie.</Para></Document>'
);
is( $x->_out( \&accept_Q, "=extend N B,I Y,Q,A,bzroch\n\nI N<like> pie.\n"),
  '<Document><Para>I <Q>like</Q> pie.</Para></Document>'
);
is( $x->_out( \&accept_Q, "=extend N C,B,I Y,Q,A,bzroch\n\nI N<like> pie.\n"),
  '<Document><Para>I <Q>like</Q> pie.</Para></Document>'
);



print "# extending to many-letter accepted (not hitting fallback)\n";

is( $x->_out( \&accept_prok, "=extend N B Y,prok,A,bzroch\n\nI N<like> pie.\n"),
  '<Document><Para>I <prok>like</prok> pie.</Para></Document>'
);
is( $x->_out( \&accept_prok, "=extend N B,I Y,prok,A,bzroch\n\nI N<like> pie.\n"),
  '<Document><Para>I <prok>like</prok> pie.</Para></Document>'
);
is( $x->_out( \&accept_prok, "=extend N C,B,I Y,prok,A,bzroch\n\nI N<like> pie.\n"),
  '<Document><Para>I <prok>like</prok> pie.</Para></Document>'
);



print "# extending to :-containing, many-letter accepted (not hitting fallback)\n";

is( $x->_out( \&accept_zing_prok, "=extend N B Y,zing:prok,A,bzroch\n\nI N<like> pie.\n"),
  '<Document><Para>I <zing:prok>like</zing:prok> pie.</Para></Document>'
);
is( $x->_out( \&accept_zing_prok, "=extend N B,I Y,zing:prok,A,bzroch\n\nI N<like> pie.\n"),
  '<Document><Para>I <zing:prok>like</zing:prok> pie.</Para></Document>'
);
is( $x->_out( \&accept_zing_prok, "=extend N C,B,I Y,zing:prok,A,bzroch\n\nI N<like> pie.\n"),
  '<Document><Para>I <zing:prok>like</zing:prok> pie.</Para></Document>'
);




print "# extending to _:-0-9-containing, many-letter accepted (not hitting fallback)\n";

is( $x->_out( \&accept_zing_superprok, "=extend N B Y,z.i_ng:Prok-12,A,bzroch\n\nI N<like> pie.\n"),
  '<Document><Para>I <z.i_ng:Prok-12>like</z.i_ng:Prok-12> pie.</Para></Document>'
);
is( $x->_out( \&accept_zing_superprok, "=extend N B,I Y,z.i_ng:Prok-12,A,bzroch\n\nI N<like> pie.\n"),
  '<Document><Para>I <z.i_ng:Prok-12>like</z.i_ng:Prok-12> pie.</Para></Document>'
);
is( $x->_out( \&accept_zing_superprok, "=extend N C,B,I Y,z.i_ng:Prok-12,A,bzroch\n\nI N<like> pie.\n"),
  '<Document><Para>I <z.i_ng:Prok-12>like</z.i_ng:Prok-12> pie.</Para></Document>'
);



print "#\n# Testing acceptance order\n";

is( $x->_out( \&accept_zing_superduperprok, "=extend N B Y,z.i_ng:Prok-12,A,bzroch\n\nI N<like> pie.\n"),
  '<Document><Para>I <z.i_ng:Prok-12>like</z.i_ng:Prok-12> pie.</Para></Document>'
);
is( $x->_out( \&accept_zing_superduperprok, "=extend N B,I Y,z.i_ng:Prok-12,A,bzroch\n\nI N<like> pie.\n"),
  '<Document><Para>I <z.i_ng:Prok-12>like</z.i_ng:Prok-12> pie.</Para></Document>'
);
is( $x->_out( \&accept_zing_superduperprok, "=extend N C,B,I Y,z.i_ng:Prok-12,A,bzroch\n\nI N<like> pie.\n"),
  '<Document><Para>I <z.i_ng:Prok-12>like</z.i_ng:Prok-12> pie.</Para></Document>'
);