line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#! perl |
2
|
|
|
|
|
|
|
|
3
|
80
|
|
|
80
|
|
1212088
|
use strict; |
|
80
|
|
|
|
|
645
|
|
|
80
|
|
|
|
|
2591
|
|
4
|
80
|
|
|
80
|
|
427
|
use warnings; |
|
80
|
|
|
|
|
198
|
|
|
80
|
|
|
|
|
2154
|
|
5
|
80
|
|
|
80
|
|
445
|
use utf8; |
|
80
|
|
|
|
|
187
|
|
|
80
|
|
|
|
|
472
|
|
6
|
80
|
|
|
80
|
|
2098
|
use Carp; |
|
80
|
|
|
|
|
171
|
|
|
80
|
|
|
|
|
7829
|
|
7
|
|
|
|
|
|
|
|
8
|
80
|
|
|
80
|
|
39923
|
use FindBin; |
|
80
|
|
|
|
|
97427
|
|
|
80
|
|
|
|
|
5054
|
|
9
|
80
|
|
|
80
|
|
35711
|
use lib "$FindBin::Bin/../lib"; |
|
80
|
|
|
|
|
58616
|
|
|
80
|
|
|
|
|
595
|
|
10
|
80
|
|
|
80
|
|
13609
|
use lib "$FindBin::Bin/../lib/ChordPro/lib"; |
|
80
|
|
|
|
|
204
|
|
|
80
|
|
|
|
|
494
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
binmode STDOUT => ':utf8'; |
13
|
|
|
|
|
|
|
binmode STDERR => ':utf8'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
package ChordPro::Testing; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = "6.000"; |
18
|
|
|
|
|
|
|
|
19
|
80
|
|
|
80
|
|
15038
|
use base 'Exporter'; |
|
80
|
|
|
|
|
161
|
|
|
80
|
|
|
|
|
11825
|
|
20
|
|
|
|
|
|
|
our @EXPORT = qw( $config ); |
21
|
|
|
|
|
|
|
|
22
|
80
|
|
|
80
|
|
48498
|
use Test::More (); |
|
80
|
|
|
|
|
7486607
|
|
|
80
|
|
|
|
|
3191
|
|
23
|
|
|
|
|
|
|
|
24
|
80
|
|
|
80
|
|
40208
|
use App::Packager ( ':name', 'ChordPro' ); |
|
80
|
|
|
|
|
226362
|
|
|
80
|
|
|
|
|
581
|
|
25
|
80
|
|
|
80
|
|
66701
|
use ChordPro::Config; |
|
80
|
|
|
|
|
1720
|
|
|
80
|
|
|
|
|
8839
|
|
26
|
80
|
|
|
80
|
|
634
|
use ChordPro::Chords; |
|
80
|
|
|
|
|
1412
|
|
|
80
|
|
|
|
|
47626
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub import { |
29
|
80
|
|
|
80
|
|
1068
|
my $pkg = shift; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# This is dirty... |
32
|
80
|
100
|
|
|
|
4629
|
-d "t" && chdir "t"; |
33
|
|
|
|
|
|
|
|
34
|
80
|
|
|
|
|
438
|
$::running_under_test = 1; |
35
|
80
|
|
|
|
|
8268
|
App::Packager->export_to_level(1); |
36
|
80
|
|
|
|
|
14547
|
Test::More->export_to_level(1); |
37
|
80
|
|
|
|
|
42024
|
$pkg->export_to_level( 1, undef, @EXPORT ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub is_deeply { |
41
|
79
|
|
|
79
|
0
|
75085
|
my ( $got, $expect, $tag ) = @_; |
42
|
|
|
|
|
|
|
|
43
|
79
|
100
|
66
|
|
|
602
|
if ( ref($got) eq 'HASH' && ref($expect) eq 'HASH' ) { |
44
|
66
|
100
|
|
|
|
399
|
fixchords($got) if $got->{body}; |
45
|
|
|
|
|
|
|
|
46
|
66
|
|
|
|
|
221
|
for ( qw( config ) ) { |
47
|
66
|
50
|
|
|
|
423
|
delete $got->{$_} unless exists $expect->{$_}; |
48
|
|
|
|
|
|
|
} |
49
|
66
|
100
|
|
|
|
282
|
if ( $got->{chordsinfo} ) { |
50
|
64
|
100
|
100
|
|
|
125
|
if ( !%{$got->{chordsinfo}} && !$expect->{chordsinfo} ) { |
51
|
30
|
|
|
|
|
120
|
delete $got->{chordsinfo}; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
else { |
54
|
34
|
|
|
|
|
81
|
foreach ( keys %{ $got->{chordsinfo} } ) { |
|
34
|
|
|
|
|
157
|
|
55
|
89
|
|
|
|
|
297
|
$got->{chordsinfo}{$_} = $got->{chordsinfo}{$_}->name; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
66
|
|
|
|
|
265
|
for ( qw( instrument user key_from key_actual chords numchords ) ) { |
60
|
396
|
50
|
|
|
|
1110
|
delete $got->{meta}->{$_} unless exists $expect->{meta}->{$_}; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
79
|
|
|
|
|
413
|
Test::More::is_deeply( $got, $expect, $tag ); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
push( @EXPORT, 'is_deeply' ); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub testconfig { |
70
|
|
|
|
|
|
|
# May change later. |
71
|
80
|
|
|
80
|
0
|
362
|
ChordPro::Config::configurator; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
push( @EXPORT, 'testconfig' ); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
our $config = testconfig(); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
ChordPro::Chords::add_config_chord |
79
|
|
|
|
|
|
|
( { name => "NC", base => 1, frets => [ (-1)x6 ], fingers => [] } ); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
{ |
82
|
80
|
|
|
80
|
|
690
|
no warnings 'redefine'; |
|
80
|
|
|
|
|
183
|
|
|
80
|
|
|
|
|
33065
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub getresource { |
85
|
11
|
|
|
11
|
|
4781
|
App::Packager::U_GetResource(@_); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
push( @EXPORT, 'getresource' ); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub cmp { |
92
|
|
|
|
|
|
|
# Perl version of the 'cmp' program. |
93
|
|
|
|
|
|
|
# Returns 1 if the files differ, 0 if the contents are equal. |
94
|
0
|
|
|
0
|
0
|
0
|
my ($old, $new) = @_; |
95
|
0
|
0
|
|
|
|
0
|
unless ( open (F1, $old) ) { |
96
|
0
|
|
|
|
|
0
|
print STDERR ("$old: $!\n"); |
97
|
0
|
|
|
|
|
0
|
return 1; |
98
|
|
|
|
|
|
|
} |
99
|
0
|
0
|
|
|
|
0
|
unless ( open (F2, $new) ) { |
100
|
0
|
|
|
|
|
0
|
print STDERR ("$new: $!\n"); |
101
|
0
|
|
|
|
|
0
|
return 1; |
102
|
|
|
|
|
|
|
} |
103
|
0
|
|
|
|
|
0
|
my ($buf1, $buf2); |
104
|
0
|
|
|
|
|
0
|
my ($len1, $len2); |
105
|
0
|
|
|
|
|
0
|
while ( 1 ) { |
106
|
0
|
|
|
|
|
0
|
$len1 = sysread (F1, $buf1, 10240); |
107
|
0
|
|
|
|
|
0
|
$len2 = sysread (F2, $buf2, 10240); |
108
|
0
|
0
|
0
|
|
|
0
|
return 0 if $len1 == $len2 && $len1 == 0; |
109
|
0
|
0
|
0
|
|
|
0
|
return 1 if $len1 != $len2 || ( $len1 && $buf1 ne $buf2 ); |
|
|
|
0
|
|
|
|
|
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
80
|
|
|
80
|
|
1946
|
use File::LoadLines qw( loadlines ); |
|
80
|
|
|
|
|
1554
|
|
|
80
|
|
|
|
|
51853
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub differ { |
116
|
79
|
|
|
79
|
0
|
9992
|
my ($file1, $file2) = @_; |
117
|
79
|
50
|
|
|
|
329
|
$file2 = "$file1" unless $file2; |
118
|
79
|
|
|
|
|
244
|
$file1 = "$file1"; |
119
|
|
|
|
|
|
|
|
120
|
79
|
|
|
|
|
410
|
my @lines1 = loadlines($file1); |
121
|
79
|
|
|
|
|
33250
|
my @lines2 = loadlines($file2); |
122
|
79
|
50
|
|
|
|
26712
|
my $linesm = @lines1 > @lines2 ? @lines1 : @lines2; |
123
|
79
|
|
|
|
|
550
|
for ( my $line = 1; $line < $linesm; $line++ ) { |
124
|
2471
|
50
|
|
|
|
5677
|
next if $lines1[$line] eq $lines2[$line]; |
125
|
0
|
|
|
|
|
0
|
Test::More::diag("Files $file1 and $file2 differ at line $line"); |
126
|
0
|
|
|
|
|
0
|
Test::More::diag(" < $lines1[$line]"); |
127
|
0
|
|
|
|
|
0
|
Test::More::diag(" > $lines2[$line]"); |
128
|
0
|
|
|
|
|
0
|
return 1; |
129
|
|
|
|
|
|
|
} |
130
|
79
|
50
|
|
|
|
1198
|
return 0 if @lines1 == @lines2; |
131
|
0
|
|
|
|
|
0
|
$linesm++; |
132
|
0
|
|
|
|
|
0
|
Test::More::diag("Files $file1 and $file2 differ at line $linesm" ); |
133
|
0
|
|
0
|
|
|
0
|
Test::More::diag(" < ", $lines1[$linesm] // "***missing***"); |
134
|
0
|
|
0
|
|
|
0
|
Test::More::diag(" > ", $lines2[$linesm] // "***missing***"); |
135
|
0
|
|
|
|
|
0
|
1; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
push( @EXPORT, 'differ' ); |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub fixchords { |
141
|
38
|
|
|
38
|
0
|
125
|
my ( $s ) = @_; |
142
|
38
|
|
50
|
|
|
90
|
for ( @{ $s->{body} // [] } ) { |
|
38
|
|
|
|
|
223
|
|
143
|
176
|
|
100
|
|
|
286
|
for ( @{ $_->{chords} // [] } ) { |
|
176
|
|
|
|
|
654
|
|
144
|
152
|
100
|
|
|
|
614
|
$_ = $_->key if UNIVERSAL::can( $_, "key" ); |
145
|
|
|
|
|
|
|
} |
146
|
176
|
|
100
|
|
|
297
|
for ( @{ $_->{chorus} // [] } ) { |
|
176
|
|
|
|
|
622
|
|
147
|
28
|
|
100
|
|
|
52
|
for ( @{ $_->{chords} // [] } ) { |
|
28
|
|
|
|
|
115
|
|
148
|
47
|
100
|
|
|
|
178
|
$_ = $_->key if UNIVERSAL::can( $_, "key" ); |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
} |
151
|
176
|
|
100
|
|
|
293
|
for ( @{ $_->{tokens} // [] } ) { |
|
176
|
|
|
|
|
622
|
|
152
|
136
|
100
|
|
|
|
294
|
if ( $_->{class} eq "chord" ) { |
|
|
100
|
|
|
|
|
|
153
|
31
|
|
|
|
|
42
|
for ( $_->{chord} ) { |
154
|
31
|
|
|
|
|
72
|
$_ = $_->key; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
elsif ( $_->{class} eq "chords" ) { |
158
|
1
|
|
|
|
|
4
|
for ( @{ $_->{chords} } ) { |
|
1
|
|
|
|
|
5
|
|
159
|
2
|
|
|
|
|
5
|
$_ = $_->key; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
push( @EXPORT, 'fixchords' ); |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
1; |