Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix element action to return component's AST value (sometimes) and fi…

…x corresponding test as well.
  • Loading branch information...
commit 7edf476df12e6cd31ffe636b4f429bbacfa904de 1 parent 0c5c68f
@colomon authored
Showing with 6 additions and 6 deletions.
  1. +3 −3 lib/ABC/Actions.pm
  2. +0 −1  lib/ABC/Note.pm
  3. +3 −2 t/05-actions.t
View
6 lib/ABC/Actions.pm
@@ -48,9 +48,9 @@ class ABC::Actions {
}
my $ast = $type => ~$/{$type};
- # if $/{$type}.ast ~~ ABC::Duration {
- # $ast does ABC::Duration($/{$type}.ast.ticks);
- # }
+ if $/{$type}.ast ~~ ABC::Duration {
+ $ast = $type => $/{$type}.ast;
+ }
make $ast;
}
View
1  lib/ABC/Note.pm
@@ -7,7 +7,6 @@ class ABC::Note does ABC::Duration {
has $.is-tie;
method new($pitch, ABC::Duration $duration, $is-tie) {
- say :$duration.perl;
self.bless(*, :$pitch, :ticks($duration.ticks), :$is-tie);
}
}
View
5 t/05-actions.t
@@ -5,6 +5,7 @@ use ABC::Tune;
use ABC::Grammar;
use ABC::Actions;
use ABC::Note;
+use ABC::Stem;
plan *;
@@ -45,7 +46,7 @@ K:D
isa_ok $match, Match, 'element recognized';
isa_ok $match.ast, Pair, '$match.ast is a Pair';
is $match.ast.key, "stem", "Stem found";
- is $match.ast.value, "e3", "Value e3";
+ isa_ok $match.ast.value, ABC::Note, "Value is note";
}
{
@@ -104,7 +105,7 @@ BAB G2G|G2g gdB|c2a B2g|A2=f fcA:|
{
my $match = ABC::Grammar.parse(slurp("samples.abc"), :rule<tune_file>, :actions(ABC::Actions.new));
isa_ok $match, Match, 'samples.abc is a valid tune file';
- say $match.ast.perl;
+ # say $match.ast.perl;
is @( $match<tune> ).elems, 3, "Three tunes were found";
is @( $match.ast )[0].elems, 3, "Three tunes were found";
isa_ok @( $match.ast )[0][0], ABC::Tune, "First is an ABC::Tune";

0 comments on commit 7edf476

Please sign in to comment.
Something went wrong with that request. Please try again.