Test::HTCT::Parser - A parser for test data in HTML Tree Construction Tests format
use Test::HTCT::Parser;
for_each_test $file_name, {
data => {},
errors => {is_list => 1},
document => {is_prefixed => 1},
'document-fragment' => {is_prefixed => 1},
}, sub {
my $test = shift;
my ($serialized, $errors) = parse_data ($test->{data}->[0]);
is $serialized, $test->{document}->[0];
is_deeply $errors, $test->{errors}->[0];
};
The Test::HTCT::Parser
module exports a function to parse test data file encoded in the format for HTML Parsers' Tree Construction Tests. It can also be used to parse test data for other purposes than HTML parsing.
For more information on the usage of the module, see t/test-htct-parser.t
test script.
The callback code is invoked for each test, in order in the input test data file. It is invoked with two arguments.
The first argument $_[0]
represents the test data.
The second argument $_[1]
has additional data. It is a hash reference with a key/value pair: line_number
is the line number of the first line of the test data in the input test data file.
WHATWG Wiki, Parser tests, Tree Constructoion Tests <https://wiki.whatwg.org/wiki/Parser_tests#Tree_Construction_Tests>.
HTML Parser Tree Constructions Tests (from html5lib repository) <http://html5lib.googlecode.com/svn/trunk/testdata/tree-construction/>.
sami-test.js, which is a JavaScript implementation of the format <https://github.com/wakaba/samijs/blob/master/sami/script/sami-test.js>.
The latest version of the module is available from the GitHub repository: <https://github.com/wakaba/testdataparser>.
The module requires Perl 5.8 or later.
Wakaba <wakaba@suikawiki.org>.
The format was originally defined by WHATWG/html5lib contributors.
The parser was originally developed as part of Whatpm::HTML HTML parser module, which is part of the manakai package <https://suika.suikawiki.org/www/manakai-core/doc/web/>.
The first version, 1.0
, as a standalone module with new name Test::HTCT::Parser is released on February 19, 2011.
The second version, 2.0
, added support for multiple
fields.
This repository was located at <https://github.com/wakaba/testdataparser> until it has been transferred to the manakai project on Nobember 4, 2021.
Copyright 2007-2021 Wakaba <wakaba@suikawiki.org>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.