Skip to content

Instantly share code, notes, and snippets.

@masak
Last active March 25, 2016 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masak/3a018a8eeef9acbf397f to your computer and use it in GitHub Desktop.
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
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