~ubuntu-branches/debian/sid/libxml-twig-perl/sid

« back to all changes in this revision

Viewing changes to t/test_comment_handler.t

  • Committer: Package Import Robot
  • Author(s): Bart Martens
  • Date: 2014-01-05 22:58:27 UTC
  • mfrom: (1.3.5)
  • Revision ID: package-import@ubuntu.com-20140105225827-k8vqp9bffrupmdj5
Tags: 1:3.44-1
* New upstream release.  Closes: #720457, #721395, #694523.
* debian/control: Updated Homepage.  Closes: #720616.
* debian/patches/series: Added.  Enables patches.
* debian/patches/07_691028.diff: Added.  Closes: #691028.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
use XML::Twig;
8
8
 
 
9
if( $] < 5.008)
 
10
  { warn "skipped, not tested under perl < 5.8\n"; print "1..1\nok 1\n"; exit 0; }
 
11
 
9
12
my $nb_tests=4;
10
13
print "1..$nb_tests\n";
11
14
 
 
15
{
12
16
my $result;
13
17
my $t= XML::Twig->new( comments => 'process',
14
18
                       twig_handlers => { '#COMMENT' => sub { $result .=$_->text; } },
21
25
  { print "not ok 1\n";
22
26
    warn "expected: $expected\nfound   : $result\n";
23
27
  }
 
28
}
24
29
 
25
 
$result='';
26
 
$t= XML::Twig->new( comments => 'process',
 
30
{
 
31
my $result='';
 
32
my $t= XML::Twig->new( comments => 'process',
27
33
                       twig_handlers => { '#COMMENT' => sub { $result .=$_->text; } },
28
34
                     );
29
35
$t->parse( q{<!-- comment in doc --><doc id="doc"></doc>});
30
 
$expected= ' comment in doc ';
 
36
my $expected= ' comment in doc ';
31
37
if( $result eq $expected)
32
38
  { print "ok 2\n"; }
33
39
else
34
40
  { print "not ok 2\n";
35
41
    warn "expected: $expected\nfound   : $result\n";
36
42
  }
 
43
}
37
44
 
38
 
$result='';
39
 
$t= XML::Twig->new( twig_handlers => { 'doc' => sub { $result= $_->{extra_data}; } },);
 
45
{
 
46
my $result='';
 
47
my $t= XML::Twig->new( twig_handlers => { 'doc' => sub { $result= $_->{extra_data}; } },);
40
48
$t->parse( q{<!-- comment in doc --><doc id="doc"></doc>});
41
 
$expected= '<!-- comment in doc -->';
 
49
my $expected= '<!-- comment in doc -->';
42
50
if( $result eq $expected)
43
51
  { print "ok 3\n"; }
44
52
else
45
53
  { print "not ok 3\n";
46
54
    warn "expected: $expected\nfound   : $result\n";
47
55
  }
48
 
 
49
 
 
50
 
$result='';
51
 
$t= XML::Twig->new( comments => 'process',
52
 
                    twig_roots => { '/#COMMENT' => sub { $result= $_->{extra_data}; },
53
 
                                    elt         => sub { },
54
 
                                  });
 
56
}
 
57
 
 
58
{
 
59
my $result='';
 
60
my $t= XML::Twig->new( comments => 'process',
 
61
                       twig_roots => { '/#COMMENT' => sub { $result= $_->{extra_data}; },
 
62
                                       elt         => sub { },
 
63
                                     });
55
64
$t->parse( q{<!-- comment in doc --><doc id="doc"><elt/></doc>});
56
 
$expected= '';  # This is a bug!
 
65
my $expected= '';  # This is a bug!
57
66
if( $result eq $expected)
58
67
  { print "ok 4\n"; }
59
68
else
60
69
  { print "not ok 4\n";
61
70
    warn "expected: $expected\nfound   : $result\n";
62
71
  }
 
72
}
 
73
 
63
74
exit 0;
64
75