| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#! perl |
|
2
|
|
|
|
|
|
|
|
|
3
|
78
|
|
|
78
|
|
950101
|
use strict; |
|
|
78
|
|
|
|
|
621
|
|
|
|
78
|
|
|
|
|
2346
|
|
|
4
|
78
|
|
|
78
|
|
408
|
use warnings; |
|
|
78
|
|
|
|
|
145
|
|
|
|
78
|
|
|
|
|
1883
|
|
|
5
|
78
|
|
|
78
|
|
398
|
use utf8; |
|
|
78
|
|
|
|
|
177
|
|
|
|
78
|
|
|
|
|
432
|
|
|
6
|
78
|
|
|
78
|
|
1921
|
use Carp; |
|
|
78
|
|
|
|
|
170
|
|
|
|
78
|
|
|
|
|
10532
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
binmode STDOUT => ':utf8'; |
|
9
|
|
|
|
|
|
|
binmode STDERR => ':utf8'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package ChordPro::Testing; |
|
12
|
|
|
|
|
|
|
|
|
13
|
78
|
|
|
78
|
|
593
|
use base 'Exporter'; |
|
|
78
|
|
|
|
|
177
|
|
|
|
78
|
|
|
|
|
13179
|
|
|
14
|
|
|
|
|
|
|
our @EXPORT = qw( $config ); |
|
15
|
|
|
|
|
|
|
|
|
16
|
78
|
|
|
78
|
|
44885
|
use Test::More (); |
|
|
78
|
|
|
|
|
7211459
|
|
|
|
78
|
|
|
|
|
2877
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
78
|
|
|
78
|
|
38293
|
use App::Packager ( ':name', 'ChordPro' ); |
|
|
78
|
|
|
|
|
190274
|
|
|
|
78
|
|
|
|
|
597
|
|
|
19
|
78
|
|
|
78
|
|
60296
|
use ChordPro::Config; |
|
|
78
|
|
|
|
|
314
|
|
|
|
78
|
|
|
|
|
6658
|
|
|
20
|
78
|
|
|
78
|
|
1967
|
use ChordPro::Chords; |
|
|
78
|
|
|
|
|
173
|
|
|
|
78
|
|
|
|
|
30060
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub import { |
|
23
|
78
|
|
|
78
|
|
1029
|
my $pkg = shift; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# This is dirty... |
|
26
|
78
|
100
|
|
|
|
4550
|
-d "t" && chdir "t"; |
|
27
|
|
|
|
|
|
|
|
|
28
|
78
|
|
|
|
|
398
|
$::running_under_test = 1; |
|
29
|
78
|
|
|
|
|
7885
|
App::Packager->export_to_level(1); |
|
30
|
78
|
|
|
|
|
14576
|
Test::More->export_to_level(1); |
|
31
|
78
|
|
|
|
|
41383
|
$pkg->export_to_level( 1, undef, @EXPORT ); |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub is_deeply { |
|
35
|
78
|
|
|
78
|
0
|
70173
|
my ( $got, $expect, $tag ) = @_; |
|
36
|
|
|
|
|
|
|
|
|
37
|
78
|
100
|
66
|
|
|
624
|
if ( ref($got) eq 'HASH' && ref($expect) eq 'HASH' ) { |
|
38
|
65
|
100
|
|
|
|
366
|
fixchords($got) if $got->{body}; |
|
39
|
|
|
|
|
|
|
|
|
40
|
65
|
|
|
|
|
235
|
for ( qw( config ) ) { |
|
41
|
65
|
50
|
|
|
|
311
|
delete $got->{$_} unless exists $expect->{$_}; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
65
|
100
|
|
|
|
264
|
if ( $got->{chordsinfo} ) { |
|
44
|
63
|
100
|
100
|
|
|
110
|
if ( !%{$got->{chordsinfo}} && !$expect->{chordsinfo} ) { |
|
45
|
29
|
|
|
|
|
73
|
delete $got->{chordsinfo}; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
else { |
|
48
|
34
|
|
|
|
|
77
|
foreach ( keys %{ $got->{chordsinfo} } ) { |
|
|
34
|
|
|
|
|
133
|
|
|
49
|
89
|
|
|
|
|
295
|
$got->{chordsinfo}{$_} = $got->{chordsinfo}{$_}->name; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
} |
|
53
|
65
|
|
|
|
|
269
|
for ( qw( instrument user key_from key_actual chords numchords ) ) { |
|
54
|
390
|
50
|
|
|
|
1084
|
delete $got->{meta}->{$_} unless exists $expect->{meta}->{$_}; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
78
|
|
|
|
|
389
|
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
|
1896
|
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
|
|
660
|
no warnings 'redefine'; |
|
|
78
|
|
|
|
|
191
|
|
|
|
78
|
|
|
|
|
23013
|
|
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub getresource { |
|
79
|
11
|
|
|
11
|
|
3555
|
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
|
|
696
|
use File::LoadLines qw( loadlines ); |
|
|
78
|
|
|
|
|
1399
|
|
|
|
78
|
|
|
|
|
55149
|
|
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub differ { |
|
110
|
79
|
|
|
79
|
0
|
11220
|
my ($file1, $file2) = @_; |
|
111
|
79
|
50
|
|
|
|
325
|
$file2 = "$file1" unless $file2; |
|
112
|
79
|
|
|
|
|
233
|
$file1 = "$file1"; |
|
113
|
|
|
|
|
|
|
|
|
114
|
79
|
|
|
|
|
477
|
my @lines1 = loadlines($file1); |
|
115
|
79
|
|
|
|
|
33342
|
my @lines2 = loadlines($file2); |
|
116
|
79
|
50
|
|
|
|
25738
|
my $linesm = @lines1 > @lines2 ? @lines1 : @lines2; |
|
117
|
79
|
|
|
|
|
508
|
for ( my $line = 1; $line < $linesm; $line++ ) { |
|
118
|
2471
|
50
|
|
|
|
5672
|
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
|
|
|
|
1234
|
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
|
|
|
77
|
for ( @{ $s->{body} // [] } ) { |
|
|
37
|
|
|
|
|
219
|
|
|
137
|
158
|
|
100
|
|
|
262
|
for ( @{ $_->{chords} // [] } ) { |
|
|
158
|
|
|
|
|
598
|
|
|
138
|
152
|
100
|
|
|
|
611
|
$_ = $_->key if UNIVERSAL::can( $_, "key" ); |
|
139
|
|
|
|
|
|
|
} |
|
140
|
158
|
|
100
|
|
|
281
|
for ( @{ $_->{chorus} // [] } ) { |
|
|
158
|
|
|
|
|
572
|
|
|
141
|
28
|
|
100
|
|
|
52
|
for ( @{ $_->{chords} // [] } ) { |
|
|
28
|
|
|
|
|
101
|
|
|
142
|
47
|
100
|
|
|
|
163
|
$_ = $_->key if UNIVERSAL::can( $_, "key" ); |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
} |
|
145
|
158
|
|
100
|
|
|
252
|
for ( @{ $_->{tokens} // [] } ) { |
|
|
158
|
|
|
|
|
550
|
|
|
146
|
136
|
100
|
|
|
|
277
|
if ( $_->{class} eq "chord" ) { |
|
|
|
100
|
|
|
|
|
|
|
147
|
31
|
|
|
|
|
58
|
for ( $_->{chord} ) { |
|
148
|
31
|
|
|
|
|
62
|
$_ = $_->key; |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
elsif ( $_->{class} eq "chords" ) { |
|
152
|
1
|
|
|
|
|
19
|
for ( @{ $_->{chords} } ) { |
|
|
1
|
|
|
|
|
6
|
|
|
153
|
2
|
|
|
|
|
5
|
$_ = $_->key; |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
} |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
} |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
push( @EXPORT, 'fixchords' ); |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
1; |