xref: /openbsd-src/gnu/usr.bin/perl/cpan/Pod-Simple/t/linkclas.t (revision 5486feefcc8cb79b19e014ab332cc5dfd05b3b33)
1# Testing the LinkSection class
2### Test the basic sanity of the link-section treelet class
3
4use strict;
5use warnings;
6use Test::More tests => 6;
7
8#use Pod::Simple::Debug (6);
9
10use Pod::Simple::LinkSection;
11use Pod::Simple::BlackBox; # for its pretty()
12
13my $bare_treelet =
14  ['B', {'pie' => 'no'},
15   'a',
16   ['C', {'bzrok' => 'plip'},
17    'b'
18   ],
19   'c'
20  ]
21;
22my $treelet = Pod::Simple::LinkSection->new($bare_treelet);
23
24# Make sure they're not the same
25
26is ref($bare_treelet), 'ARRAY';
27is ref($treelet), 'Pod::Simple::LinkSection';
28
29print "# Testing stringification...\n";
30
31is $treelet->stringify, 'abc';  # explicit
32is join('', $treelet),  'abc';  # implicit
33
34
35print "# Testing non-coreferentiality...\n";
36{
37  my @stack = ($bare_treelet);
38  my $this;
39  while(@stack) {
40    $this = shift @stack;
41    if(ref($this || '') eq 'ARRAY') {
42      push @stack, splice @$this;
43      push @$this, ("BAD!") x 3;
44    } elsif(ref($this || '') eq 'Pod::Simple::LinkSection') {
45      push @stack, splice @$this;
46      push @$this, ("BAD!") x 3;
47    } elsif(ref($this || '') eq 'HASH') {
48      %$this = ();
49    }
50  }
51  # These will fail if $treelet and $bare_treelet are coreferential,
52  # since we just conspicuously nuked $bare_treelet
53
54  is $treelet->stringify, 'abc';  # explicit
55  is join('', $treelet),  'abc';  # implicit
56}
57