From 7e1910fc97ac3849d32fc8749862e8bf51ae8dbe Mon Sep 17 00:00:00 2001 From: dakkar Date: Sat, 27 Jun 2009 13:56:17 +0200 Subject: non-working test, PPIx::XPath is quite broken --- t/07-class-xpath.t | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 t/07-class-xpath.t diff --git a/t/07-class-xpath.t b/t/07-class-xpath.t new file mode 100644 index 0000000..891ddff --- /dev/null +++ b/t/07-class-xpath.t @@ -0,0 +1,53 @@ +#!perl +package main; +use Test::Most 'die'; +BEGIN { + eval 'use PPIx::XPath'; + plan skip_all => 'PPIx::XPath needed for this test' if $@; +} + +package CXpEngine; { +use PPIx::XPath; +sub new { bless {},shift } +sub findnodes { + my ($self,$expr,$node)=@_; + return PPIx::XPath->new($node)->match($expr); +} +} + +package PPITransform;{ + use Tree::Transform::XSLTish ':engine'; + use strict; + use warnings; + + engine_class 'CXpEngine'; + + default_rules; + + tree_rule match => '//Statement::Sub', action => sub { + return $_[0]->it->name.'('.$_[0]->it->prototype.')'; + }; + +} + +package main; +use strict; +use warnings; +use PPI; +plan tests=>1; + +{ +my $doc=PPI::Document->new(\<<'EOP'); +sub gino($%) {} +sub pino {} + +gino(\&pino,{1=>2}); +EOP + +my $x=PPIx::XPath->new($doc); +diag "$_\n" for $x->match('//Statement::Sub'); + +my $trans=PPITransform->new(); +my @results=$trans->transform($doc); +is_deeply \@results,['gino($%)','pino'],'PPI example'; +} -- cgit v1.2.3