4
BEGIN { plan tests => 14 };
6
#use Pod::Simple::Debug (6);
8
use Pod::Simple::DumpAsXML;
9
use Pod::Simple::XMLOutStream;
10
print "# Pod::Simple version $Pod::Simple::VERSION\n";
12
$Pod::Simple::XMLOutStream::ATTR_PAD = ' ';
13
$Pod::Simple::XMLOutStream::SORT_ATTRS = 1; # for predictably testable output
15
#sub e ($$) { Pod::Simple::DumpAsXML->_duo(@_) }
17
$Pod::Simple::XMLOutStream::ATTR_PAD = ' ';
18
$Pod::Simple::XMLOutStream::SORT_ATTRS = 1; # for predictably testable output
20
my $x = 'Pod::Simple::XMLOutStream';
24
print "# Testing exceptions being thrown...\n";
26
eval { $x->new->accept_directive('head1') };
27
if($@) { ok 1 } # print " # Good: exception thrown: $@\n" }
28
else { ok 0,1, 'No exception thrown!' }
30
eval { $x->new->accept_directive('I like pie') };
31
if($@) { ok 1 } # print " # Good: exception thrown: $@\n" }
32
else { ok 0,1, 'No exception thrown!' }
34
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
35
# print "Testing basic directive behavior...\n";
37
sub Pd { shift->accept_directive_as_data( 'freepies') }
38
sub Pv { shift->accept_directive_as_verbatim( 'freepies') }
39
sub Pp { shift->accept_directive_as_processed('freepies') }
41
ok( $x->_out( "\n=freepies Mmmmpie\n\n") => '/POD ERROR/' );
43
ok( $x->_out(\&Pp, "\n=freepies Mmmmpie\n\n"),
44
'<Document><freepies>Mmmmpie</freepies></Document>'
46
ok( $x->_out(\&Pv, "\n=freepies Mmmmpie\n\n"),
47
'<Document><freepies xml:space="preserve">Mmmmpie</freepies></Document>'
49
ok( $x->_out(\&Pd, "\n=freepies Mmmmpie\n\n"),
50
'<Document><freepies xml:space="preserve">Mmmmpie</freepies></Document>'
53
# print "Testing more complex directive behavior...\n";
55
ok( $x->_out(\&Pp, "\n=freepies Mmmmpie \n\tI<is good>! \n\n"),
56
'<Document><freepies>Mmmmpie <I>is good</I>!</freepies></Document>'
58
ok( $x->_out(\&Pd, "\n=freepies Mmmmpie \n\tI<is good>! \n\n"),
59
qq{<Document><freepies xml:space="preserve">Mmmmpie \n\tI<is good>! </freepies></Document>}
61
ok( $x->_out(\&Pv, "\n=freepies Mmmmpie \n\tI<is good>! \n\n"),
62
qq{<Document><freepies xml:space="preserve">Mmmmpie \n I<is good>! </freepies></Document>}
65
# print "Testing within larger documents...\n";
68
ok( $x->_out(\&Pp, "\n=head1 NAME\n\nPie Consortium -- me gustan pasteles\n\n=freepies Mmmmpie \n\tI<is good>! \n\nGoody!"),
69
'<Document><head1>NAME</head1><Para>Pie Consortium -- me gustan pasteles</Para><freepies>Mmmmpie <I>is good</I>!</freepies><Para>Goody!</Para></Document>'
71
ok( $x->_out(\&Pd, "\n=head1 NAME\n\nPie Consortium -- me gustan pasteles\n\n=freepies Mmmmpie \n\tI<is good>! \n\nGoody!"),
72
qq{<Document><head1>NAME</head1><Para>Pie Consortium -- me gustan pasteles</Para><freepies xml:space="preserve">Mmmmpie \n\tI<is good>! </freepies><Para>Goody!</Para></Document>}
74
ok( $x->_out(\&Pv, "\n=head1 NAME\n\nPie Consortium -- me gustan pasteles\n\n=freepies Mmmmpie \n\tI<is good>! \n\nGoody!"),
75
qq{<Document><head1>NAME</head1><Para>Pie Consortium -- me gustan pasteles</Para><freepies xml:space="preserve">Mmmmpie \n I<is good>! </freepies><Para>Goody!</Para></Document>}
79
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
81
print "# Wrapping up... one for the road...\n";
83
print "# --- Done with ", __FILE__, " --- \n";