Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 57 lines (40 sloc) 1.702 kB
343e66b @rjray First round of Devel::Cover-inspired improvements.
authored
1 #!/usr/bin/perl
2
3 # Test the RPC::XML::Parser class negative conditions
4
5 use strict;
6 use warnings;
7 use vars qw($p $retval);
8
9 use Test::More tests => 14;
10
11 # Create a dummy class to use for attempts to call methods within the
12 # RPC::XML::Parser class:
13 package BadParser;
14
15 use base 'RPC::XML::Parser';
16
17 package main;
18
19 # This is the pattern we are looking for in the error messages:
20 my $errtext = qr/should have been overridden by the BadParser class/;
21
22 # First, the constructor:
23 eval { $p = BadParser->new() };
24 ok(! defined $p, 'RPC::XML::Parser did not instantiate');
25 like($@, $errtext, 'Correctly-set error message in $@');
26
27 # Fine! We'll *force* an object into that class:
28 $p = bless {}, 'BadParser';
29
30 # *Now* try and stop me from calling methods!
31 $retval = eval { $p->parse(); 1 };
32 ok(! $retval, '::parse correctly failed to run');
33 like($@, $errtext, 'Correctly-set error message in $@');
34
35 $retval = eval { $p->parse_more(); 1 };
36 ok(! $retval, '::parse_more correctly failed to run');
37 like($@, $errtext, 'Correctly-set error message in $@');
38
39 $retval = eval { $p->parse_done(); 1 };
40 ok(! $retval, '::parse_done correctly failed to run');
41 like($@, $errtext, 'Correctly-set error message in $@');
42
43 # Try them as static methods:
44 $retval = eval { BadParser->parse(); 1 };
45 ok(! $retval, '::parse correctly failed to run');
46 like($@, $errtext, 'Correctly-set error message in $@');
47
48 $retval = eval { BadParser->parse_more(); 1 };
49 ok(! $retval, '::parse_more correctly failed to run');
50 like($@, $errtext, 'Correctly-set error message in $@');
51
52 $retval = eval { BadParser->parse_done(); 1 };
53 ok(! $retval, '::parse_done correctly failed to run');
54 like($@, $errtext, 'Correctly-set error message in $@');
55
56 exit;
Something went wrong with that request. Please try again.