line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
14154
|
use 5.008; |
|
1
|
|
|
|
|
3
|
|
2
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
67
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Test::Compiles; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
8
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
351
|
use Exporter::Shiny our @EXPORT = qw( compiles doesnt_compile ); |
|
1
|
|
|
|
|
2927
|
|
|
1
|
|
|
|
|
8
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $PRELUDE = ''; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
require Test::More; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub compiles { |
17
|
13
|
100
|
|
13
|
1
|
2732
|
@_ % 2 or splice(@_, 1, 0, 'message'); |
18
|
13
|
|
|
|
|
36
|
my ($code, %opts) = @_; |
19
|
|
|
|
|
|
|
|
20
|
13
|
|
33
|
|
|
60
|
my $package = $opts{package} || caller; |
21
|
|
|
|
|
|
|
|
22
|
13
|
|
50
|
|
|
63
|
my $prepend = $PRELUDE || $opts{prelude} || ''; |
23
|
|
|
|
|
|
|
$prepend .= ';use strict' |
24
|
13
|
100
|
66
|
|
|
62
|
if $opts{strict} || !exists $opts{strict}; |
25
|
|
|
|
|
|
|
$prepend .= ';use warnings FATAL => qw(all)' |
26
|
13
|
100
|
|
|
|
44
|
if $opts{warnings}; |
27
|
|
|
|
|
|
|
|
28
|
13
|
|
|
|
|
78
|
my $rand = 100_000 + int rand 900_000; |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
|
|
|
0
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
|
1
|
|
|
|
|
17
|
|
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
65
|
|
|
13
|
|
|
|
|
916
|
|
34
|
|
|
|
|
|
|
. "$prepend;\n;" |
35
|
|
|
|
|
|
|
. "$code;\n;" |
36
|
|
|
|
|
|
|
. "BEGIN { die \"ERROR$rand\" };\n;"; |
37
|
13
|
|
|
|
|
77
|
$@; |
38
|
|
|
|
|
|
|
}; |
39
|
|
|
|
|
|
|
my $result = ( |
40
|
13
|
|
|
|
|
200
|
!$opts{should_fail} == !!($e =~ /\AERROR$rand\b/) |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
13
|
50
|
|
|
|
45
|
if (!$result) { |
44
|
0
|
0
|
|
|
|
0
|
Test::More::diag($opts{should_fail} ? "no error encountered": "error: $e"); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
$opts{message} ||= $opts{should_fail} |
48
|
13
|
100
|
66
|
|
|
53
|
? "code shouldn't compile" |
49
|
|
|
|
|
|
|
: "code should compile"; |
50
|
|
|
|
|
|
|
|
51
|
13
|
|
|
|
|
45
|
@_ = ($result, $opts{message}); |
52
|
13
|
|
|
|
|
66
|
goto \&Test::More::ok; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub doesnt_compile { |
56
|
7
|
100
|
|
7
|
1
|
4167
|
@_ % 2 or splice(@_, 1, 0, 'message'); |
57
|
7
|
|
|
|
|
21
|
my ($code, %opts) = @_; |
58
|
7
|
|
|
|
|
17
|
$opts{should_fail} = !$opts{should_fail}; |
59
|
7
|
|
|
|
|
23
|
@_ = ($code, %opts); |
60
|
7
|
|
|
|
|
26
|
goto \&compiles; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |