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

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

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

revision 1.29 by wakaba, Mon Mar 3 13:15:54 2008 UTC revision 1.37 by wakaba, Sun Jun 1 06:47:12 2008 UTC
# Line 26  BEGIN { Line 26  BEGIN {
26  }  }
27    
28  use Test;  use Test;
29  BEGIN { plan tests => 471 }  BEGIN { plan tests => 1073 }
30    
31  use Data::Dumper;  use Data::Dumper;
32  $Data::Dumper::Useqq = 1;  $Data::Dumper::Useqq = 1;
# Line 37  sub Data::Dumper::qquote { Line 37  sub Data::Dumper::qquote {
37  } # Data::Dumper::qquote  } # Data::Dumper::qquote
38    
39  if ($DEBUG) {  if ($DEBUG) {
40    my $not_found = {%$Whatpm::HTML::Debug::cp};    my $not_found = {%{$Whatpm::HTML::Debug::cp or {}}};
41    
42    $Whatpm::HTML::Debug::cp_pass = sub {    $Whatpm::HTML::Debug::cp_pass = sub {
43      my $id = shift;      my $id = shift;
# Line 61  for my $file_name (grep {$_} split /\s+/ Line 61  for my $file_name (grep {$_} split /\s+/
61                        ${dir_name}test4.test                        ${dir_name}test4.test
62                        ${dir_name}contentModelFlags.test                        ${dir_name}contentModelFlags.test
63                        ${dir_name}escapeFlag.test                        ${dir_name}escapeFlag.test
64                          ${dir_name}entities.test
65                          ${dir_name}xmlViolation.test
66                        ${test_dir_name}tokenizer-test-1.test                        ${test_dir_name}tokenizer-test-1.test
67                       ]) {                       ]) {
68    open my $file, '<', $file_name    open my $file, '<', $file_name
# Line 80  for my $file_name (grep {$_} split /\s+/ Line 82  for my $file_name (grep {$_} split /\s+/
82      $c += ((((hex $1) & 0b1111111111) << 10) | ((hex $2) & 0b1111111111));      $c += ((((hex $1) & 0b1111111111) << 10) | ((hex $2) & 0b1111111111));
83      chr $c;      chr $c;
84    }gex;    }gex;
85    my $tests = jsonToObj ($js)->{tests};    my $json = jsonToObj ($js);
86      my $tests = $json->{tests} || $json->{xmlViolationTests};
87    TEST: for my $test (@$tests) {    TEST: for my $test (@$tests) {
88      my $s = $test->{input};      my $s = $test->{input};
89            
# Line 121  for my $file_name (grep {$_} split /\s+/ Line 124  for my $file_name (grep {$_} split /\s+/
124          } elsif ($self->{next_char} == 0x0000) { # NULL          } elsif ($self->{next_char} == 0x0000) { # NULL
125            $self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST            $self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST
126            push @token, 'ParseError';            push @token, 'ParseError';
127            } elsif ($self->{next_char} <= 0x0008 or
128                     (0x000E <= $self->{next_char} and
129                      $self->{next_char} <= 0x001F) or
130                     (0x007F <= $self->{next_char} and
131                      $self->{next_char} <= 0x009F) or
132                     (0xD800 <= $self->{next_char} and
133                      $self->{next_char} <= 0xDFFF) or
134                     (0xFDD0 <= $self->{next_char} and
135                      $self->{next_char} <= 0xFDDF) or
136                     {
137                       0xFFFE => 1, 0xFFFF => 1, 0x1FFFE => 1, 0x1FFFF => 1,
138                       0x2FFFE => 1, 0x2FFFF => 1, 0x3FFFE => 1, 0x3FFFF => 1,
139                       0x4FFFE => 1, 0x4FFFF => 1, 0x5FFFE => 1, 0x5FFFF => 1,
140                       0x6FFFE => 1, 0x6FFFF => 1, 0x7FFFE => 1, 0x7FFFF => 1,
141                       0x8FFFE => 1, 0x8FFFF => 1, 0x9FFFE => 1, 0x9FFFF => 1,
142                       0xAFFFE => 1, 0xAFFFF => 1, 0xBFFFE => 1, 0xBFFFF => 1,
143                       0xCFFFE => 1, 0xCFFFF => 1, 0xDFFFE => 1, 0xDFFFF => 1,
144                       0xEFFFE => 1, 0xEFFFF => 1, 0xFFFFE => 1, 0xFFFFF => 1,
145                       0x10FFFE => 1, 0x10FFFF => 1,
146                      }->{$self->{next_char}}) {
147              push @token, 'ParseError';
148          }          }
149        };        };
150        $p->{prev_char} = [-1, -1, -1];        $p->{prev_char} = [-1, -1, -1];
# Line 156  for my $file_name (grep {$_} split /\s+/ Line 180  for my $file_name (grep {$_} split /\s+/
180          $test_token->[1] = $token->{data} if defined $token->{data};          $test_token->[1] = $token->{data} if defined $token->{data};
181          if ($token->{type} == Whatpm::HTML::START_TAG_TOKEN ()) {          if ($token->{type} == Whatpm::HTML::START_TAG_TOKEN ()) {
182            $test_token->[2] = {map {$_->{name} => $_->{value}} values %{$token->{attributes}}};            $test_token->[2] = {map {$_->{name} => $_->{value}} values %{$token->{attributes}}};
183              $test_token->[3] = 1 if $p->{self_closing};
184              delete $p->{self_closing};
185          } elsif ($token->{type} == Whatpm::HTML::DOCTYPE_TOKEN ()) {          } elsif ($token->{type} == Whatpm::HTML::DOCTYPE_TOKEN ()) {
186            $test_token->[1] = $token->{name};            $test_token->[1] = $token->{name};
187            $test_token->[2] = $token->{public_identifier};            $test_token->[2] = $token->{public_identifier};

Legend:
Removed from v.1.29  
changed lines
  Added in v.1.37

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24