summaryrefslogtreecommitdiff
path: root/t/02-inherit.t
blob: 3b0f65a54ca0d0a6f276a9b6eff554cdd0bb4952 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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)];
}