line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#! perl |
2
|
|
|
|
|
|
|
|
3
|
78
|
|
|
78
|
|
952859
|
use strict; |
|
78
|
|
|
|
|
646
|
|
|
78
|
|
|
|
|
2272
|
|
4
|
78
|
|
|
78
|
|
414
|
use warnings; |
|
78
|
|
|
|
|
204
|
|
|
78
|
|
|
|
|
1958
|
|
5
|
78
|
|
|
78
|
|
393
|
use utf8; |
|
78
|
|
|
|
|
191
|
|
|
78
|
|
|
|
|
472
|
|
6
|
78
|
|
|
78
|
|
1941
|
use Carp; |
|
78
|
|
|
|
|
169
|
|
|
78
|
|
|
|
|
10427
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
binmode STDOUT => ':utf8'; |
9
|
|
|
|
|
|
|
binmode STDERR => ':utf8'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package ChordPro::Testing; |
12
|
|
|
|
|
|
|
|
13
|
78
|
|
|
78
|
|
609
|
use base 'Exporter'; |
|
78
|
|
|
|
|
208
|
|
|
78
|
|
|
|
|
13294
|
|
14
|
|
|
|
|
|
|
our @EXPORT = qw( $config ); |
15
|
|
|
|
|
|
|
|
16
|
78
|
|
|
78
|
|
47289
|
use Test::More (); |
|
78
|
|
|
|
|
7244421
|
|
|
78
|
|
|
|
|
2959
|
|
17
|
|
|
|
|
|
|
|
18
|
78
|
|
|
78
|
|
39533
|
use App::Packager ( ':name', 'ChordPro' ); |
|
78
|
|
|
|
|
191026
|
|
|
78
|
|
|
|
|
619
|
|
19
|
78
|
|
|
78
|
|
60655
|
use ChordPro::Config; |
|
78
|
|
|
|
|
330
|
|
|
78
|
|
|
|
|
5571
|
|
20
|
78
|
|
|
78
|
|
607
|
use ChordPro::Chords; |
|
78
|
|
|
|
|
177
|
|
|
78
|
|
|
|
|
35916
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub import { |
23
|
78
|
|
|
78
|
|
1149
|
my $pkg = shift; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# This is dirty... |
26
|
78
|
100
|
|
|
|
4455
|
-d "t" && chdir "t"; |
27
|
|
|
|
|
|
|
|
28
|
78
|
|
|
|
|
415
|
$::running_under_test = 1; |
29
|
78
|
|
|
|
|
8151
|
App::Packager->export_to_level(1); |
30
|
78
|
|
|
|
|
14560
|
Test::More->export_to_level(1); |
31
|
78
|
|
|
|
|
41691
|
$pkg->export_to_level( 1, undef, @EXPORT ); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub is_deeply { |
35
|
78
|
|
|
78
|
0
|
70458
|
my ( $got, $expect, $tag ) = @_; |
36
|
|
|
|
|
|
|
|
37
|
78
|
100
|
66
|
|
|
613
|
if ( ref($got) eq 'HASH' && ref($expect) eq 'HASH' ) { |
38
|
65
|
100
|
|
|
|
383
|
fixchords($got) if $got->{body}; |
39
|
|
|
|
|
|
|
|
40
|
65
|
|
|
|
|
232
|
for ( qw( config ) ) { |
41
|
65
|
50
|
|
|
|
332
|
delete $got->{$_} unless exists $expect->{$_}; |
42
|
|
|
|
|
|
|
} |
43
|
65
|
100
|
|
|
|
253
|
if ( $got->{chordsinfo} ) { |
44
|
63
|
100
|
100
|
|
|
129
|
if ( !%{$got->{chordsinfo}} && !$expect->{chordsinfo} ) { |
45
|
29
|
|
|
|
|
77
|
delete $got->{chordsinfo}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
else { |
48
|
34
|
|
|
|
|
70
|
foreach ( keys %{ $got->{chordsinfo} } ) { |
|
34
|
|
|
|
|
145
|
|
49
|
89
|
|
|
|
|
300
|
$got->{chordsinfo}{$_} = $got->{chordsinfo}{$_}->name; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
65
|
|
|
|
|
269
|
for ( qw( instrument user key_from key_actual chords numchords ) ) { |
54
|
390
|
50
|
|
|
|
1110
|
delete $got->{meta}->{$_} unless exists $expect->{meta}->{$_}; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
78
|
|
|
|
|
395
|
Test::More::is_deeply( $got, $expect, $tag ); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
push( @EXPORT, 'is_deeply' ); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub testconfig { |
64
|
|
|
|
|
|
|
# May change later. |
65
|
78
|
|
|
78
|
0
|
1274
|
ChordPro::Config::configurator; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
push( @EXPORT, 'testconfig' ); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
our $config = testconfig(); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
ChordPro::Chords::add_config_chord |
73
|
|
|
|
|
|
|
( { name => "NC", base => 1, frets => [ (-1)x6 ], fingers => [] } ); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
{ |
76
|
78
|
|
|
78
|
|
659
|
no warnings 'redefine'; |
|
78
|
|
|
|
|
1494
|
|
|
78
|
|
|
|
|
27854
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub getresource { |
79
|
11
|
|
|
11
|
|
4067
|
App::Packager::U_GetResource(@_); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
push( @EXPORT, 'getresource' ); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub cmp { |
86
|
|
|
|
|
|
|
# Perl version of the 'cmp' program. |
87
|
|
|
|
|
|
|
# Returns 1 if the files differ, 0 if the contents are equal. |
88
|
0
|
|
|
0
|
0
|
0
|
my ($old, $new) = @_; |
89
|
0
|
0
|
|
|
|
0
|
unless ( open (F1, $old) ) { |
90
|
0
|
|
|
|
|
0
|
print STDERR ("$old: $!\n"); |
91
|
0
|
|
|
|
|
0
|
return 1; |
92
|
|
|
|
|
|
|
} |
93
|
0
|
0
|
|
|
|
0
|
unless ( open (F2, $new) ) { |
94
|
0
|
|
|
|
|
0
|
print STDERR ("$new: $!\n"); |
95
|
0
|
|
|
|
|
0
|
return 1; |
96
|
|
|
|
|
|
|
} |
97
|
0
|
|
|
|
|
0
|
my ($buf1, $buf2); |
98
|
0
|
|
|
|
|
0
|
my ($len1, $len2); |
99
|
0
|
|
|
|
|
0
|
while ( 1 ) { |
100
|
0
|
|
|
|
|
0
|
$len1 = sysread (F1, $buf1, 10240); |
101
|
0
|
|
|
|
|
0
|
$len2 = sysread (F2, $buf2, 10240); |
102
|
0
|
0
|
0
|
|
|
0
|
return 0 if $len1 == $len2 && $len1 == 0; |
103
|
0
|
0
|
0
|
|
|
0
|
return 1 if $len1 != $len2 || ( $len1 && $buf1 ne $buf2 ); |
|
|
|
0
|
|
|
|
|
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
78
|
|
|
78
|
|
656
|
use File::LoadLines qw( loadlines ); |
|
78
|
|
|
|
|
198
|
|
|
78
|
|
|
|
|
49463
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub differ { |
110
|
79
|
|
|
79
|
0
|
11395
|
my ($file1, $file2) = @_; |
111
|
79
|
50
|
|
|
|
361
|
$file2 = "$file1" unless $file2; |
112
|
79
|
|
|
|
|
238
|
$file1 = "$file1"; |
113
|
|
|
|
|
|
|
|
114
|
79
|
|
|
|
|
446
|
my @lines1 = loadlines($file1); |
115
|
79
|
|
|
|
|
33561
|
my @lines2 = loadlines($file2); |
116
|
79
|
50
|
|
|
|
27512
|
my $linesm = @lines1 > @lines2 ? @lines1 : @lines2; |
117
|
79
|
|
|
|
|
522
|
for ( my $line = 1; $line < $linesm; $line++ ) { |
118
|
2452
|
50
|
|
|
|
5796
|
next if $lines1[$line] eq $lines2[$line]; |
119
|
0
|
|
|
|
|
0
|
Test::More::diag("Files $file1 and $file2 differ at line $line"); |
120
|
0
|
|
|
|
|
0
|
Test::More::diag(" < $lines1[$line]"); |
121
|
0
|
|
|
|
|
0
|
Test::More::diag(" > $lines2[$line]"); |
122
|
0
|
|
|
|
|
0
|
return 1; |
123
|
|
|
|
|
|
|
} |
124
|
79
|
50
|
|
|
|
1099
|
return 0 if @lines1 == @lines2; |
125
|
0
|
|
|
|
|
0
|
$linesm++; |
126
|
0
|
|
|
|
|
0
|
Test::More::diag("Files $file1 and $file2 differ at line $linesm" ); |
127
|
0
|
|
0
|
|
|
0
|
Test::More::diag(" < ", $lines1[$linesm] // "***missing***"); |
128
|
0
|
|
0
|
|
|
0
|
Test::More::diag(" > ", $lines2[$linesm] // "***missing***"); |
129
|
0
|
|
|
|
|
0
|
1; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
push( @EXPORT, 'differ' ); |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub fixchords { |
135
|
37
|
|
|
37
|
0
|
121
|
my ( $s ) = @_; |
136
|
37
|
|
50
|
|
|
76
|
for ( @{ $s->{body} // [] } ) { |
|
37
|
|
|
|
|
189
|
|
137
|
158
|
|
100
|
|
|
242
|
for ( @{ $_->{chords} // [] } ) { |
|
158
|
|
|
|
|
603
|
|
138
|
152
|
100
|
|
|
|
655
|
$_ = $_->key if UNIVERSAL::can( $_, "key" ); |
139
|
|
|
|
|
|
|
} |
140
|
158
|
|
100
|
|
|
277
|
for ( @{ $_->{chorus} // [] } ) { |
|
158
|
|
|
|
|
569
|
|
141
|
28
|
|
100
|
|
|
42
|
for ( @{ $_->{chords} // [] } ) { |
|
28
|
|
|
|
|
95
|
|
142
|
47
|
100
|
|
|
|
179
|
$_ = $_->key if UNIVERSAL::can( $_, "key" ); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
} |
145
|
158
|
|
100
|
|
|
245
|
for ( @{ $_->{tokens} // [] } ) { |
|
158
|
|
|
|
|
610
|
|
146
|
136
|
100
|
|
|
|
296
|
if ( $_->{class} eq "chord" ) { |
|
|
100
|
|
|
|
|
|
147
|
31
|
|
|
|
|
50
|
for ( $_->{chord} ) { |
148
|
31
|
|
|
|
|
62
|
$_ = $_->key; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
elsif ( $_->{class} eq "chords" ) { |
152
|
1
|
|
|
|
|
4
|
for ( @{ $_->{chords} } ) { |
|
1
|
|
|
|
|
5
|
|
153
|
2
|
|
|
|
|
7
|
$_ = $_->key; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
push( @EXPORT, 'fixchords' ); |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
1; |