From 21427fe4d2b0e8237dc6a30b69a8f41b945b46ec Mon Sep 17 00:00:00 2001 From: dakkar Date: Wed, 12 Aug 2009 17:22:06 +0200 Subject: added back-compatibility actually tested it: 02-back-compat passes on both PPIx::XPath 1.0.0 and PPIx::XPath 2.0 --- t/01-use.t | 3 +++ t/02-back-compat.t | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 t/01-use.t create mode 100644 t/02-back-compat.t (limited to 't') diff --git a/t/01-use.t b/t/01-use.t new file mode 100644 index 0000000..9848444 --- /dev/null +++ b/t/01-use.t @@ -0,0 +1,3 @@ +#!perl +use Test::Most tests=>1,'bail'; +use_ok('PPIx::XPath'); diff --git a/t/02-back-compat.t b/t/02-back-compat.t new file mode 100644 index 0000000..e8bc3e4 --- /dev/null +++ b/t/02-back-compat.t @@ -0,0 +1,23 @@ +#!perl +use Test::Most tests=>3,'die'; +use strict; +use warnings; +use PPI; +use PPIx::XPath; + +my $x=PPIx::XPath->new(\<<'EOF'); +sub foo { print "bar" } + +baz(); +EOF + +#explain('the doc: ',$x->{doc}); + +my ($subdef) = $x->match('/Statement::Sub'); +is($subdef->name,'foo','Got the sub'); + +my ($string) = $x->match('/Statement::Sub/Structure::Block/Statement/Token::Quote::Double'); +is($string->string,'bar','Got the string'); + +my ($call) = $x->match('/Statement/Token::Word'); +is($call->literal,'baz','Got the call'); -- cgit v1.2.3