From 16541cf3bbf59460b1e0839bc18f08b3c75dd1ed Mon Sep 17 00:00:00 2001 From: dakkar Date: Sun, 28 Jun 2009 09:17:07 +0200 Subject: still broken --- t/07-class-xpath.t | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/t/07-class-xpath.t b/t/07-class-xpath.t index 891ddff..9aa8040 100644 --- a/t/07-class-xpath.t +++ b/t/07-class-xpath.t @@ -13,6 +13,10 @@ sub findnodes { my ($self,$expr,$node)=@_; return PPIx::XPath->new($node)->match($expr); } + +sub PPI::Document::parent { + return $_[0]; +} } package PPITransform;{ @@ -22,9 +26,17 @@ package PPITransform;{ engine_class 'CXpEngine'; - default_rules; + #default_rules; + tree_rule match => '/', priority => 0, action => sub { + print '# root'; + $_[0]->apply_rules + }; + tree_rule match => '*', priority => 0, action => sub { + print '# ',$_[0]->it->xpath; + $_[0]->apply_rules + }; - tree_rule match => '//Statement::Sub', action => sub { + tree_rule match => 'Statement::Sub', action => sub { return $_[0]->it->name.'('.$_[0]->it->prototype.')'; }; @@ -34,6 +46,8 @@ package main; use strict; use warnings; use PPI; +use Devel::TraceCalls; + plan tests=>1; { @@ -48,6 +62,13 @@ my $x=PPIx::XPath->new($doc); diag "$_\n" for $x->match('//Statement::Sub'); my $trans=PPITransform->new(); +#trace_calls { +# Package => 'PPIx::XPath', +# Class => 'PPI::Node', +# ShowStack => 1, +# CaptureAll => 1, +#}; + my @results=$trans->transform($doc); is_deeply \@results,['gino($%)','pino'],'PPI example'; } -- cgit v1.2.3