-
-
Save masak/3a018a8eeef9acbf397f to your computer and use it in GitHub Desktop.
I would like the test to look a little bit more like this
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v6; | |
use Test; | |
use _007::Test; | |
my $actions-ast = qast-of("lib/_007/Parser/Actions.pm"); | |
for find-methods($actions-ast) -> $method { | |
my $methodname = $method.ann('code_object').name; | |
my $constructions = 0; | |
my $finishblocks = 0; | |
for find-statements($method) -> $statement { | |
visit($statement, { | |
"QAST::Op" => sub ($node) { | |
return unless $node.op eq "callmethod"; | |
if $node.name eq "new" { | |
my $wval = $node.list[0]; | |
if $wval.^name eq "QAST::WVal" && $wval.compile_time_value.^name eq "Q::Block" { | |
$constructions++; | |
} | |
} | |
if $node.name eq "finish-block" { | |
my $var = $node.list[0]; | |
if $var.^name eq "QAST::Var" && $var.scope eq "lexical" && $var.name eq "self" { | |
$*self-finishblock-count++; | |
} | |
} | |
}, | |
}); | |
} | |
is $constructions, $finishblocks, "finished all Q::Block.new in $methodname"; | |
} | |
done-testing; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment