/[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.20 by wakaba, Mon Jul 16 07:48:19 2007 UTC revision 1.27 by wakaba, Sun Apr 13 06:44:27 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 => 774 }  BEGIN { plan tests => 1794 }
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 or {}}};
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 38  for my $file_name (grep {$_} split /\s+/ Line 55  for my $file_name (grep {$_} split /\s+/
55                        ${dir_name}tests4.dat                        ${dir_name}tests4.dat
56                        ${dir_name}tests5.dat                        ${dir_name}tests5.dat
57                        ${dir_name}tests6.dat                        ${dir_name}tests6.dat
58                          ${dir_name}tests7.dat
59                        ${test_dir_name}tree-test-1.dat                        ${test_dir_name}tree-test-1.dat
60                        ${test_dir_name}tree-test-2.dat                        ${test_dir_name}tree-test-2.dat
61                       ]) {                       ]) {
# Line 65  for my $file_name (grep {$_} split /\s+/ Line 83  for my $file_name (grep {$_} split /\s+/
83        $mode = 'errors';        $mode = 'errors';
84        $test->{data} =~ s/\x0D?\x0A\z//;              $test->{data} =~ s/\x0D?\x0A\z//;      
85        $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;
86          $test->{data} =~ s/\\U([0-9A-Fa-f]{8})/chr hex $1/ge if $escaped;
87        undef $escaped;        undef $escaped;
88      } elsif (/^#document$/) {      } elsif (/^#document$/) {
89        $test->{document} = '';        $test->{document} = '';
# Line 90  for my $file_name (grep {$_} split /\s+/ Line 109  for my $file_name (grep {$_} split /\s+/
109        $escaped = 1;        $escaped = 1;
110      } elsif (defined $test->{document} and /^$/) {      } elsif (defined $test->{document} and /^$/) {
111        $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;
112          $test->{document} =~ s/\\U([0-9A-Fa-f]{8})/chr hex $1/ge if $escaped;
113        test ($test);        test ($test);
114        undef $test;        undef $test;
115      } else {      } else {
# Line 137  sub test ($) { Line 157  sub test ($) {
157    }    }
158            
159    ok scalar @errors, scalar @{$test->{errors}},    ok scalar @errors, scalar @{$test->{errors}},
160      'Parse error: ' . $test->{data} . '; ' .      'Parse error: ' . Data::Dumper::qquote ($test->{data}) . '; ' .
161      join (', ', @errors) . ';' . join (', ', @{$test->{errors}});      join (', ', @errors) . ';' . join (', ', @{$test->{errors}});
162    
163    ok $result, $test->{document}, 'Document tree: ' . $test->{data};    ok $result, $test->{document},
164          'Document tree: ' . Data::Dumper::qquote ($test->{data});
165  } # test  } # test
166    
167  sub serialize ($) {  sub serialize ($) {
# Line 167  sub serialize ($) { Line 188  sub serialize ($) {
188      } elsif ($nt == $child->[0]->COMMENT_NODE) {      } elsif ($nt == $child->[0]->COMMENT_NODE) {
189        $r .= '| ' . $child->[1] . '<!-- ' . $child->[0]->data . " -->\x0A";        $r .= '| ' . $child->[1] . '<!-- ' . $child->[0]->data . " -->\x0A";
190      } elsif ($nt == $child->[0]->DOCUMENT_TYPE_NODE) {      } elsif ($nt == $child->[0]->DOCUMENT_TYPE_NODE) {
191        $r .= '| ' . $child->[1] . '<!DOCTYPE ' . $child->[0]->name . ">\x0A";        $r .= '| ' . $child->[1] . '<!DOCTYPE ' . $child->[0]->name;
192          my $pubid = $child->[0]->public_id;
193          $r .= ' PUBLIC "' . $pubid . '"' if length $pubid;
194          my $sysid = $child->[0]->system_id;
195          $r .= ' SYSTEM' if not length $pubid and length $sysid;
196          $r .= ' "' . $sysid . '"' if length $sysid;
197          $r .= ">\x0A";
198      } else {      } else {
199        $r .= '| ' . $child->[1] . $child->[0]->node_type . "\x0A"; # error        $r .= '| ' . $child->[1] . $child->[0]->node_type . "\x0A"; # error
200      }      }

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.27

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24