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