~ubuntu-branches/ubuntu/vivid/horae/vivid

« back to all changes in this revision

Viewing changes to 0CPAN/Pod-Simple-3.03/t/ac_c_simple.t

  • Committer: Bazaar Package Importer
  • Author(s): Carlo Segre
  • Date: 2006-12-26 11:54:29 UTC
  • Revision ID: james.westby@ubuntu.com-20061226115429-kjuhf6h9w6bohlwj
Tags: upstream-063
ImportĀ upstreamĀ versionĀ 063

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
use strict;
 
3
use Test;
 
4
BEGIN { plan tests => 13 };
 
5
 
 
6
#use Pod::Simple::Debug (6);
 
7
 
 
8
ok 1;
 
9
 
 
10
use Pod::Simple::DumpAsXML;
 
11
use Pod::Simple::XMLOutStream;
 
12
print "# Pod::Simple version $Pod::Simple::VERSION\n";
 
13
sub e ($$) { Pod::Simple::DumpAsXML->_duo(@_) }
 
14
 
 
15
my $x = 'Pod::Simple::XMLOutStream';
 
16
sub accept_N { $_[0]->accept_codes('N') }
 
17
 
 
18
print "# Some sanity tests...\n";
 
19
ok( $x->_out( "=pod\n\nI like pie.\n"), # without acceptor
 
20
  '<Document><Para>I like pie.</Para></Document>'
 
21
);
 
22
ok( $x->_out( \&accept_N, "=pod\n\nI like pie.\n"),
 
23
  '<Document><Para>I like pie.</Para></Document>'
 
24
);
 
25
ok( $x->_out( "=pod\n\nB<foo\t>\n"), # without acceptor
 
26
  '<Document><Para><B>foo </B></Para></Document>'
 
27
);
 
28
ok( $x->_out( \&accept_N,  "=pod\n\nB<foo\t>\n"),
 
29
  '<Document><Para><B>foo </B></Para></Document>'
 
30
);
 
31
 
 
32
print "# Some real tests...\n";
 
33
 
 
34
ok( $x->_out( \&accept_N,  "=pod\n\nN<foo\t>\n"),
 
35
  '<Document><Para><N>foo </N></Para></Document>'
 
36
);
 
37
ok( $x->_out( \&accept_N,  "=pod\n\nB<N<foo\t>>\n"),
 
38
  '<Document><Para><B><N>foo </N></B></Para></Document>'
 
39
);
 
40
ok( $x->_out( "=pod\n\nB<N<foo\t>>\n") # without the mutor
 
41
  ne '<Document><Para><B><N>foo </N></B></Para></Document>'
 
42
  # make sure it DOESN'T pass thru the N<...> when not accepted
 
43
);
 
44
ok( $x->_out( \&accept_N,  "=pod\n\nB<pieF<zorch>N<foo>I<pling>>\n"),
 
45
  '<Document><Para><B>pie<F>zorch</F><N>foo</N><I>pling</I></B></Para></Document>'
 
46
);
 
47
 
 
48
print "# Tests of nonacceptance...\n";
 
49
 
 
50
sub starts_with {
 
51
  my($large, $small) = @_;
 
52
  print("# supahstring is undef\n"),
 
53
   return '' unless defined $large;
 
54
  print("# supahstring $large is smaller than target-starter $small\n"),
 
55
   return '' if length($large) < length($small);
 
56
  if( substr($large, 0, length($small)) eq $small ) {
 
57
    #print "# Supahstring $large\n#  indeed starts with $small\n";
 
58
    return 1;
 
59
  } else {
 
60
    print "# Supahstring $large\n#  !starts w/ $small\n";
 
61
    return '';
 
62
  }
 
63
}
 
64
 
 
65
 
 
66
ok( starts_with( $x->_out( "=pod\n\nB<N<foo\t>>\n"), # without the mutor
 
67
  '<Document><Para><B>foo </B></Para>'
 
68
  # make sure it DOESN'T pass thru the N<...>, when not accepted
 
69
));
 
70
 
 
71
ok( starts_with( $x->_out( "=pod\n\nB<pieF<zorch>N<foo>I<pling>>\n"), # !mutor
 
72
  '<Document><Para><B>pie<F>zorch</F>foo<I>pling</I></B></Para>'
 
73
  # make sure it DOESN'T pass thru the N<...>, when not accepted
 
74
));
 
75
 
 
76
ok( starts_with( $x->_out( "=pod\n\nB<pieF<zorch>N<C<foo>>I<pling>>\n"), # !mutor
 
77
  '<Document><Para><B>pie<F>zorch</F><C>foo</C><I>pling</I></B></Para>'
 
78
  # make sure it DOESN'T pass thru the N<...>, when not accepted
 
79
));
 
80
 
 
81
 
 
82
 
 
83
 
 
84
 
 
85
print "# Wrapping up... one for the road...\n";
 
86
ok 1;
 
87
print "# --- Done with ", __FILE__, " --- \n";
 
88