[svn:parrot] r47433 - branches/gsoc_past_optimization/t/library
tcurtis at svn.parrot.org
tcurtis at svn.parrot.org
Sun Jun 6 23:13:09 UTC 2010
Author: tcurtis
Date: Sun Jun 6 23:13:09 2010
New Revision: 47433
URL: https://trac.parrot.org/parrot/changeset/47433
Log:
Added a test for correct .from when matching a subtree of a PAST::Node.
Modified:
branches/gsoc_past_optimization/t/library/pastpattern.t
Modified: branches/gsoc_past_optimization/t/library/pastpattern.t
==============================================================================
--- branches/gsoc_past_optimization/t/library/pastpattern.t Sun Jun 6 23:02:16 2010 (r47432)
+++ branches/gsoc_past_optimization/t/library/pastpattern.t Sun Jun 6 23:13:09 2010 (r47433)
@@ -5,7 +5,7 @@
pir::load_bytecode('PCT.pbc');
pir::load_bytecode('PAST/Pattern.pbc');
-plan(2033);
+plan(2036);
test_type_matching();
test_attribute_exact_matching();
@@ -545,7 +545,7 @@
sub test_match_result () {
test_match_result_from_top_node();
-# test_match_result_from_sub_node();
+ test_match_result_from_sub_node();
test_match_result_from_closure();
test_match_result_from_constant();
}
@@ -583,6 +583,21 @@
}
}
+sub test_match_result_from_sub_node () {
+ my $pattern := PAST::Pattern::Val.new(:returns('Integer'));
+ my $node := PAST::Op.new(:pirop<abs>,
+ PAST::Val.new(:value(5),
+ :returns<Integer>));
+ my $/ := $node ~~ $pattern;
+
+ ok($/ ~~ PAST::Pattern::Match,
+ "Deep match result on Node 1 is a PAST::Pattern::Match.");
+ ok(?$/,
+ "Deep match result on Node 1 converts to boolean truth.");
+ ok($/.from() =:= $node[0],
+ "Deep match result on Node 1 has correct .from.");
+}
+
sub test_match_result_from_closure () {
my $pattern :=
PAST::Pattern::Closure.new(sub ($_) {
More information about the parrot-commits
mailing list