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