Browse files

Line of music working, with tests.

  • Loading branch information...
1 parent 702bdff commit 8cf49a2fd8ec61dfbf96b675bc73ef083f91b534 @LastOfTheCarelessMen committed Dec 20, 2009
Showing with 15 additions and 2 deletions.
  1. +1 −1 lib/ABC.pm
  2. +14 −1 t/01-regexes.t
View
2 lib/ABC.pm
@@ -32,7 +32,7 @@ grammar ABC
regex bar { <element>+ <barline>? }
- regex line_of_music { <barline> $$ | <barline>? <element>+ $$ }
+ regex line_of_music { <barline>? <bar>+ }
}
class ABCHeader
View
15 t/01-regexes.t
@@ -167,7 +167,20 @@ for ':|:', '|:', '|', ':|', '::'
my $match = $line ~~ m/ <ABC::line_of_music> /;
isa_ok $match, Match, 'line of music recognized';
is $match<ABC::line_of_music>, $line, "Entire line was matched";
- say $match<ABC::line_of_music>.perl;
+ is $match<ABC::line_of_music><bar>[0], "g>ecg ec e/f/g/e/ |", "First bar is correct";
+ is $match<ABC::line_of_music><bar>[1], " d/c/B/A/ Gd BG B/c/d/B/ |", "Second bar is correct";
+ # say $match<ABC::line_of_music>.perl;
+}
+
+{
+ my $line = "|A/B/c/A/ c>d e>deg | dB/A/ gB +trill+A2 +trill+e2 ::";
+ my $match = $line ~~ m/ <ABC::line_of_music> /;
+ isa_ok $match, Match, 'line of music recognized';
+ is $match<ABC::line_of_music>, $line, "Entire line was matched";
+ is $match<ABC::line_of_music><bar>[0], "A/B/c/A/ c>d e>deg |", "First bar is correct";
+ is $match<ABC::line_of_music><bar>[1], " dB/A/ gB +trill+A2 +trill+e2 ::", "Second bar is correct";
+ is $match<ABC::line_of_music><barline>, "|", "Initial barline matched";
+ # say $match<ABC::line_of_music>.perl;
}
done_testing;

0 comments on commit 8cf49a2

Please sign in to comment.