Debian lenny version packages
[pkg-perl] / deb-src / libpod-simple-perl / libpod-simple-perl-3.07 / t / ac_d.t
1 BEGIN {
2     if($ENV{PERL_CORE}) {
3         chdir 't';
4         @INC = '../lib';
5     }
6 }
7
8 use strict;
9 use Test;
10 BEGIN { plan tests => 14 };
11
12 #use Pod::Simple::Debug (6);
13
14 use Pod::Simple::DumpAsXML;
15 use Pod::Simple::XMLOutStream;
16 print "# Pod::Simple version $Pod::Simple::VERSION\n";
17
18 $Pod::Simple::XMLOutStream::ATTR_PAD   = ' ';
19 $Pod::Simple::XMLOutStream::SORT_ATTRS = 1; # for predictably testable output
20
21 #sub e ($$) { Pod::Simple::DumpAsXML->_duo(@_) }
22
23 $Pod::Simple::XMLOutStream::ATTR_PAD   = ' ';
24 $Pod::Simple::XMLOutStream::SORT_ATTRS = 1; # for predictably testable output
25
26 my $x = 'Pod::Simple::XMLOutStream';
27
28 ok 1;
29
30 print "# Testing exceptions being thrown...\n";
31
32 eval { $x->new->accept_directive('head1') };
33 if($@) { ok 1 } # print " # Good: exception thrown: $@\n" }
34 else   { ok 0,1, 'No exception thrown!' }
35
36 eval { $x->new->accept_directive('I like pie') };
37 if($@) { ok 1 } # print " # Good: exception thrown: $@\n" }
38 else   { ok 0,1, 'No exception thrown!' }
39
40 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
41 # print "Testing basic directive behavior...\n";
42
43 sub Pd { shift->accept_directive_as_data(     'freepies') }
44 sub Pv { shift->accept_directive_as_verbatim( 'freepies') }
45 sub Pp { shift->accept_directive_as_processed('freepies') }
46
47 ok( $x->_out( "\n=freepies Mmmmpie\n\n") => '/POD ERROR/' );
48
49 ok( $x->_out(\&Pp, "\n=freepies Mmmmpie\n\n"),
50   '<Document><freepies>Mmmmpie</freepies></Document>'
51 );
52 ok( $x->_out(\&Pv, "\n=freepies Mmmmpie\n\n"),
53   '<Document><freepies xml:space="preserve">Mmmmpie</freepies></Document>'
54 );
55 ok( $x->_out(\&Pd, "\n=freepies Mmmmpie\n\n"),
56   '<Document><freepies xml:space="preserve">Mmmmpie</freepies></Document>'
57 );
58
59 # print "Testing more complex directive behavior...\n";
60
61 ok( $x->_out(\&Pp, "\n=freepies Mmmmpie \n\tI<is good>!  \n\n"),
62   '<Document><freepies>Mmmmpie <I>is good</I>!</freepies></Document>'
63 );
64 ok( $x->_out(\&Pd, "\n=freepies Mmmmpie \n\tI<is good>!  \n\n"),
65  qq{<Document><freepies xml:space="preserve">Mmmmpie \n\tI&#60;is good&#62;!  </freepies></Document>}
66 );
67 ok( $x->_out(\&Pv, "\n=freepies Mmmmpie \n\tI<is good>!  \n\n"),
68  qq{<Document><freepies xml:space="preserve">Mmmmpie \n        I&#60;is good&#62;!  </freepies></Document>}
69 );
70
71 # print "Testing within larger documents...\n";
72
73
74 ok( $x->_out(\&Pp, "\n=head1 NAME\n\nPie Consortium -- me gustan pasteles\n\n=freepies Mmmmpie \n\tI<is good>!  \n\nGoody!"),
75   '<Document><head1>NAME</head1><Para>Pie Consortium -- me gustan pasteles</Para><freepies>Mmmmpie <I>is good</I>!</freepies><Para>Goody!</Para></Document>'
76 );
77 ok( $x->_out(\&Pd, "\n=head1 NAME\n\nPie Consortium -- me gustan pasteles\n\n=freepies Mmmmpie \n\tI<is good>!  \n\nGoody!"),
78  qq{<Document><head1>NAME</head1><Para>Pie Consortium -- me gustan pasteles</Para><freepies xml:space="preserve">Mmmmpie \n\tI&#60;is good&#62;!  </freepies><Para>Goody!</Para></Document>}
79 );
80 ok( $x->_out(\&Pv, "\n=head1 NAME\n\nPie Consortium -- me gustan pasteles\n\n=freepies Mmmmpie \n\tI<is good>!  \n\nGoody!"),
81  qq{<Document><head1>NAME</head1><Para>Pie Consortium -- me gustan pasteles</Para><freepies xml:space="preserve">Mmmmpie \n        I&#60;is good&#62;!  </freepies><Para>Goody!</Para></Document>}
82 );
83
84
85 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
86
87 print "# Wrapping up... one for the road...\n";
88 ok 1;
89 print "# --- Done with ", __FILE__, " --- \n";
90
91
92 __END__
93