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