This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Raw, uncorrected synch of Pod-Simple-3.45
[perl5.git] / cpan / Pod-Simple / t / linkclas.t
CommitLineData
9c7c0c6c 1# Testing the LinkSection class
351625bd
SP
2### Test the basic sanity of the link-section treelet class
3
4use strict;
1ccbfc07 5use warnings;
3afe1500 6use Test::More tests => 6;
351625bd
SP
7
8#use Pod::Simple::Debug (6);
9
351625bd
SP
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
3afe1500
JK
26is ref($bare_treelet), 'ARRAY';
27is ref($treelet), 'Pod::Simple::LinkSection';
351625bd
SP
28
29print "# Testing stringification...\n";
30
3afe1500
JK
31is $treelet->stringify, 'abc'; # explicit
32is join('', $treelet), 'abc'; # implicit
351625bd
SP
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
643dfa47 53
3afe1500
JK
54 is $treelet->stringify, 'abc'; # explicit
55 is join('', $treelet), 'abc'; # implicit
56}