Upgrade to Pod-Simple-3.05.
[p5sagit/p5-mst-13.2.git] / lib / Pod / Simple / t / linkclas.t
CommitLineData
351625bd 1BEGIN {
2 if($ENV{PERL_CORE}) {
3 chdir 't';
4 @INC = '../lib';
5 }
6}
7
8### Test the basic sanity of the link-section treelet class
9
10use strict;
11use Test;
12BEGIN { plan tests => 8 };
13
14#use Pod::Simple::Debug (6);
15
16ok 1;
17
18use Pod::Simple::LinkSection;
19use Pod::Simple::BlackBox; # for its pretty()
20
21my $bare_treelet =
22 ['B', {'pie' => 'no'},
23 'a',
24 ['C', {'bzrok' => 'plip'},
25 'b'
26 ],
27 'c'
28 ]
29;
30my $treelet = Pod::Simple::LinkSection->new($bare_treelet);
31
32# Make sure they're not the same
33
34ok ref($bare_treelet), 'ARRAY';
35ok ref($treelet), 'Pod::Simple::LinkSection';
36
37print "# Testing stringification...\n";
38
39ok $treelet->stringify, 'abc'; # explicit
40ok join('', $treelet), 'abc'; # implicit
41
42
43print "# Testing non-coreferentiality...\n";
44{
45 my @stack = ($bare_treelet);
46 my $this;
47 while(@stack) {
48 $this = shift @stack;
49 if(ref($this || '') eq 'ARRAY') {
50 push @stack, splice @$this;
51 push @$this, ("BAD!") x 3;
52 } elsif(ref($this || '') eq 'Pod::Simple::LinkSection') {
53 push @stack, splice @$this;
54 push @$this, ("BAD!") x 3;
55 } elsif(ref($this || '') eq 'HASH') {
56 %$this = ();
57 }
58 }
59 # These will fail if $treelet and $bare_treelet are coreferential,
60 # since we just conspicuously nuked $bare_treelet
61
62 ok $treelet->stringify, 'abc'; # explicit
63 ok join('', $treelet), 'abc'; # implicit
64}
65
66
67print "# Byebye...\n";
68ok 1;
69print "# --- Done with ", __FILE__, " --- \n";
70