From f7cd6ed5adcea6d64ea55d7bacd92d2a9be8b5e0 Mon Sep 17 00:00:00 2001 From: tcurtis Date: Wed, 4 Aug 2010 16:29:37 -0500 Subject: [PATCH] Test that .transform does the right thing with deleting nodes. --- t/pastpattern.t | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/t/pastpattern.t b/t/pastpattern.t index 9d02cf0..190c500 100644 --- a/t/pastpattern.t +++ b/t/pastpattern.t @@ -5,7 +5,7 @@ pir::load_bytecode('PCT.pbc'); pir::load_bytecode('PAST/Pattern.pbc'); -plan(2151); +plan(2153); test_type_matching(); test_attribute_exact_matching(); @@ -825,6 +825,17 @@ sub test_transform_sub () { 'Matched node 2 is changed. 2'); ok($result[1][1][0].value() == 2, 'Matched nodes within other matched nodes are changed.'); + + sub del ($/) { + pir::null__P; + } + $pattern := PAST::Pattern::Val.new; + $past := PAST::Stmts.new(PAST::Val.new, PAST::Op.new); + $result := $pattern.transform($past, del); + ok($result ~~ PAST::Stmts, + 'Non-matched nodes left unchanged 2.'); + ok($result[0] ~~ PAST::Op, + 'Deletion of nodes is correctly handled.'); } sub test_transform_options () {