Add ARM files
[dh-make-perl] / dev / arm / libhtml-parser-perl / libhtml-parser-perl-3.56 / t / case-sensitive.t
1 use strict;
2 use Test::More tests => 8;
3
4 use HTML::Parser ();
5 my $p = HTML::Parser->new();
6 $p->case_sensitive(1);
7
8 my $text = "";
9 $p->handler(start =>
10             sub {
11                  my($tag, $attr, $attrseq) = @_;
12                  $text .= "S[$tag";
13                  for my $k (sort keys %$attr) {
14                      my $v =  $attr->{$k};
15                      $text .= " $k=$v";
16                  }
17                  if (@$attrseq) { $text.=" Order:" ; }
18                  for my $k (@$attrseq) {
19                      $text .= " $k";
20                  }
21                  $text .= "]";
22              }, "tagname,attr,attrseq");
23 $p->handler(end =>
24             sub {
25                  my ($tag) = @_;
26                  $text .= "E[$tag]";
27              }, "tagname");
28
29 my $html = <<'EOT';
30 <tAg aRg="Value" arg="other value"></tAg>
31 EOT
32 my $cs = 'S[tAg aRg=Value arg=other value Order: aRg arg]E[tAg]';
33 my $ci = 'S[tag arg=Value Order: arg arg]E[tag]';
34
35 $p->parse($html)->eof;
36 is($text, $cs);
37
38 $text = "";
39 $p->case_sensitive(0);
40 $p->parse($html)->eof;
41 is($text, $ci);
42
43 $text = "";
44 $p->case_sensitive(1);
45 $p->xml_mode(1);
46 $p->parse($html)->eof;
47 is($text, $cs);
48
49 $text = "";
50 $p->case_sensitive(0);
51 $p->parse($html)->eof;
52 is($text, $cs);
53
54 $html = <<'EOT';
55 <tAg aRg="Value" arg="other value"></tAg>
56 <iGnOrE></ignore>
57 EOT
58 $p->ignore_tags('ignore');
59 $cs = 'S[tAg aRg=Value arg=other value Order: aRg arg]E[tAg]S[iGnOrE]';
60 $ci = 'S[tag arg=Value Order: arg arg]E[tag]';
61
62 $text = "";
63 $p->case_sensitive(0);
64 $p->xml_mode(0);
65 $p->parse($html)->eof;
66 is($text, $ci);
67  
68 $text = "";
69 $p->case_sensitive(1);
70 $p->xml_mode(0);
71 $p->parse($html)->eof;
72 is($text, $cs);
73
74 $text = "";
75 $p->case_sensitive(0);
76 $p->xml_mode(1);
77 $p->parse($html)->eof;
78 is($text, $cs);
79  
80 $text = "";
81 $p->case_sensitive(1);
82 $p->xml_mode(1);
83 $p->parse($html)->eof;
84 is($text, $cs);
85