/[suikacvs]/markup/html/whatpm/t/HTML-tree.t
Suika

Diff of /markup/html/whatpm/t/HTML-tree.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.19 by wakaba, Mon Jul 16 07:03:09 2007 UTC revision 1.24 by wakaba, Wed Mar 5 13:07:02 2008 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl  #!/usr/bin/perl
2  use strict;  use strict;
3    
4    my $DEBUG = $ENV{DEBUG};
5    
6  my $dir_name;  my $dir_name;
7  my $test_dir_name;  my $test_dir_name;
8  BEGIN {  BEGIN {
# Line 20  BEGIN { Line 22  BEGIN {
22  }  }
23    
24  use Test;  use Test;
25  BEGIN { plan tests => 640 }  BEGIN { plan tests => 980 }
26    
27  use Data::Dumper;  use Data::Dumper;
28  $Data::Dumper::Useqq = 1;  $Data::Dumper::Useqq = 1;
# Line 30  sub Data::Dumper::qquote { Line 32  sub Data::Dumper::qquote {
32    return q<qq'> . $s . q<'>;    return q<qq'> . $s . q<'>;
33  } # Data::Dumper::qquote  } # Data::Dumper::qquote
34    
35    
36    if ($DEBUG) {
37      my $not_found = {%$Whatpm::HTML::Debug::cp};
38      $Whatpm::HTML::Debug::cp_pass = sub {
39        my $id = shift;
40        delete $not_found->{$id};
41      };
42    
43      END {
44        for my $id (sort {$a <=> $b || $a cmp $b} keys %$not_found) {
45          print "# checkpoint $id is not reached\n";
46        }
47      }
48    }
49    
50  for my $file_name (grep {$_} split /\s+/, qq[  for my $file_name (grep {$_} split /\s+/, qq[
51                        ${test_dir_name}tokenizer-test-2.dat                        ${test_dir_name}tokenizer-test-2.dat
52                        ${dir_name}tests1.dat                        ${dir_name}tests1.dat
# Line 65  for my $file_name (grep {$_} split /\s+/ Line 82  for my $file_name (grep {$_} split /\s+/
82        $mode = 'errors';        $mode = 'errors';
83        $test->{data} =~ s/\x0D?\x0A\z//;              $test->{data} =~ s/\x0D?\x0A\z//;      
84        $test->{data} =~ s/\\u([0-9A-Fa-f]{4})/chr hex $1/ge if $escaped;        $test->{data} =~ s/\\u([0-9A-Fa-f]{4})/chr hex $1/ge if $escaped;
85          $test->{data} =~ s/\\U([0-9A-Fa-f]{8})/chr hex $1/ge if $escaped;
86        undef $escaped;        undef $escaped;
87      } elsif (/^#document$/) {      } elsif (/^#document$/) {
88        $test->{document} = '';        $test->{document} = '';
# Line 90  for my $file_name (grep {$_} split /\s+/ Line 108  for my $file_name (grep {$_} split /\s+/
108        $escaped = 1;        $escaped = 1;
109      } elsif (defined $test->{document} and /^$/) {      } elsif (defined $test->{document} and /^$/) {
110        $test->{document} =~ s/\\u([0-9A-Fa-f]{4})/chr hex $1/ge if $escaped;        $test->{document} =~ s/\\u([0-9A-Fa-f]{4})/chr hex $1/ge if $escaped;
111          $test->{document} =~ s/\\U([0-9A-Fa-f]{8})/chr hex $1/ge if $escaped;
112        test ($test);        test ($test);
113        undef $test;        undef $test;
114      } else {      } else {
# Line 137  sub test ($) { Line 156  sub test ($) {
156    }    }
157            
158    ok scalar @errors, scalar @{$test->{errors}},    ok scalar @errors, scalar @{$test->{errors}},
159      'Parse error: ' . $test->{data} . '; ' .      'Parse error: ' . Data::Dumper::qquote ($test->{data}) . '; ' .
160      join (', ', @errors) . ';' . join (', ', @{$test->{errors}});      join (', ', @errors) . ';' . join (', ', @{$test->{errors}});
161    
162    ok $result, $test->{document}, 'Document tree: ' . $test->{data};    ok $result, $test->{document},
163          'Document tree: ' . Data::Dumper::qquote ($test->{data});
164  } # test  } # test
165    
166  sub serialize ($) {  sub serialize ($) {
# Line 167  sub serialize ($) { Line 187  sub serialize ($) {
187      } elsif ($nt == $child->[0]->COMMENT_NODE) {      } elsif ($nt == $child->[0]->COMMENT_NODE) {
188        $r .= '| ' . $child->[1] . '<!-- ' . $child->[0]->data . " -->\x0A";        $r .= '| ' . $child->[1] . '<!-- ' . $child->[0]->data . " -->\x0A";
189      } elsif ($nt == $child->[0]->DOCUMENT_TYPE_NODE) {      } elsif ($nt == $child->[0]->DOCUMENT_TYPE_NODE) {
190        $r .= '| ' . $child->[1] . '<!DOCTYPE ' . $child->[0]->name . ">\x0A";        $r .= '| ' . $child->[1] . '<!DOCTYPE ' . $child->[0]->name;
191          my $pubid = $child->[0]->public_id;
192          $r .= ' PUBLIC "' . $pubid . '"' if length $pubid;
193          my $sysid = $child->[0]->system_id;
194          $r .= ' SYSTEM' if not length $pubid and length $sysid;
195          $r .= ' "' . $sysid . '"' if length $sysid;
196          $r .= ">\x0A";
197      } else {      } else {
198        $r .= '| ' . $child->[1] . $child->[0]->node_type . "\x0A"; # error        $r .= '| ' . $child->[1] . $child->[0]->node_type . "\x0A"; # error
199      }      }

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.24

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24