summaryrefslogtreecommitdiff
path: root/t/01-basic.t
blob: a6eb0bafd1571252c78095b402ab81c74c54a407 (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
#!perl 
package BasicTransform;{ 
 use Tree::Transform;
 use strict;
 use warnings;
 
 tree_rule match => '/'action => sub {
     return 'root'$_[0]->apply_rules;
 };
 
 tree_rule match => '*'action => sub {
     return $_[0]->it->name, $_[0]->apply_rules;
 }
 
}
 
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=BasicTransform->new();
 
#explain 'root children:',$tree->xpath_get_root_node->xpath_get_child_nodes; 
#explain 'root children:',$trans->engine->findnodes('*',$tree); 
 
my @results=$trans->transform($tree);
 
is_deeply \@results,[qw(root base coso1 coso2 coso3 coso4 coso5)];