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

Contents of /markup/html/whatpm/t/WebIDL.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download) (as text)
Sat Aug 2 15:14:24 2008 UTC (17 years, 9 months ago) by wakaba
Branch: MAIN
Changes since 1.2: +3 -2 lines
File MIME type: application/x-troff
++ whatpm/t/ChangeLog	2 Aug 2008 15:13:47 -0000
	* WebIDL.t ($onerror): |value| argument value should be
	checked as well as other argument values.

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

++ whatpm/t/webidl/ChangeLog	2 Aug 2008 15:14:12 -0000
	* webidl-defs.dat: Test result updated.

	* webidl-interface.dat: New test data for constants are added.

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

++ whatpm/Whatpm/ChangeLog	2 Aug 2008 15:12:09 -0000
	* WebIDL.pm ($integer): Order of selections are changed to match
	hexadecimal numbers (the original pattern, taken from the spec,
	was not work for hexadecimal numbers, because the "0" prefix
	matches to the [0-7]* part (as an empty string) and therefore
	it does not match with remaining "x..." part of a "0x..." integer
	literal.
	($get_type): It now returns a string, not an array reference,
	for regular types and |sequence| types (i.e. it in any case
	returns a string).
	($get_next_token): The second item in the array that represents
	a integer or float token is now a Perl number value, not the
	original string representation of the number.
	(check): Support for const value consistency checking.
	No extended attribute is defined for constants.
	(Node subclasses): Use simple strings rather than array references
	for default data type values.
	($serialize_type): Type values are now simple strings.
	(value): If the new attribute value is a false value, then
	a FALSE value is set to the attribute.

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

1 #!/usr/bin/perl
2 use strict;
3
4 my $DEBUG = $ENV{DEBUG};
5
6 my $dir_name;
7 my $test_dir_name;
8 BEGIN {
9 $test_dir_name = 't/';
10 $dir_name = 't/webidl/';
11 }
12
13 use Test;
14 BEGIN { plan tests => 1920 }
15
16 require Whatpm::WebIDL;
17
18 for my $file_name (grep {$_} split /\s+/, qq[
19 ${dir_name}webidl-defs.dat
20 ${dir_name}webidl-interface.dat
21 ]) {
22 open my $file, '<', $file_name
23 or die "$0: $file_name: $!";
24 print "# $file_name\n";
25
26 my $test;
27 my $mode = 'data';
28 my $escaped;
29 while (<$file>) {
30 s/\x0D\x0A/\x0A/;
31 if (/^#data$/) {
32 undef $test;
33 $test->{data} = '';
34 $mode = 'data';
35 undef $escaped;
36 } elsif (/^#data escaped$/) {
37 undef $test;
38 $test->{data} = '';
39 $mode = 'data';
40 $escaped = 1;
41 } elsif (/^#errors$/) {
42 $test->{errors} = [];
43 $mode = 'errors';
44 $test->{data} =~ s/\x0D?\x0A\z//;
45 $test->{data} =~ s/\\u([0-9A-Fa-f]{4})/chr hex $1/ge if $escaped;
46 $test->{data} =~ s/\\U([0-9A-Fa-f]{8})/chr hex $1/ge if $escaped;
47 undef $escaped;
48 } elsif (/^#document$/) {
49 $test->{document} = '';
50 $mode = 'document';
51 undef $escaped;
52 } elsif (/^#document escaped$/) {
53 $test->{document} = '';
54 $mode = 'document';
55 $escaped = 1;
56 } elsif (defined $test->{document} and /^$/) {
57 $test->{document} =~ s/\\u([0-9A-Fa-f]{4})/chr hex $1/ge if $escaped;
58 $test->{document} =~ s/\\U([0-9A-Fa-f]{8})/chr hex $1/ge if $escaped;
59 test ($test);
60 undef $test;
61 } elsif (defined $test->{data} and /^$/) {
62 test ($test);
63 undef $test;
64 } else {
65 if ($mode eq 'data' or $mode eq 'document') {
66 $test->{$mode} .= $_;
67 } elsif ($mode eq 'errors') {
68 tr/\x0D\x0A//d;
69 push @{$test->{errors}}, $_;
70 }
71 }
72 }
73 test ($test);
74 }
75
76 sub test ($) {
77 my $test = shift;
78
79 $test->{document} =~ s/^\| //;
80 $test->{document} =~ s/[\x0D\x0A]\| /\x0A/g;
81
82 my @errors;
83
84 my $onerror = sub {
85 my %opt = @_;
86 push @errors, join ';',
87 ($opt{node} ? $opt{node}->get_user_data ('manakai_source_line') || $opt{line} : $opt{line} . '.' . $opt{column}) .
88 (defined $opt{value} ? ':' . $opt{value} : ''),
89 $opt{type}, $opt{level},
90 (defined $opt{text} ? ($opt{text}) : ());
91 };
92
93 my $p = Whatpm::WebIDL::Parser->new;
94 my $idl = $p->parse_char_string ($test->{data}, $onerror);
95
96 if (defined $test->{errors}) {
97 $idl->check ($onerror);
98
99 ok join ("\n", sort {$a cmp $b} @errors),
100 join ("\n", sort {$a cmp $b} @{$test->{errors}}), $test->{data};
101 }
102
103 if (defined $test->{document}) {
104 ok $idl->idl_text, $test->{document}, $test->{data};
105 }
106 } # test
107
108 ## License: Public Domain.
109 ## $Date: 2008/08/02 12:51:52 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24