line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MyTest; |
2
|
9
|
|
|
9
|
|
24075
|
use strict; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
335
|
|
3
|
|
|
|
|
|
|
|
4
|
9
|
|
|
9
|
|
10172
|
use Test qw< plan ok skip >; |
|
9
|
|
|
|
|
41014
|
|
|
9
|
|
|
|
|
923
|
|
5
|
9
|
|
|
9
|
|
77
|
use vars qw< @EXPORT_OK >; |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
610
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN { |
8
|
9
|
|
|
9
|
|
32
|
@EXPORT_OK= qw< plan ok skip Ok SkipIf Eval Dies >; |
9
|
9
|
|
|
|
|
45
|
require Exporter; |
10
|
9
|
|
|
|
|
4207
|
*import= \&Exporter::import; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$|= 1; |
14
|
|
|
|
|
|
|
for my $base ( '', '../' ) { |
15
|
|
|
|
|
|
|
if( -d $base.'blib/arch' || -d $base.'blib/lib' ) { |
16
|
|
|
|
|
|
|
require lib; |
17
|
|
|
|
|
|
|
lib->import( $base.'blib/arch', $base.'blib/lib' ); |
18
|
|
|
|
|
|
|
last; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
return 1; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub Ok($;$$) { |
26
|
69
|
100
|
|
69
|
0
|
13499
|
@_= @_ < 3 ? reverse @_ : @_[1,0,2]; |
27
|
69
|
|
|
|
|
266
|
return &ok(@_); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub SkipIf($;$$$) { |
32
|
2
|
|
|
2
|
0
|
303
|
my $skip= shift @_; |
33
|
2
|
50
|
33
|
|
|
7
|
die "Can't not skip a non-test" |
34
|
|
|
|
|
|
|
if ! $skip && ! @_; |
35
|
2
|
50
|
33
|
|
|
6
|
$skip= 'Prior test failed' |
36
|
|
|
|
|
|
|
if $skip && 1 eq $skip; |
37
|
2
|
50
|
|
|
|
8
|
@_= @_ < 3 ? reverse @_ : @_[1,0,2]; |
38
|
2
|
|
|
|
|
9
|
return &skip( $skip, @_ ); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub Eval { |
43
|
1
|
|
|
1
|
0
|
325
|
my( $code, $desc )= @_; |
44
|
1
|
|
33
|
|
|
4
|
$desc ||= $code; |
45
|
1
|
|
|
|
|
3
|
my( $pkg, $file, $line )= caller(); |
46
|
1
|
|
|
|
|
2
|
++$line; |
47
|
1
|
|
|
|
|
23
|
my $eval= qq(\n#line $line "$file"\n) . $code . "\n1;\n"; |
48
|
1
|
|
|
|
|
59
|
Ok( 1, eval $eval, "Should not die:\n$desc\n$@" ); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub Dies { |
53
|
2
|
|
|
2
|
0
|
347
|
my( $code, $omen, $desc )= @_; |
54
|
|
|
|
|
|
|
#if( ref $code ) { |
55
|
|
|
|
|
|
|
# SkipIf( |
56
|
|
|
|
|
|
|
# ! Ok( undef, eval { $code->() }, "Should die:\n$desc" ), |
57
|
|
|
|
|
|
|
# $omen, $@, "Error from:\n$desc", |
58
|
|
|
|
|
|
|
# ); |
59
|
|
|
|
|
|
|
#} |
60
|
2
|
|
66
|
|
|
10
|
$desc ||= $code; |
61
|
2
|
|
|
|
|
4
|
my( $pkg, $file, $line )= caller(); |
62
|
2
|
|
|
|
|
5
|
++$line; |
63
|
2
|
|
|
|
|
7
|
my $eval= qq(\n#line $line "$file"\n) . $code . "\n1;\n"; |
64
|
2
|
|
|
|
|
97
|
SkipIf( |
65
|
|
|
|
|
|
|
! Ok( undef, eval $eval, "Should die:\n$desc" ), |
66
|
|
|
|
|
|
|
$omen, $@, "Error from:\n$desc", |
67
|
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
} |