| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
154
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
24
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
79
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
732
|
use lib qw(lib t t/lib); |
|
|
1
|
|
|
|
|
707
|
|
|
|
1
|
|
|
|
|
5
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
1277
|
use Test::More; |
|
|
1
|
|
|
|
|
49445
|
|
|
|
1
|
|
|
|
|
12
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
BEGIN { |
|
12
|
1
|
|
|
1
|
|
649
|
eval "use Test::Exception;"; |
|
|
1
|
|
|
1
|
|
493
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
1
|
50
|
|
|
|
8
|
if ($@) { |
|
15
|
1
|
|
|
|
|
6
|
plan skip_all => 'Test::Exception needed'; |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# data source for tests |
|
20
|
|
|
|
|
|
|
my $runtime_class = 'Syntax::X'; |
|
21
|
|
|
|
|
|
|
my %subclasses = ( |
|
22
|
|
|
|
|
|
|
'Parameters' => qr{Missing parameters}, |
|
23
|
|
|
|
|
|
|
'Parameters::None' => qr{Missing all}, |
|
24
|
|
|
|
|
|
|
'Parameters::Source' => qr{Missing source}, |
|
25
|
|
|
|
|
|
|
'Parameters::Wrong' => { |
|
26
|
|
|
|
|
|
|
regex => qr{Wrong value}, |
|
27
|
|
|
|
|
|
|
params => { |
|
28
|
|
|
|
|
|
|
parameter => q(page), |
|
29
|
|
|
|
|
|
|
value => q(esta/pagina/no/existe), |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
}, |
|
32
|
|
|
|
|
|
|
'Engine' => qr{external engine}, |
|
33
|
|
|
|
|
|
|
'Engine::Use' => qr{Could not use the module}, |
|
34
|
|
|
|
|
|
|
'Engine::Language' => qr{Unsupported syntax of language}, |
|
35
|
|
|
|
|
|
|
'Template' => qr{Not access to or not found template}, |
|
36
|
|
|
|
|
|
|
); |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
plan tests => (scalar keys %subclasses) + 1; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# test the package load |
|
41
|
|
|
|
|
|
|
my $class = 'IkiWiki::Plugin::syntax::X'; |
|
42
|
|
|
|
|
|
|
use_ok( $class ); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
foreach my $subclass (keys %subclasses) { |
|
45
|
|
|
|
|
|
|
my $full_class = "${runtime_class}::${subclass}"; |
|
46
|
|
|
|
|
|
|
my ( $regex, $text, %params ); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# get the description from the class |
|
49
|
|
|
|
|
|
|
$text = $full_class . " - " . $full_class->description(); |
|
50
|
|
|
|
|
|
|
%params = (); |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# extract regex and fields from the tests hash |
|
53
|
|
|
|
|
|
|
if (ref $subclasses{$subclass} eq 'HASH') { |
|
54
|
|
|
|
|
|
|
$regex = $subclasses{$subclass}->{regex}; |
|
55
|
|
|
|
|
|
|
%params = exists $subclasses{$subclass}->{params} |
|
56
|
|
|
|
|
|
|
? %{ $subclasses{$subclass}->{params} } |
|
57
|
|
|
|
|
|
|
: (); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
else { |
|
60
|
|
|
|
|
|
|
$regex = $subclasses{$subclass}; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# raise the exception and check the results |
|
64
|
|
|
|
|
|
|
throws_ok { raise_exception( $full_class, %params ) } $regex, $text; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub raise_exception { |
|
68
|
|
|
|
|
|
|
my $class = shift; |
|
69
|
|
|
|
|
|
|
my @params = @_; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
$class->throw(@params); |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|