/[suikacvs]/markup/html/whatpm/t/URIChecker.t
Suika

Diff of /markup/html/whatpm/t/URIChecker.t

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

revision 1.4 by wakaba, Sat Aug 30 04:31:57 2008 UTC revision 1.5 by wakaba, Sat Aug 30 05:31:38 2008 UTC
# Line 34  my $Cases = [ Line 34  my $Cases = [
34    },    },
35    {    {
36      data => q<%a2>,      data => q<%a2>,
37      errors => ['w:1:URL:lowercase hexadecimal digit'],      errors => ['w:0.2:URL:lowercase hexadecimal digit'],
38    },    },
39    {    {
40      data => q<%a2?>,      data => q<%a2?>,
41      errors => ['w:1:URL:lowercase hexadecimal digit'],      errors => ['w:0.2:URL:lowercase hexadecimal digit'],
42    },    },
43    {    {
44      data => q<?%a2>,      data => q<?%a2>,
45      errors => ['w:2:URL:lowercase hexadecimal digit'],      errors => ['w:1.3:URL:lowercase hexadecimal digit'],
46    },    },
47    {    {
48      data => q<%a2%1b>,      data => q<%a2%1b>,
49      errors => ['w:1:URL:lowercase hexadecimal digit',      errors => ['w:0.2:URL:lowercase hexadecimal digit',
50                 'w:4:URL:lowercase hexadecimal digit'],                 'w:3.5:URL:lowercase hexadecimal digit'],
51    },    },
52    {    {
53      data => q<http://%5b/>,      data => q<http://%5b/>,
54      errors => ['w:8:URL:lowercase hexadecimal digit',      errors => ['w:7.9:URL:lowercase hexadecimal digit',
55                 'w::URL:non-DNS host'],                 'w::URL:non-DNS host'],
56    },    },
57    {    {
58      data => q<http://%5b/%25a/bv/%cc>,      data => q<http://%5b/%25a/bv/%cc>,
59      errors => ['w:8:URL:lowercase hexadecimal digit',      errors => ['w:7.9:URL:lowercase hexadecimal digit',
60                 'w:20:URL:lowercase hexadecimal digit',                 'w:19.21:URL:lowercase hexadecimal digit',
61                 'w::URL:non-DNS host'],                 'w::URL:non-DNS host'],
62    },    },
63    {    {
64      data => q<%41>,      data => q<%41>,
65      errors => ['w:1:URL:percent-encoded unreserved'],      errors => ['w:0.2:URL:percent-encoded unreserved'],
66    },    },
67    {    {
68      data => q<%41%7E>,      data => q<%41%7E>,
69      errors => ['w:1:URL:percent-encoded unreserved',      errors => ['w:0.2:URL:percent-encoded unreserved',
70                 'w:4:URL:percent-encoded unreserved'],                 'w:3.5:URL:percent-encoded unreserved'],
71    },    },
72    {    {
73      data => q</%41>,      data => q</%41>,
74      errors => ['w:2:URL:percent-encoded unreserved'],      errors => ['w:1.3:URL:percent-encoded unreserved'],
75    },    },
76    {    {
77      data => q<http://%5a/>,      data => q<http://%5a/>,
78      errors => ['w:8:URL:lowercase hexadecimal digit',      errors => ['w:7.9:URL:lowercase hexadecimal digit',
79                 'w:8:URL:percent-encoded unreserved'],                 'w:7.9:URL:percent-encoded unreserved'],
80    },    },
81    {    {
82      data => q<./%2E%2E>,      data => q<./%2E%2E>,
83      errors => ['w:3:URL:percent-encoded unreserved',      errors => ['w:2.4:URL:percent-encoded unreserved',
84                 'w:6:URL:percent-encoded unreserved'],                 'w:5.7:URL:percent-encoded unreserved'],
85    },    },
86    {    {
87      data => q<http://www.example.com/%7Euser/>,      data => q<http://www.example.com/%7Euser/>,
88      errors => ['w:24:URL:percent-encoded unreserved'],      errors => ['w:23.25:URL:percent-encoded unreserved'],
89    },    },
90    {    {
91      data => q<HTTP://example/>,      data => q<HTTP://example/>,
# Line 103  my $Cases = [ Line 103  my $Cases = [
103      data => q<dat%41:,>,      data => q<dat%41:,>,
104      errors => ['m::syntax error:iriref3987',      errors => ['m::syntax error:iriref3987',
105                 'w::URL:uppercase scheme name',                 'w::URL:uppercase scheme name',
106                 'w:4:URL:percent-encoded unreserved'],                 'w:3.5:URL:percent-encoded unreserved'],
107    },    },
108    {    {
109      data => q<g%5A:,>,      data => q<g%5A:,>,
110      errors => ['m::syntax error:iriref3987',      errors => ['m::syntax error:iriref3987',
111                 'w::URL:uppercase scheme name',                 'w::URL:uppercase scheme name',
112                 'w:2:URL:percent-encoded unreserved'],                 'w:1.3:URL:percent-encoded unreserved'],
113    },    },
114    {    {
115      data => q<g%7A:,>,      data => q<g%7A:,>,
116      errors => ['m::syntax error:iriref3987',      errors => ['m::syntax error:iriref3987',
117                 'w:2:URL:percent-encoded unreserved'],                 'w:1.3:URL:percent-encoded unreserved'],
118    },    },
119    {    {
120      data => q<http://www.test:2222/>,      data => q<http://www.test:2222/>,
# Line 138  my $Cases = [ Line 138  my $Cases = [
138    },    },
139    {    {
140      data => q<http://EXAMPLE/>,      data => q<http://EXAMPLE/>,
141      errors => ['w::URL:uppercase host:EXAMPLE'],      errors => ['w::URL:uppercase host'],
142    },    },
143    {    {
144      data => q<http://USER@example/>,      data => q<http://USER@example/>,
# Line 146  my $Cases = [ Line 146  my $Cases = [
146    },    },
147    {    {
148      data => q<http://[v0.aaa]/>,      data => q<http://[v0.aaa]/>,
149      errors => ['u::URL:address format:v0'],      errors => ['w:1.2:URL:address format:v0'],
150    },    },
151    {    {
152      data => q<http://user@[v0.aaa]/>,      data => q<http://user@[v0.aaa]/>,
153      errors => ['u::URL:address format:v0'],      errors => ['w:1.2:URL:address format:v0'],
154    },    },
155    {    {
156      data => q<http://user@[V0A.aaa]/>,      data => q<http://user@[V0A.aaa]/>,
157      errors => ['u::URL:address format:V0A',      errors => ['w:1.3:URL:address format:V0A',
158                 'w::URL:uppercase host:[V0A.aaa]'],                 'w::URL:uppercase host'],
159    },    },
160    {    {
161      data => q<http://127.0.0.1/>,      data => q<http://127.0.0.1/>,
# Line 175  my $Cases = [ Line 175  my $Cases = [
175    },    },
176    {    {
177      data => q<http://123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123./>,      data => q<http://123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123./>,
178      errors => ['w::URL:long host'],      errors => ['w:256.256:URL:long host'],
179      },
180      {
181        data => q<http://123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123.456789/>,
182        errors => ['w:256.262:URL:long host'],
183    },    },
184    {    {
185      data => q<http://a_b.test/>,      data => q<http://a_b.test/>,
# Line 183  my $Cases = [ Line 187  my $Cases = [
187    },    },
188    {    {
189      data => q<http://%61.test/>,      data => q<http://%61.test/>,
190      errors => ['w:8:URL:percent-encoded unreserved'],      errors => ['w:7.9:URL:percent-encoded unreserved'],
191    },    },
192    {    {
193      data => q<http://a.test/>,      data => q<http://a.test/>,
# Line 241  my $Cases = [ Line 245  my $Cases = [
245    {    {
246      data => q<eXAMPLE://a/./b/../b/%63/%7bfoo%7d>,      data => q<eXAMPLE://a/./b/../b/%63/%7bfoo%7d>,
247      errors => ['w::URL:uppercase scheme name',      errors => ['w::URL:uppercase scheme name',
248                 'w:22:URL:percent-encoded unreserved',                 'w:21.23:URL:percent-encoded unreserved',
249                 'w:26:URL:lowercase hexadecimal digit',                 'w:25.27:URL:lowercase hexadecimal digit',
250                 'w:32:URL:lowercase hexadecimal digit',                 'w:31.33:URL:lowercase hexadecimal digit',
251                 'w::URL:dot-segment'],                 'w::URL:dot-segment'],
252    },    },
253    {    {
# Line 278  my $Cases = [ Line 282  my $Cases = [
282    {    {
283      data => q<%68ttp://example.com:80/>,      data => q<%68ttp://example.com:80/>,
284      errors => ['m::syntax error:iriref3987',      errors => ['m::syntax error:iriref3987',
285                 'w:1:URL:percent-encoded unreserved',                 'w:0.2:URL:percent-encoded unreserved',
286                 'w::URL:default port'],                 'w::URL:default port'],
287    },    },
288    {    {
# Line 332  my $Cases = [ Line 336  my $Cases = [
336    },    },
337    {    {
338      data => q<http://xn--99zt52a.example.org/%e2%80%ae>,      data => q<http://xn--99zt52a.example.org/%e2%80%ae>,
339      errors => ['w:32:URL:lowercase hexadecimal digit',      errors => ['w:31.33:URL:lowercase hexadecimal digit',
340                 'w:38:URL:lowercase hexadecimal digit'],                 'w:37.39:URL:lowercase hexadecimal digit'],
341    },    },
342    {    {
343      data => qq<example://a/b/c/%7Bfoo%7D/ros\xE9>,      data => qq<example://a/b/c/%7Bfoo%7D/ros\xE9>,
# Line 342  my $Cases = [ Line 346  my $Cases = [
346    {    {
347      data => qq<eXAMPLE://a/./b/../b/%63/%7bfoo%7d/ros%C3%A9>,      data => qq<eXAMPLE://a/./b/../b/%63/%7bfoo%7d/ros%C3%A9>,
348      errors => ['w::URL:uppercase scheme name',      errors => ['w::URL:uppercase scheme name',
349                 'w:22:URL:percent-encoded unreserved',                 'w:21.23:URL:percent-encoded unreserved',
350                 'w:26:URL:lowercase hexadecimal digit',                 'w:25.27:URL:lowercase hexadecimal digit',
351                 'w:32:URL:lowercase hexadecimal digit',                 'w:31.33:URL:lowercase hexadecimal digit',
352                 'w::URL:dot-segment'],                 'w::URL:dot-segment'],
353    },    },
354    {    {
355        data => qq<http://www.example.org/..abc/>,
356        errors => [],
357      },
358      {
359        data => qq<http://www.example.org/../abc/>,
360        errors => ['w::URL:dot-segment'],
361      },
362      {
363      data => qq<http://www.example.org/r\xE9sum\xE9.html>,      data => qq<http://www.example.org/r\xE9sum\xE9.html>,
364      errors => [],      errors => [],
365    },    },
# Line 369  for my $test (@$Cases) { Line 381  for my $test (@$Cases) {
381    Whatpm::URIChecker->check_iri_reference ($test->{data}, sub {    Whatpm::URIChecker->check_iri_reference ($test->{data}, sub {
382      my %opt = @_;      my %opt = @_;
383      push @errors, $opt{level} . ':' .      push @errors, $opt{level} . ':' .
384          (defined $opt{position} ? $opt{position} : '') . ':' .          (defined $opt{pos_start} ? $opt{pos_start} . '.' . $opt{pos_end} : '') . ':' .
385          $opt{type} .          $opt{type} .
386          (defined $opt{value} ? ':' . $opt{value} : '');          (defined $opt{text} ? ':' . $opt{text} : '');
387    });    });
388    @errors = sort {$a cmp $b} @errors;    @errors = sort {$a cmp $b} @errors;
389    

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24