File: 20factory.t

package info (click to toggle)
libxml-sax-perl 0.10-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 576 kB
  • ctags: 191
  • sloc: perl: 2,611; xml: 1,533; makefile: 35; sh: 28
file content (36 lines) | stat: -rw-r--r-- 871 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use Test;
BEGIN { plan tests => 14 }
use XML::SAX::ParserFactory;

# load SAX parsers (no ParserDetails.ini available at first in blib)
use XML::SAX qw(Namespaces Validation);
ok(@{XML::SAX->parsers}, 0);
ok(XML::SAX->add_parser(q(XML::SAX::PurePerl)));
ok(@{XML::SAX->parsers}, 1);

ok(XML::SAX::ParserFactory->parser); # test class method
my $factory = XML::SAX::ParserFactory->new();
ok($factory);
ok($factory->parser);

ok($factory->require_feature(Namespaces));
ok($factory->parser);

ok($factory->require_feature(Validation));
eval {
    my $parser = $factory->parser;
    # should never get here unless PurePerl starts providing validation
    ok(!$parser);
};
ok($@);
ok($@->isa('XML::SAX::Exception'));

$factory = XML::SAX::ParserFactory->new();
my $parser = $factory->parser;
ok($parser);
eval {
    $parser->parse_string('<widget/>');
    ok(1);
};
ok(!$@);