Debian Codegraph @

t/60error_prev_chain.t

raw
1 # This test script checks for:
2 #
3 # https://rt.cpan.org/Ticket/Display.html?id=56671 .
4 #
5 # It makes sure an error chain cannot be too long, because if it is it consumes
6 # a lot of RAM.
7
8 use strict;
9 use warnings;
10
11 no warnings 'recursion';
12
13 use Test::More;
14
15 use XML::LibXML;
16
17 {
18 my $parser = XML::LibXML->new();
19 $parser->validation(0);
20 $parser->load_ext_dtd(0);
21
22 eval
23 {
24 local $^W = 0;
25 $parser->parse_file('example/JBR-ALLENtrees.htm');
26 };
27
28 my $err = $@;
29 my $count = 0;
30
31 if( $err && !ref($err) ) {
32 plan skip_all => 'The local libxml library does not support errors as objects to $@';
33 }
34 plan tests => 1;
35
36 while (defined($err) && $count < 200)
37 {
38 $err = $err->_prev();
39 }
40 continue
41 {
42 $count++;
43 }
44
45 # TEST
46 ok ((!$err), "Reached the end of the chain.");
47 }
48
49 =head1 COPYRIGHT & LICENSE
50
51 Copyright 2011 by Shlomi Fish
52
53 This program is distributed under the MIT (X11) License:
54 L<http://www.opensource.org/licenses/mit-license.php>
55
56 Permission is hereby granted, free of charge, to any person
57 obtaining a copy of this software and associated documentation
58 files (the "Software"), to deal in the Software without
59 restriction, including without limitation the rights to use,
60 copy, modify, merge, publish, distribute, sublicense, and/or sell
61 copies of the Software, and to permit persons to whom the
62 Software is furnished to do so, subject to the following
63 conditions:
64
65 The above copyright notice and this permission notice shall be
66 included in all copies or substantial portions of the Software.
67
68 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
69 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
70 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
71 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
72 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
73 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
74 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
75 OTHER DEALINGS IN THE SOFTWARE.
76
77 =cut