/[suikacvs]/markup/html/whatpm/t/CSS-Parser-1.t
Suika

Contents of /markup/html/whatpm/t/CSS-Parser-1.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.21 - (hide annotations) (download) (as text)
Mon Feb 11 09:53:37 2008 UTC (17 years, 5 months ago) by wakaba
Branch: MAIN
Changes since 1.20: +24 -4 lines
File MIME type: application/x-troff
++ whatpm/t/ChangeLog	11 Feb 2008 09:53:28 -0000
	* css-text.dat: Test data for 'writing-mode' and 'text-anchor'
	are added.

	* CSS-Parser-1.t: New properties are added.

2008-02-11  Wakaba  <wakaba@suika.fam.cx>

++ whatpm/Whatpm/CSS/ChangeLog	11 Feb 2008 09:52:47 -0000
	* Parser.pm: 'writing-mode', 'text-anchor', 'dominant-baseline',
	and 'alignment-baseline' are implemented.

2008-02-11  Wakaba  <wakaba@suika.fam.cx>

1 wakaba 1.1 #!/usr/bin/perl
2     use strict;
3    
4     use lib qw[/home/wakaba/work/manakai2/lib]; ## TODO: ...
5    
6     use Test;
7    
8     BEGIN { plan tests => 548 }
9    
10     require Whatpm::CSS::Parser;
11     require Message::DOM::Window;
12    
13     require Message::DOM::DOMImplementation;
14     my $dom = Message::DOM::DOMImplementation->new;
15    
16     my $DefaultComputed;
17     my $DefaultComputedText;
18    
19     for my $file_name (map {"t/$_"} qw(
20     css-1.dat
21 wakaba 1.17 css-2.dat
22 wakaba 1.18 css-3.dat
23 wakaba 1.20 css-4.dat
24 wakaba 1.4 css-visual.dat
25 wakaba 1.6 css-generated.dat
26 wakaba 1.9 css-paged.dat
27     css-text.dat
28 wakaba 1.7 css-font.dat
29 wakaba 1.10 css-table.dat
30     css-interactive.dat
31 wakaba 1.1 )) {
32     print "# $file_name\n";
33 wakaba 1.13 open my $file, '<:utf8', $file_name or die "$0: $file_name: $!";
34 wakaba 1.1
35     my $all_test = {document => {}, test => []};
36     my $test;
37     my $mode = 'data';
38     my $doc_id;
39     my $selectors;
40     while (<$file>) {
41     s/\x0D\x0A/\x0A/;
42     if (/^#data$/) {
43     undef $test;
44     $test->{data} = '';
45     push @{$all_test->{test}}, $test;
46     $mode = 'data';
47     } elsif (/#(csstext|cssom)$/) {
48     $test->{$1} = '';
49     $mode = $1;
50     } elsif (/#(computed(?>text)?) (\S+) (.+)$/) {
51     $test->{$1}->{$doc_id = $2}->{$selectors = $3} = '';
52     $mode = $1;
53     } elsif (/^#html (\S+)$/) {
54     undef $test;
55     $test->{format} = 'html';
56     $test->{data} = '';
57     $all_test->{document}->{$1} = $test;
58     $mode = 'data';
59 wakaba 1.2 } elsif (/^#errors$/) {
60     $test->{errors} = [];
61     $mode = 'errors';
62     $test->{data} =~ s/\x0D?\x0A\z//;
63 wakaba 1.4 } elsif (/^#option q$/) {
64     $test->{option}->{parse_mode} = 'q';
65 wakaba 1.1 } elsif (defined $test->{data} and /^$/) {
66     undef $test;
67     } else {
68     if ({data => 1, cssom => 1, csstext => 1}->{$mode}) {
69     $test->{$mode} .= $_;
70     } elsif ($mode eq 'computed' or $mode eq 'computedtext') {
71     $test->{$mode}->{$doc_id}->{$selectors} .= $_;
72 wakaba 1.2 } elsif ($mode eq 'errors') {
73     tr/\x0D\x0A//d;
74     push @{$test->{errors}}, $_;
75 wakaba 1.1 } else {
76     die "Line $.: $_";
77     }
78     }
79     }
80    
81     for my $data (values %{$all_test->{document}}) {
82     if ($data->{format} eq 'html') {
83     my $doc = $dom->create_document;
84     $doc->manakai_is_html (1);
85     $doc->inner_html ($data->{data});
86     $data->{document} = $doc;
87     } else {
88     die "Test data format $data->{format} is not supported";
89     }
90     }
91    
92     for my $test (@{$all_test->{test}}) {
93 wakaba 1.4 my ($p, $css_options) = get_parser ($test->{option}->{parse_mode});
94 wakaba 1.1
95 wakaba 1.2 my @actual_error;
96 wakaba 1.1 $p->{onerror} = sub {
97     my (%opt) = @_;
98 wakaba 1.2 my $uri = ${$opt{uri}};
99     $uri =~ s[^thismessage:/][];
100     push @actual_error, join ';',
101     $uri, $opt{token}->{line}, $opt{token}->{column},
102     $opt{level},
103 wakaba 1.16 $opt{type} . (defined $opt{value} ? ';'.$opt{value} : '');
104 wakaba 1.1 };
105    
106     my $ss = $p->parse_char_string ($test->{data});
107 wakaba 1.2
108     ok ((join "\n", @actual_error), (join "\n", @{$test->{errors} or []}),
109     "#result ($test->{data})");
110 wakaba 1.1
111     if (defined $test->{cssom}) {
112     my $actual = serialize_cssom ($ss);
113     ok $actual, $test->{cssom}, "#cssom ($test->{data})";
114     }
115    
116     if (defined $test->{csstext}) {
117     my $actual = $ss->css_text;
118     ok $actual, $test->{csstext}, "#csstext ($test->{data})";
119     }
120    
121     for my $doc_id (keys %{$test->{computed} or {}}) {
122     for my $selectors (keys %{$test->{computed}->{$doc_id}}) {
123     my ($window, $style) = get_computed_style
124     ($all_test, $doc_id, $selectors, $dom, $css_options, $ss);
125     ## NOTE: $window is the root object, so that we must keep it
126     ## referenced in this block.
127    
128     my $actual = serialize_style ($style, '');
129     my $expected = $DefaultComputed;
130     my $diff = $test->{computed}->{$doc_id}->{$selectors};
131     ($actual, $expected) = apply_diff ($actual, $expected, $diff);
132     ok $actual, $expected,
133     "#computed $doc_id $selectors ($test->{data})";
134     }
135     }
136    
137     for my $doc_id (keys %{$test->{computedtext} or {}}) {
138     for my $selectors (keys %{$test->{computedtext}->{$doc_id}}) {
139     my ($window, $style) = get_computed_style
140     ($all_test, $doc_id, $selectors, $dom, $css_options, $ss);
141     ## NOTE: $window is the root object, so that we must keep it
142     ## referenced in this block.
143    
144     my $actual = $style->css_text;
145     my $expected = $DefaultComputedText;
146     my $diff = $test->{computedtext}->{$doc_id}->{$selectors};
147     ($actual, $expected) = apply_diff ($actual, $expected, $diff);
148     "#computedtext $doc_id $selectors ($test->{data})";
149     ok $actual, $expected,
150     "#computedtext $doc_id $selectors ($test->{data})";
151     }
152     }
153     }
154     }
155    
156     my @longhand;
157     my @shorthand;
158     BEGIN {
159     @longhand = qw/
160 wakaba 1.21 alignment-baseline
161 wakaba 1.1 background-attachment background-color background-image
162     background-position-x background-position-y
163     background-repeat border-bottom-color
164     border-bottom-style border-bottom-width border-collapse
165     border-left-color
166     border-left-style border-left-width border-right-color
167     border-right-style border-right-width
168     -manakai-border-spacing-x -manakai-border-spacing-y
169     border-top-color border-top-style border-top-width bottom
170 wakaba 1.15 caption-side clear clip color content counter-increment counter-reset
171 wakaba 1.21 cursor direction display dominant-baseline empty-cells float
172 wakaba 1.16 font-family font-size font-size-adjust font-stretch
173     font-style font-variant font-weight height left
174 wakaba 1.1 letter-spacing line-height
175     list-style-image list-style-position list-style-type
176 wakaba 1.16 margin-bottom margin-left margin-right margin-top marker-offset
177     marks max-height max-width min-height min-width opacity -moz-opacity
178 wakaba 1.11 orphans outline-color outline-style outline-width overflow-x overflow-y
179 wakaba 1.1 padding-bottom padding-left padding-right padding-top
180 wakaba 1.16 page page-break-after page-break-before page-break-inside
181     position quotes right size table-layout
182 wakaba 1.21 text-align text-anchor text-decoration text-indent text-transform
183 wakaba 1.1 top unicode-bidi vertical-align visibility white-space width widows
184 wakaba 1.21 word-spacing writing-mode z-index
185 wakaba 1.1 /;
186     @shorthand = qw/
187     background background-position
188     border border-color border-style border-width border-spacing
189     border-top border-right border-bottom border-left
190 wakaba 1.11 font list-style margin outline overflow padding
191 wakaba 1.1 /;
192 wakaba 1.21 $DefaultComputedText = q[ alignment-baseline: auto;
193     border-spacing: 0px;
194 wakaba 1.1 background: transparent none repeat scroll 0% 0%;
195     border: 0px none -manakai-default;
196     border-collapse: separate;
197     bottom: auto;
198     caption-side: top;
199     clear: none;
200 wakaba 1.15 clip: auto;
201 wakaba 1.1 color: -manakai-default;
202 wakaba 1.13 content: normal;
203 wakaba 1.14 counter-increment: none;
204     counter-reset: none;
205 wakaba 1.1 cursor: auto;
206     direction: ltr;
207     display: inline;
208 wakaba 1.21 dominant-baseline: auto;
209 wakaba 1.1 empty-cells: show;
210     float: none;
211     font-family: -manakai-default;
212     font-size: 16px;
213 wakaba 1.16 font-size-adjust: none;
214     font-stretch: normal;
215 wakaba 1.1 font-style: normal;
216     font-variant: normal;
217     font-weight: 400;
218     height: auto;
219     left: auto;
220     letter-spacing: normal;
221     line-height: normal;
222     list-style-image: none;
223     list-style-position: outside;
224     list-style-type: disc;
225 wakaba 1.5 margin: 0px;
226 wakaba 1.16 marker-offset: auto;
227     marks: none;
228 wakaba 1.1 max-height: none;
229     max-width: none;
230     min-height: 0px;
231     min-width: 0px;
232     opacity: 1;
233     orphans: 2;
234     outline: 0px none invert;
235     overflow: visible;
236 wakaba 1.6 padding: 0px;
237 wakaba 1.16 page: auto;
238 wakaba 1.1 page-break-after: auto;
239     page-break-before: auto;
240     page-break-inside: auto;
241     position: static;
242 wakaba 1.12 quotes: -manakai-default;
243 wakaba 1.1 right: auto;
244 wakaba 1.16 size: auto;
245 wakaba 1.1 table-layout: auto;
246     text-align: begin;
247 wakaba 1.21 text-anchor: start;
248 wakaba 1.1 text-decoration: none;
249     text-indent: 0px;
250     text-transform: none;
251     top: auto;
252     unicode-bidi: normal;
253     vertical-align: baseline;
254     visibility: visible;
255     white-space: normal;
256     widows: 2;
257     width: auto;
258     word-spacing: normal;
259 wakaba 1.21 writing-mode: lr-tb;
260 wakaba 1.1 z-index: auto;
261     ];
262     $DefaultComputed = $DefaultComputedText;
263     $DefaultComputed =~ s/^ /| /gm;
264     $DefaultComputed =~ s/;$//gm;
265     $DefaultComputed .= q[| -manakai-border-spacing-x: 0px
266     | -manakai-border-spacing-y: 0px
267     | -moz-opacity: 1
268     | background-attachment: scroll
269     | background-color: transparent
270     | background-image: none
271 wakaba 1.8 | background-position: 0% 0%
272 wakaba 1.1 | background-position-x: 0%
273     | background-position-y: 0%
274     | background-repeat: repeat
275     | border-top: 0px none -manakai-default
276     | border-right: 0px none -manakai-default
277     | border-bottom: 0px none -manakai-default
278     | border-left: 0px none -manakai-default
279     | border-bottom-color: -manakai-default
280     | border-bottom-style: none
281     | border-bottom-width: 0px
282     | border-left-color: -manakai-default
283     | border-left-style: none
284     | border-left-width: 0px
285     | border-right-color: -manakai-default
286     | border-right-style: none
287     | border-right-width: 0px
288     | border-top-color: -manakai-default
289     | border-top-style: none
290     | border-top-width: 0px
291     | border-color: -manakai-default
292     | border-style: none
293     | border-width: 0px
294     | float: none
295 wakaba 1.7 | font: 400 16px -manakai-default
296 wakaba 1.6 | list-style: disc none outside
297 wakaba 1.5 | margin-top: 0px
298     | margin-right: 0px
299     | margin-bottom: 0px
300     | margin-left: 0px
301 wakaba 1.1 | outline-color: invert
302     | outline-style: none
303     | outline-width: 0px
304 wakaba 1.11 | overflow-x: visible
305     | overflow-y: visible
306 wakaba 1.6 | padding-bottom: 0px
307     | padding-left: 0px
308     | padding-right: 0px
309     | padding-top: 0px];
310 wakaba 1.1 }
311    
312 wakaba 1.4 sub get_parser ($) {
313     my $parse_mode = shift;
314    
315 wakaba 1.1 my $p = Whatpm::CSS::Parser->new;
316 wakaba 1.4
317 wakaba 1.1 $p->{prop}->{$_} = 1 for (@longhand, @shorthand);
318     $p->{prop_value}->{display}->{$_} = 1 for qw/
319 wakaba 1.15 block clip inline inline-block inline-table list-item none
320 wakaba 1.1 table table-caption table-cell table-column table-column-group
321     table-header-group table-footer-group table-row table-row-group
322 wakaba 1.16 compact marker
323 wakaba 1.1 /;
324     $p->{prop_value}->{position}->{$_} = 1 for qw/
325     absolute fixed relative static
326     /;
327     $p->{prop_value}->{float}->{$_} = 1 for qw/
328     left right none
329     /;
330     $p->{prop_value}->{clear}->{$_} = 1 for qw/
331     left right none both
332     /;
333     $p->{prop_value}->{direction}->{ltr} = 1;
334     $p->{prop_value}->{direction}->{rtl} = 1;
335 wakaba 1.16 $p->{prop_value}->{marks}->{crop} = 1;
336     $p->{prop_value}->{marks}->{cross} = 1;
337 wakaba 1.1 $p->{prop_value}->{'unicode-bidi'}->{$_} = 1 for qw/
338     normal bidi-override embed
339     /;
340 wakaba 1.11 for my $prop_name (qw/overflow overflow-x overflow-y/) {
341     $p->{prop_value}->{$prop_name}->{$_} = 1 for qw/
342     visible hidden scroll auto -webkit-marquee -moz-hidden-unscrollable
343     /;
344     }
345 wakaba 1.1 $p->{prop_value}->{visibility}->{$_} = 1 for qw/
346     visible hidden collapse
347     /;
348     $p->{prop_value}->{'list-style-type'}->{$_} = 1 for qw/
349     disc circle square decimal decimal-leading-zero
350     lower-roman upper-roman lower-greek lower-latin
351     upper-latin armenian georgian lower-alpha upper-alpha none
352 wakaba 1.16 hebrew cjk-ideographic hiragana katakana hiragana-iroha
353     katakana-iroha
354 wakaba 1.1 /;
355     $p->{prop_value}->{'list-style-position'}->{outside} = 1;
356     $p->{prop_value}->{'list-style-position'}->{inside} = 1;
357     $p->{prop_value}->{'page-break-before'}->{$_} = 1 for qw/
358     auto always avoid left right
359     /;
360     $p->{prop_value}->{'page-break-after'}->{$_} = 1 for qw/
361     auto always avoid left right
362     /;
363     $p->{prop_value}->{'page-break-inside'}->{auto} = 1;
364     $p->{prop_value}->{'page-break-inside'}->{avoid} = 1;
365     $p->{prop_value}->{'background-repeat'}->{$_} = 1 for qw/
366     repeat repeat-x repeat-y no-repeat
367     /;
368     $p->{prop_value}->{'background-attachment'}->{scroll} = 1;
369     $p->{prop_value}->{'background-attachment'}->{fixed} = 1;
370 wakaba 1.16 $p->{prop_value}->{'font-size'}->{$_} = 1 for qw/
371     xx-small x-small small medium large x-large xx-large
372     -manakai-xxx-large -webkit-xxx-large
373     larger smaller
374     /;
375 wakaba 1.1 $p->{prop_value}->{'font-style'}->{normal} = 1;
376     $p->{prop_value}->{'font-style'}->{italic} = 1;
377     $p->{prop_value}->{'font-style'}->{oblique} = 1;
378     $p->{prop_value}->{'font-variant'}->{normal} = 1;
379     $p->{prop_value}->{'font-variant'}->{'small-caps'} = 1;
380 wakaba 1.16 $p->{prop_value}->{'font-stretch'}->{$_} = 1 for
381     qw/normal wider narrower ultra-condensed extra-condensed
382     condensed semi-condensed semi-expanded expanded
383     extra-expanded ultra-expanded/;
384 wakaba 1.1 $p->{prop_value}->{'text-align'}->{$_} = 1 for qw/
385     left right center justify begin end
386     /;
387     $p->{prop_value}->{'text-transform'}->{$_} = 1 for qw/
388     capitalize uppercase lowercase none
389     /;
390     $p->{prop_value}->{'white-space'}->{$_} = 1 for qw/
391 wakaba 1.18 normal pre nowrap pre-line pre-wrap -moz-pre-wrap
392 wakaba 1.21 /;
393     $p->{prop_value}->{'writing-mode'}->{$_} = 1 for qw/
394     lr rl tb lr-tb rl-tb tb-rl
395     /;
396     $p->{prop_value}->{'text-anchor'}->{$_} = 1 for qw/
397     start middle end
398     /;
399     $p->{prop_value}->{'dominant-baseline'}->{$_} = 1 for qw/
400     auto use-script no-change reset-size ideographic alphabetic
401     hanging mathematical central middle text-after-edge text-before-edge
402     /;
403     $p->{prop_value}->{'alignment-baseline'}->{$_} = 1 for qw/
404     auto baseline before-edge text-before-edge middle central
405     after-edge text-after-edge ideographic alphabetic hanging
406     mathematical
407 wakaba 1.1 /;
408     $p->{prop_value}->{'text-decoration'}->{$_} = 1 for qw/
409     none blink underline overline line-through
410     /;
411     $p->{prop_value}->{'caption-side'}->{$_} = 1 for qw/
412 wakaba 1.16 top bottom left right
413 wakaba 1.1 /;
414     $p->{prop_value}->{'table-layout'}->{auto} = 1;
415     $p->{prop_value}->{'table-layout'}->{fixed} = 1;
416 wakaba 1.18 $p->{prop_value}->{'border-collapse'}->{collapse} = 1;
417 wakaba 1.1 $p->{prop_value}->{'border-collapse'}->{separate} = 1;
418     $p->{prop_value}->{'empty-cells'}->{show} = 1;
419     $p->{prop_value}->{'empty-cells'}->{hide} = 1;
420     $p->{prop_value}->{cursor}->{$_} = 1 for qw/
421     auto crosshair default pointer move e-resize ne-resize nw-resize n-resize
422     se-resize sw-resize s-resize w-resize text wait help progress
423     /;
424     for my $prop (qw/border-top-style border-left-style
425     border-bottom-style border-right-style outline-style/) {
426     $p->{prop_value}->{$prop}->{$_} = 1 for qw/
427     none hidden dotted dashed solid double groove ridge inset outset
428     /;
429     }
430     for my $prop (qw/color background-color
431     border-bottom-color border-left-color border-right-color
432     border-top-color border-color/) {
433     $p->{prop_value}->{$prop}->{transparent} = 1;
434     $p->{prop_value}->{$prop}->{flavor} = 1;
435     $p->{prop_value}->{$prop}->{'-manakai-default'} = 1;
436     }
437     $p->{prop_value}->{'outline-color'}->{invert} = 1;
438     $p->{prop_value}->{'outline-color'}->{'-manakai-invert-or-currentcolor'} = 1;
439     $p->{pseudo_class}->{$_} = 1 for qw/
440     active checked disabled empty enabled first-child first-of-type
441     focus hover indeterminate last-child last-of-type link only-child
442     only-of-type root target visited
443     lang nth-child nth-last-child nth-of-type nth-last-of-type not
444     -manakai-contains -manakai-current
445     /;
446     $p->{pseudo_element}->{$_} = 1 for qw/
447     after before first-letter first-line
448     /;
449    
450     my $css_options = {
451     prop => $p->{prop},
452     prop_value => $p->{prop_value},
453     pseudo_class => $p->{pseudo_class},
454     pseudo_element => $p->{pseudo_element},
455     };
456    
457 wakaba 1.19 $p->init;
458     if ($parse_mode eq 'q') {
459     $p->{unitless_px} = 1;
460     $p->{hashless_color} = 1;
461     }
462 wakaba 1.1 $p->{href} = 'thismessage:/';
463    
464     return ($p, $css_options);
465     } # get_parser
466    
467     sub serialize_cssom ($) {
468     my $ss = shift;
469    
470     if (defined $ss) {
471     if ($ss->isa ('Message::IF::CSSStyleSheet')) {
472     my $v = '';
473     for my $rule (@{$ss->css_rules}) {
474     my $indent = '';
475 wakaba 1.17 $v .= serialize_rule ($rule, $indent);
476 wakaba 1.1 }
477     return $v;
478     } else {
479     return '(' . (ref $ss) . ')';
480     }
481     } else {
482     return '(undef)';
483     }
484     } # serialize_cssom
485 wakaba 1.17
486     sub serialize_rule ($$) {
487     my ($rule, $indent) = @_;
488     my $v = '';
489     if ($rule->type == $rule->STYLE_RULE) {
490     $v .= '| ' . $indent . '<' . $rule->selector_text . ">\n";
491     $v .= serialize_style ($rule->style, $indent . ' ');
492     } elsif ($rule->type == $rule->MEDIA_RULE) {
493     $v .= '| ' . $indent . '@media ' . $rule->media . "\n";
494     $v .= serialize_rule ($_, $indent . ' ') for @{$rule->css_rules};
495 wakaba 1.18 } elsif ($rule->type == $rule->NAMESPACE_RULE) {
496     $v .= '| ' . $indent . '@namespace ';
497     my $prefix = $rule->prefix;
498     $v .= $prefix . ': ' if length $prefix;
499     $v .= '<' . $rule->namespace_uri . ">\n";
500 wakaba 1.20 } elsif ($rule->type == $rule->IMPORT_RULE) {
501     $v .= '| ' . $indent . '@import <' . $rule->href . '> ' . $rule->media;
502     $v .= "\n";
503     } elsif ($rule->type == $rule->CHARSET_RULE) {
504     $v .= '| ' . $indent . '@charset ' . $rule->encoding . "\n";
505 wakaba 1.17 } else {
506     die "Rule type @{[$rule->type]} is not supported";
507     }
508     return $v;
509     } # serialize_rule
510 wakaba 1.1
511     sub get_computed_style ($$$$$$) {
512     my ($all_test, $doc_id, $selectors, $dom, $css_options, $ss) = @_;
513    
514     my $doc = $all_test->{document}->{$doc_id}->{document};
515     unless ($doc) {
516     die "Test document $doc_id is not defined";
517     }
518    
519 wakaba 1.6 my $element = $doc->query_selector ($selectors);
520 wakaba 1.1 unless ($element) {
521     die "Element $selectors not found in document $doc_id";
522     }
523    
524     my $window = Message::DOM::Window->___new ($dom);
525     $window->___set_css_options ($css_options);
526     $window->___set_user_style_sheets ([$ss]);
527     $window->set_document ($doc);
528    
529 wakaba 1.3 my $style = $element->manakai_computed_style;
530 wakaba 1.1 return ($window, $style);
531     } # get_computed_style
532    
533     sub serialize_style ($$) {
534     my ($style, $indent) = @_;
535    
536     ## TODO: check @$style
537    
538     my @v;
539     for (map {get_dom_names ($_)} @shorthand, @longhand) {
540     my $dom = $_->[1];
541     push @v, [$_->[0], $dom, $style->$dom,
542     $style->get_property_priority ($_->[0])];
543     $v[-1]->[3] = ' !' . $v[-1]->[3] if length $v[-1]->[3];
544     }
545     return join '', map {"| $indent$_->[0]: $_->[2]$_->[3]\n"}
546     sort {$a->[0] cmp $b->[0]} grep {length $_->[2]} @v;
547     } # serialize_style
548    
549     sub get_dom_names ($) {
550     my $dom_name = $_[0];
551     if ($_[0] eq 'float') {
552     return ([$_[0] => 'css_float'], [$_[0] => 'style_float']);
553     }
554    
555     $dom_name =~ tr/-/_/;
556     return ([$_[0] => $dom_name]);
557     } # get_dom_names
558    
559     sub apply_diff ($$$) {
560     my ($actual, $expected, $diff) = @_;
561     my @actual = split /[\x0D\x0A]+/, $actual;
562     my @expected = split /[\x0D\x0A]+/, $expected;
563     my @diff = split /[\x0D\x0A]+/, $diff;
564     for (@diff) {
565     if (s/^-//) {
566     push @actual, $_;
567     } elsif (s/^\+//) {
568     push @expected, $_;
569     } else {
570     die "Invalid diff line: $_";
571     }
572     }
573     $actual = join "\n", sort {$a cmp $b} @actual;
574     $expected = join "\n", sort {$a cmp $b} @expected;
575     ($actual, $expected);
576     } # apply_diff

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24