line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package My::Module::Test; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1683
|
use strict; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
23
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
28
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
93
|
|
7
|
1
|
|
|
1
|
|
6
|
use Exporter qw{ import }; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
56
|
|
8
|
1
|
|
|
1
|
|
522
|
use Test::More 0.88; |
|
1
|
|
|
|
|
61539
|
|
|
1
|
|
|
|
|
8
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my @export = qw{ |
11
|
|
|
|
|
|
|
decode |
12
|
|
|
|
|
|
|
fails |
13
|
|
|
|
|
|
|
hexify |
14
|
|
|
|
|
|
|
returns |
15
|
|
|
|
|
|
|
round_trip |
16
|
|
|
|
|
|
|
}; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our @EXPORT = ( @export, @Test::More::EXPORT ); ## no critic (ProhibitAutomaticExportation) |
19
|
|
|
|
|
|
|
our @EXPORT_OK = ( @export, @Test::More::EXPORT_OK ); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub decode { |
22
|
12
|
|
|
12
|
1
|
5242
|
splice @_, 1, 0, 'decode'; |
23
|
12
|
|
|
|
|
31
|
goto &returns; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub fails { ## no critic (RequireArgUnpacking) |
27
|
10
|
|
|
10
|
1
|
25
|
my ( $obj, @args ) = @_; |
28
|
|
|
|
|
|
|
## my $opt = ref $args[0] eq 'HASH' ? shift @args : {}; |
29
|
10
|
50
|
|
|
|
23
|
ref $args[0] eq 'HASH' and shift @args; # $opt is unused |
30
|
10
|
|
|
|
|
14
|
my $method = shift @args; |
31
|
10
|
|
|
|
|
13
|
my $name = pop @args; |
32
|
10
|
|
|
|
|
11
|
my $want = pop @args; |
33
|
10
|
50
|
|
|
|
19
|
ref $want or $want = qr<@{[ quotemeta $want ]}>; |
|
10
|
|
|
|
|
161
|
|
34
|
10
|
|
|
|
|
21
|
local $@; |
35
|
10
|
|
|
|
|
40
|
eval { $obj->$method( @args ); 1 } |
|
0
|
|
|
|
|
0
|
|
36
|
10
|
50
|
|
|
|
11
|
and do { |
37
|
0
|
|
|
|
|
0
|
@_ = ( "$name did not throw an exception" ); |
38
|
0
|
|
|
|
|
0
|
goto &fail; |
39
|
|
|
|
|
|
|
}; |
40
|
10
|
|
|
|
|
197
|
@_ = ( $@, $want, $name ); |
41
|
10
|
|
|
|
|
33
|
goto &like; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub hexify { |
45
|
3
|
|
|
3
|
1
|
1274
|
splice @_, 1, 0, { unpack => 'H*' }; |
46
|
3
|
|
|
|
|
12
|
goto &returns; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub returns { ## no critic (RequireArgUnpacking) |
50
|
115
|
|
|
115
|
1
|
19615
|
my ( $obj, @args ) = @_; |
51
|
115
|
100
|
|
|
|
242
|
my $opt = ref $args[0] eq 'HASH' ? shift @args : {}; |
52
|
115
|
|
|
|
|
136
|
my $method = shift @args; |
53
|
115
|
|
|
|
|
121
|
my $name = pop @args; |
54
|
115
|
|
|
|
|
111
|
my $want = pop @args; |
55
|
115
|
|
|
|
|
106
|
my $got; |
56
|
115
|
|
|
|
|
325
|
eval { $got = $obj->$method( @args ); 1 } |
|
115
|
|
|
|
|
208
|
|
57
|
115
|
50
|
|
|
|
110
|
or do { |
58
|
0
|
|
|
|
|
0
|
@_ = ( "$name threw $@" ); |
59
|
0
|
|
|
|
|
0
|
goto &fail; |
60
|
|
|
|
|
|
|
}; |
61
|
|
|
|
|
|
|
$opt->{unpack} |
62
|
115
|
100
|
|
|
|
180
|
and $got = unpack $opt->{unpack}, $got; |
63
|
|
|
|
|
|
|
$opt->{sprintf} |
64
|
115
|
100
|
|
|
|
266
|
and $got = sprintf $opt->{sprintf}, $got; |
65
|
115
|
|
|
|
|
207
|
@_ = ( $got, $want, $name ); |
66
|
115
|
|
|
|
|
374
|
goto &is; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub round_trip { ## no critic (RequireArgUnpacking) |
70
|
41
|
|
|
41
|
1
|
19693
|
my ( $attr, $value, $opt ) = @_; |
71
|
41
|
|
100
|
|
|
154
|
$opt ||= {}; |
72
|
41
|
|
33
|
|
|
155
|
my $name = $opt->{name} || "Round-trip $attr( $value )"; |
73
|
|
|
|
|
|
|
my $utdf = eval { |
74
|
41
|
|
|
|
|
99
|
my $obj = Astro::UTDF->new( $attr => $value ); |
75
|
41
|
|
|
|
|
79
|
return Astro::UTDF->new( raw_record => $obj->raw_record() ); |
76
|
41
|
50
|
|
|
|
46
|
} or do { |
77
|
0
|
|
|
|
|
0
|
@_ = ( "$name threw $@" ); |
78
|
0
|
|
|
|
|
0
|
goto &fail; |
79
|
|
|
|
|
|
|
}; |
80
|
41
|
|
|
|
|
165
|
@_ = ( $utdf, $opt, $attr, $value, $name ); |
81
|
41
|
|
|
|
|
91
|
goto &returns; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
__END__ |