Permalink
Browse files

Fix note_length regex. Two tests of ABC::note.

  • Loading branch information...
1 parent d81a69f commit bb96052a8fb5f765b6dd5a25d2a4a245c0cc4ef0 @LastOfTheCarelessMen committed Dec 16, 2009
Showing with 20 additions and 1 deletion.
  1. +1 −1 lib/ABC.pm
  2. +19 −0 t/01-regexes.t
View
@@ -13,7 +13,7 @@ grammar ABC
regex pitch { <accidental>? <basenote> <octave>? }
regex tie { '-' }
- regex note_length { [\d* ['/' \d*] ] | '/' }
+ regex note_length { [\d* ['/' \d*]? ] | '/' }
regex note { <pitch> <note_length>? <tie>? }
}
View
@@ -36,6 +36,25 @@ plan *;
is $match<ABC::pitch><accidental>, "=", '"=d,,," has accidental "="';
}
+{
+ my $match = "^^e2" ~~ m/ <ABC::note> /;
+ isa_ok $match, Match, '"^^e2" is a note';
+ is $match<ABC::note><pitch><basenote>, "e", '"^^e2" has base note e';
+ is $match<ABC::note><pitch><octave>, "", '"^^e2" has octave ""';
+ is $match<ABC::note><pitch><accidental>, "^^", '"^^e2" has accidental "^^"';
+ is $match<ABC::note><note_length>, "2", '"^^e2" has note length 2';
+}
+
+{
+ my $match = "__f'/" ~~ m/ <ABC::note> /;
+ isa_ok $match, Match, '"__f/" is a note';
+ is $match<ABC::note><pitch><basenote>, "f", '"__f/" has base note f';
+ is $match<ABC::note><pitch><octave>, "'", '"__f/" has octave tick';
+ is $match<ABC::note><pitch><accidental>, "__", '"__f/" has accidental "__"';
+ is $match<ABC::note><note_length>, "/", '"__f/" has note length /';
+}
+
+
done_testing;

0 comments on commit bb96052

Please sign in to comment.