root/lang/perl/Music-Chord-Note/trunk/t/01.rehearsal.t @ 25526

Revision 25526, 1.2 kB (checked in by bayashi, 5 years ago)

fixed chord list and t/01

Line 
1use strict;
2
3use Test::More tests => 22;
4
5use Music::Chord::Note;
6
7my $cn = Music::Chord::Note->new();
8isa_ok($cn, 'Music::Chord::Note', 'new');
9
10
11eval { my @fail = $cn->chord(''); };
12like($@, qr/No CHORD_NAME!/, "No CHORD_NAME");
13
14eval { my @fail = $cn->chord('H'); };
15like($@, qr/unknown chord H at/, "unknown chord1 H");
16
17eval { my @fail = $cn->chord('Hm7'); };
18like($@, qr/unknown chord Hm7 at/, "unknown chord2 Hm7");
19
20eval { my @fail = $cn->chord('hoge'); };
21like($@, qr/unknown chord hoge at/, "unknown chord4 hoge");
22
23eval { my @fail = $cn->chord('Cm2'); };
24like($@, qr/undefined kind of chord m2\(Cm2\) at/, "undefined kind of chord");
25
26
27my %testchords = (
28    'C'     => 'C E G',
29    'C6'    => 'C E G A',
30    'Csus4' => 'C F G',
31    'C7'    => 'C E G A#',
32    'CM7'   => 'C E G B',
33    'Cm'    => 'C D# G',
34    'Cm7'   => 'C D# G A#',
35    'CmM7'  => 'C D# G B',
36    'Cm13'  => 'C D# G A# D F A',
37    'Csus4' => 'C F G',
38    'Caug'  => 'C E G#',
39    'Cdim'  => 'C D# F#',
40    'Cadd2' => 'C D E G',
41
42    'C#'     => 'C# F G#',
43    'F'      => 'F A C',
44    'B'      => 'B D# F#',
45    'Bm13'   => 'B D F# A C# E G#',
46);
47
48foreach my $c (sort keys %testchords){
49    my @Chord = $cn->chord($c);
50    is($testchords{$c}, "@Chord", $c.' -> '.$testchords{$c});
51}
52
53
54
Note: See TracBrowser for help on using the browser.