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

Contents of /markup/html/whatpm/t/SWML-Parser.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download) (as text)
Fri Nov 7 08:45:28 2008 UTC (16 years, 8 months ago) by wakaba
Branch: MAIN
Changes since 1.1: +2 -1 lines
File MIME type: application/x-troff
++ whatpm/t/ChangeLog	7 Nov 2008 08:45:01 -0000
	* SWML-Parser.t: Test file |swml/blocks-1.dat| added.

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

++ whatpm/t/swml/ChangeLog	7 Nov 2008 08:45:13 -0000
	* structs-1.dat: More test data added.

	* blocks-1.dat: New file.

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

++ whatpm/Whatpm/ChangeLog	7 Nov 2008 08:43:32 -0000
2008-11-07  Wakaba  <wakaba@suika.fam.cx>

	* NanoDOM.pm (text_content): Don't create a Text node if the new
	value is empty.

++ whatpm/Whatpm/HTML/ChangeLog	7 Nov 2008 08:43:49 -0000
2008-11-07  Wakaba  <wakaba@suika.fam.cx>

	* Dumper.pm (dumptree): Support for namespace abbreviation for
	SWML namespaces.

++ whatpm/Whatpm/SWML/ChangeLog	7 Nov 2008 08:44:20 -0000
	* Parser.pm: Bug fixes - both parser implementation bugs and spec
	bugs.

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

1 wakaba 1.1 #!/usr/bin/perl
2     use strict;
3    
4     my $test_dir_name = 't/swml/';
5    
6     use Test;
7     BEGIN { plan tests => 1573 }
8    
9     use Data::Dumper;
10     $Data::Dumper::Useqq = 1;
11     sub Data::Dumper::qquote {
12     my $s = shift;
13     $s =~ s/([^\x20\x21-\x26\x28-\x5B\x5D-\x7E])/sprintf '\x{%02X}', ord $1/ge;
14     return q<qq'> . $s . q<'>;
15     } # Data::Dumper::qquote
16    
17     use Whatpm::SWML::Parser;
18     use Whatpm::NanoDOM;
19     use Whatpm::HTML::Dumper qw/dumptree/;
20    
21     sub test ($) {
22     my $test = shift;
23    
24     my $doc = Whatpm::NanoDOM::Document->new;
25     my @errors;
26    
27     $SIG{INT} = sub {
28     print scalar dumptree ($doc);
29     exit;
30     };
31    
32     my $onerror = sub {
33     my %opt = @_;
34     push @errors, join ';',
35     $opt{token}->{line} || $opt{line},
36     $opt{token}->{column} || $opt{column},
37     $opt{type},
38     defined $opt{text} ? $opt{text} : '',
39     defined $opt{value} ? $opt{value} : '',
40     $opt{level};
41     };
42    
43     my $p = Whatpm::SWML::Parser->new;
44     $p->parse_char_string ($test->{data}->[0] => $doc, $onerror);
45     my $result = dumptree ($doc);
46    
47     warn "No #errors section ($test->{data}->[0])" unless $test->{errors};
48    
49     @errors = sort {$a cmp $b} @errors;
50     @{$test->{errors}->[0]} = sort {$a cmp $b} @{$test->{errors}->[0] ||= []};
51    
52     ok join ("\n", @errors), join ("\n", @{$test->{errors}->[0] or []}),
53     'Parse error: ' . Data::Dumper::qquote ($test->{data}->[0]);
54    
55     $test->{document}->[0] .= "\x0A" if length $test->{document}->[0];
56     ok $result, $test->{document}->[0],
57     'Document tree: ' . Data::Dumper::qquote ($test->{data}->[0]);
58     } # test
59    
60     my @FILES = grep {$_} split /\s+/, qq[
61     ${test_dir_name}structs-1.dat
62 wakaba 1.2 ${test_dir_name}blocks-1.dat
63 wakaba 1.1 ];
64    
65     require 't/testfiles.pl';
66     execute_test ($_, {
67     data => {is_prefixed => 1},
68     errors => {is_list => 1},
69     document => {is_prefixed => 1},
70     }, \&test) for @FILES;
71    
72     ## License: Public Domain.
73 wakaba 1.2 ## $Date: 2008/11/07 04:03:16 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24