Commit | Line | Data |
---|---|---|
9c7c0c6c | 1 | # Testing the LinkSection class |
351625bd SP |
2 | ### Test the basic sanity of the link-section treelet class |
3 | ||
4 | use strict; | |
1ccbfc07 | 5 | use warnings; |
3afe1500 | 6 | use Test::More tests => 6; |
351625bd SP |
7 | |
8 | #use Pod::Simple::Debug (6); | |
9 | ||
351625bd SP |
10 | use Pod::Simple::LinkSection; |
11 | use Pod::Simple::BlackBox; # for its pretty() | |
12 | ||
13 | my $bare_treelet = | |
14 | ['B', {'pie' => 'no'}, | |
15 | 'a', | |
16 | ['C', {'bzrok' => 'plip'}, | |
17 | 'b' | |
18 | ], | |
19 | 'c' | |
20 | ] | |
21 | ; | |
22 | my $treelet = Pod::Simple::LinkSection->new($bare_treelet); | |
23 | ||
24 | # Make sure they're not the same | |
25 | ||
3afe1500 JK |
26 | is ref($bare_treelet), 'ARRAY'; |
27 | is ref($treelet), 'Pod::Simple::LinkSection'; | |
351625bd SP |
28 | |
29 | print "# Testing stringification...\n"; | |
30 | ||
3afe1500 JK |
31 | is $treelet->stringify, 'abc'; # explicit |
32 | is join('', $treelet), 'abc'; # implicit | |
351625bd SP |
33 | |
34 | ||
35 | print "# 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 | |
643dfa47 | 53 | |
3afe1500 JK |
54 | is $treelet->stringify, 'abc'; # explicit |
55 | is join('', $treelet), 'abc'; # implicit | |
56 | } |