summaryrefslogtreecommitdiff
path: root/t/01-basic.t
diff options
context:
space:
mode:
Diffstat (limited to 't/01-basic.t')
-rw-r--r--t/01-basic.t30
1 files changed, 30 insertions, 0 deletions
diff --git a/t/01-basic.t b/t/01-basic.t
new file mode 100644
index 0000000..e9b285b
--- /dev/null
+++ b/t/01-basic.t
@@ -0,0 +1,30 @@
+#!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;
+ }
+
+}
+
+package main;
+use Test::Most qw(no_plan die);
+use strict;
+use warnings;
+use Tree::DAG_Node::XPath;
+
+my $tree=Tree::DAG_Node::XPath->new();
+$tree->new_daughter->name("coso$_") for 1..5;
+
+my $trans=BasicTransform->new();
+
+my @results=$trans->apply_rules($tree);
+
+is_deeply \@results,[qw(root coso1 coso2 coso3 coso4 coso5)];