Skip to content

Commit

Permalink
Add failing test for transforming PAST::Block.control and .loadinit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler Leslie Curtis committed Jul 16, 2010
1 parent 0be54c1 commit e2659ca
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion t/pasttransformer.t
Expand Up @@ -8,11 +8,12 @@ INIT {
pir::load_bytecode('PAST/Pattern.pbc');
}

plan(4);
plan(5);
test_change_node_attributes();
test_change_node_types();
test_delete_nodes();
test_traverse_var_attributes();
test_traverse_block_attributes();

class Increment is PAST::Transformer { }
class Negate is PAST::Transformer { }
Expand Down Expand Up @@ -121,6 +122,25 @@ sub test_traverse_var_attributes () {
"PAST::Transformer walks PAST::Var.viviself and .vivibase.");
}

sub test_traverse_block_attributes () {
my $past :=
PAST::Block.new(:control(PAST::Stmts.new(PAST::Block.new(PAST::Op.new,
PAST::Op.new),
PAST::Block.new)),
:loadinit(PAST::Stmts.new(PAST::Block.new(PAST::Op.new,
PAST::Op.new),
PAST::Block.new)));
my $transformer := Trim.new;
my $target := PAST::Pattern::Block.new;
$target<control> :=
PAST::Pattern::Stmts.new(PAST::Pattern::Block.new);
$target<loadinit> :=
PAST::Pattern::Stmts.new(PAST::Pattern::Block.new);
my $result := $transformer.walk($past);
ok($result.match($target, :pos($result)),
"PAST::Transformer walks PAST::Block.control and .loadinit.");
}

# Local Variables:
# mode: cperl
# cperl-indent-level: 4
Expand Down

0 comments on commit e2659ca

Please sign in to comment.