File: 20factory.t

package info (click to toggle)
libxml-sax-perl 0.99%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch, wheezy
  • size: 556 kB
  • ctags: 218
  • sloc: perl: 2,374; sh: 127; xml: 121; makefile: 5
file content (42 lines) | stat: -rw-r--r-- 1,064 bytes parent folder | download | duplicates (8)
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
37
38
39
40
41
42
use Test;
BEGIN { plan tests => 16 }
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(!$@);

local $XML::SAX::ParserPackage = 'XML::SAX::PurePerl';
ok(XML::SAX::ParserFactory->parser);

local $XML::SAX::ParserPackage = 'XML::SAX::PurePerl (0.01)';
ok(XML::SAX::ParserFactory->parser);