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
|
# Testing accept_codes
BEGIN {
if($ENV{PERL_CORE}) {
chdir 't';
@INC = '../lib';
}
}
use strict;
use Test;
BEGIN { plan tests => 13 };
#use Pod::Simple::Debug (6);
ok 1;
use Pod::Simple::DumpAsXML;
use Pod::Simple::XMLOutStream;
print "# Pod::Simple version $Pod::Simple::VERSION\n";
sub e ($$) { Pod::Simple::DumpAsXML->_duo(@_) }
my $x = 'Pod::Simple::XMLOutStream';
sub accept_N { $_[0]->accept_codes('N') }
print "# Some sanity tests...\n";
ok( $x->_out( "=pod\n\nI like pie.\n"), # without acceptor
'<Document><Para>I like pie.</Para></Document>'
);
ok( $x->_out( \&accept_N, "=pod\n\nI like pie.\n"),
'<Document><Para>I like pie.</Para></Document>'
);
ok( $x->_out( "=pod\n\nB<foo\t>\n"), # without acceptor
'<Document><Para><B>foo </B></Para></Document>'
);
ok( $x->_out( \&accept_N, "=pod\n\nB<foo\t>\n"),
'<Document><Para><B>foo </B></Para></Document>'
);
print "# Some real tests...\n";
ok( $x->_out( \&accept_N, "=pod\n\nN<foo\t>\n"),
'<Document><Para><N>foo </N></Para></Document>'
);
ok( $x->_out( \&accept_N, "=pod\n\nB<N<foo\t>>\n"),
'<Document><Para><B><N>foo </N></B></Para></Document>'
);
ok( $x->_out( "=pod\n\nB<N<foo\t>>\n") # without the mutor
ne '<Document><Para><B><N>foo </N></B></Para></Document>'
# make sure it DOESN'T pass thru the N<...> when not accepted
);
ok( $x->_out( \&accept_N, "=pod\n\nB<pieF<zorch>N<foo>I<pling>>\n"),
'<Document><Para><B>pie<F>zorch</F><N>foo</N><I>pling</I></B></Para></Document>'
);
print "# Tests of nonacceptance...\n";
sub starts_with {
my($large, $small) = @_;
print("# supahstring is undef\n"),
return '' unless defined $large;
print("# supahstring $large is smaller than target-starter $small\n"),
return '' if length($large) < length($small);
if( substr($large, 0, length($small)) eq $small ) {
#print "# Supahstring $large\n# indeed starts with $small\n";
return 1;
} else {
print "# Supahstring $large\n# !starts w/ $small\n";
return '';
}
}
ok( starts_with( $x->_out( "=pod\n\nB<N<foo\t>>\n"), # without the mutor
'<Document><Para><B>foo </B></Para>'
# make sure it DOESN'T pass thru the N<...>, when not accepted
));
ok( starts_with( $x->_out( "=pod\n\nB<pieF<zorch>N<foo>I<pling>>\n"), # !mutor
'<Document><Para><B>pie<F>zorch</F>foo<I>pling</I></B></Para>'
# make sure it DOESN'T pass thru the N<...>, when not accepted
));
ok( starts_with( $x->_out( "=pod\n\nB<pieF<zorch>N<C<foo>>I<pling>>\n"), # !mutor
'<Document><Para><B>pie<F>zorch</F><C>foo</C><I>pling</I></B></Para>'
# make sure it DOESN'T pass thru the N<...>, when not accepted
));
print "# Wrapping up... one for the road...\n";
ok 1;
print "# --- Done with ", __FILE__, " --- \n";
|