/[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.2 - (hide annotations) (download) (as text)
Sat Aug 2 12:51:52 2008 UTC (16 years, 3 months ago) by wakaba
Branch: MAIN
Changes since 1.1: +3 -2 lines
File MIME type: application/x-troff
++ whatpm/t/ChangeLog	2 Aug 2008 12:51:15 -0000
	* WebIDL.t: Check whether |text| argument of the error
	is correct or not.

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

++ whatpm/t/webidl/ChangeLog	2 Aug 2008 12:51:46 -0000
	* webidl-interface.dat: More test data for interface inheritances
	and interface member identifier duplications.

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

++ whatpm/Whatpm/ChangeLog	2 Aug 2008 12:50:36 -0000
	* WebIDL.pm ($get_scoped_name): Now scoped names are stored
	in its stringified format ("scoped name" as defined in the
	spec).  Note that future version of this module should not use
	array references for type values and the |type_text| attribute
	should be made obsolete.
	(parse_char_string): Unescape attribute names.
	(check): Support for checking of whether inherited interfaces
	are actually defined or not.  Support for checking of whether
	interface member identifiers are duplicated or not.
	($serialize_type): Scoped names are returned as is.  A future
	version of this code should escape identifiers other than "DOMString",
	otherwise the idl_text would be non-conforming.

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

1 wakaba 1.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 wakaba 1.2 $opt{type}, $opt{level},
89     (defined $opt{text} ? ($opt{text}) : ());
90 wakaba 1.1 };
91    
92     my $p = Whatpm::WebIDL::Parser->new;
93     my $idl = $p->parse_char_string ($test->{data}, $onerror);
94    
95     if (defined $test->{errors}) {
96     $idl->check ($onerror);
97    
98     ok join ("\n", sort {$a cmp $b} @errors),
99     join ("\n", sort {$a cmp $b} @{$test->{errors}}), $test->{data};
100     }
101    
102     if (defined $test->{document}) {
103     ok $idl->idl_text, $test->{document}, $test->{data};
104     }
105     } # test
106    
107     ## License: Public Domain.
108 wakaba 1.2 ## $Date: 2008/08/02 06:03:26 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24