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

« back to all changes in this revision

Viewing changes to t/test_errors.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:
14
14
 
15
15
use XML::Twig;
16
16
 
17
 
my $TMAX=110; 
 
17
my $TMAX=119; 
18
18
print "1..$TMAX\n";
19
19
 
20
20
my $error_file= File::Spec->catfile('t','test_errors.errors');
84
84
}
85
85
 
86
86
{ eval {XML::Twig->new( keep_spaces => 1, discard_spaces => 1 )};
87
 
  matches( $@, "cannot use both keep_spaces and discard_spaces", "invalid option combination 1");
 
87
  matches( $@, "cannot use both keep_spaces and discard_spaces", "invalid option combination keep_spaces and discard_spaces");
 
88
  eval {XML::Twig->new( keep_spaces => 1, discard_all_spaces => 1 )};
 
89
  matches( $@, "cannot use both keep_spaces and discard_all_spaces", "invalid option combination keep_spaces and discard_all_spaces");
88
90
  eval {XML::Twig->new( keep_spaces => 1, keep_spaces_in => ['p'])};
89
 
  matches( $@, "cannot use both keep_spaces and keep_spaces_in", "invalid option combination 2");
 
91
  matches( $@, "cannot use both keep_spaces and keep_spaces_in", "invalid option combination keep_spaces and keep_spaces_in");
 
92
  eval {XML::Twig->new( discard_spaces => 1, discard_all_spaces => 1)};
 
93
  matches( $@, "cannot use both discard_spaces and discard_all_spaces", "invalid option combination discard_spaces and discard_all_spaces");
90
94
  eval {XML::Twig->new( discard_spaces => 1, keep_spaces_in => ['p'])};
91
 
  matches( $@, "cannot use both discard_spaces and keep_spaces_in", "invalid option combination 3");
 
95
  matches( $@, "cannot use both discard_spaces and keep_spaces_in", "invalid option combination discard_spaces and keep_spaces_in");
92
96
  eval {XML::Twig->new( keep_spaces_in => [ 'doc' ], discard_spaces_in => ['p'])};
93
 
  matches( $@, "cannot use both keep_spaces_in and discard_spaces_in", "invalid option combination 4");
 
97
  matches( $@, "cannot use both keep_spaces_in and discard_spaces_in", "invalid option combination keep_spaces_in and discard_spaces_in");
 
98
  eval {XML::Twig->new( discard_spaces => 1, discard_spaces_in => ['p'])};
 
99
  matches( $@, "cannot use both discard_spaces and discard_spaces_in", "invalid option combination discard_spaces and discard_spaces_in");
 
100
  eval {XML::Twig->new( keep_spaces_in => [ 'doc' ], discard_all_spaces => 1)};
 
101
  matches( $@, "cannot use both keep_spaces_in and discard_all_spaces", "invalid option combination keep_spaces_in and discard_all_spaces");
 
102
  eval {XML::Twig->new( discard_all_spaces => 1, discard_spaces_in => ['p'])};
 
103
  matches( $@, "cannot use both discard_all_spaces and discard_spaces_in", "invalid option combination discard_all_spaces and discard_spaces_in");
94
104
  eval {XML::Twig->new( comments => 'wrong') };
95
105
  matches( $@, "wrong value for comments argument: 'wrong'", "invalid option value for comment");
96
106
  eval {XML::Twig->new( pi => 'wrong') };
97
107
  matches( $@, "wrong value for pi argument: 'wrong'", "invalid option value for pi");
 
108
 
98
109
}
99
110
 
100
111
{ my $t=XML::Twig->new->parse( '<doc><p> p1</p><p>p 2</p></doc>');
139
150
    }
140
151
}
141
152
 
 
153
{ my $t= XML::Twig->new->parse( '<doc/>');
 
154
  eval { XML::Twig->parse( twig_handlers => { q{foo[@a="$sd"]} => sub {  } }, "<foo/>"); };
 
155
  matches( $@, "^wrong handler condition", 'perl syntax in attribute value');
 
156
}
 
157
 
142
158
{ my $t= XML::Twig->new->parse( '<doc><field/></doc>');
143
159
  eval { $t->root->set_field( '*[2]'); };
144
160
  matches( $@, "can't create a field name from", 'set_field');
306
322
    }
307
323
}
308
324
 
 
325
{ my $e1= XML::Twig::Elt->new( 'foo');
 
326
  my $e2= XML::Twig::Elt->new( 'foo');
 
327
 
 
328
  eval { $e1->paste_before( $e2); };
 
329
  matches( $@, "cannot paste before an orphan element", 'paste before an orphan element' );
 
330
 
 
331
  eval { $e1->paste_after( $e2); };
 
332
  matches( $@, "cannot paste after an orphan element", 'paste after an orphan element' );
 
333
}
 
334
 
 
335
{ my $r=  XML::Twig->parse( '<doc/>')->root;
 
336
  eval { $r->find_nodes( '//foo/following::') };
 
337
  matches( $@, "error in xpath expression", 'error in xpath expression');
 
338
}
 
339
 
309
340
exit 0;
310
341
 
311
342
sub can_check_for_pipes