summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorGianni Ceccarelli <dakkar@dechirico.(none)>2009-03-18 16:23:41 +0100
committerGianni Ceccarelli <dakkar@dechirico.(none)>2009-03-18 16:23:41 +0100
commit6ddc252f223ef602992ccdc647eab293c7ca1112 (patch)
tree3ff53f4faeba28a6f78e6c51ab37032fe5f2f8e2 /t
parentdefault rules (diff)
downloadTree-Transform-XSLTish-6ddc252f223ef602992ccdc647eab293c7ca1112.tar.gz
Tree-Transform-XSLTish-6ddc252f223ef602992ccdc647eab293c7ca1112.tar.bz2
Tree-Transform-XSLTish-6ddc252f223ef602992ccdc647eab293c7ca1112.zip
inheritance
Diffstat (limited to 't')
-rw-r--r--t/02-inherit.t47
1 files changed, 47 insertions, 0 deletions
diff --git a/t/02-inherit.t b/t/02-inherit.t
new file mode 100644
index 0000000..3b0f65a
--- /dev/null
+++ b/t/02-inherit.t
@@ -0,0 +1,47 @@
+#!perl
+package TransformA;{
+ use Tree::Transform;
+ use strict;
+ use warnings;
+
+ default_rules;
+
+ tree_rule match => '*', action => sub {
+ return $_[0]->it->name, $_[0]->apply_rules;
+ }
+
+}
+
+package TransformB;{
+ use base 'TransformA';
+ use Tree::Transform;
+ use strict;
+ use warnings;
+
+ tree_rule match => 'coso1', action => sub {
+ return 'sub-coso1';
+ };
+
+ tree_rule match => 'base/coso2', action => sub {
+ return 'sub-coso2';
+ }
+
+}
+
+package main;
+use Test::Most qw(no_plan die);
+use strict;
+use warnings;
+use Tree::DAG_Node::XPath;
+
+sub Tree::DAG_Node::XPath::Root::xpath_get_root_node { return $_[0] }
+
+my $tree=Tree::DAG_Node::XPath->new();
+$tree->name('base');
+$tree->new_daughter->name("coso$_") for 1..5;
+
+{
+my $trans=TransformB->new();
+my @results=$trans->transform($tree);
+is_deeply \@results,[qw(base sub-coso1 sub-coso2 coso3 coso4 coso5)];
+}