diff options
Diffstat (limited to 't')
-rw-r--r-- | t/01-basic.t | 25 | ||||
-rw-r--r-- | t/02-xslt.t | 62 |
2 files changed, 87 insertions, 0 deletions
diff --git a/t/01-basic.t b/t/01-basic.t new file mode 100644 index 0000000..a063a2f --- /dev/null +++ b/t/01-basic.t @@ -0,0 +1,25 @@ +#!perl +use Test::Most 'no_plan','die'; +use strict; +use warnings; +use Tree::Template::Declare; +use Data::Dumper; + +my $tree=tree { + node { + name 'root'; + attribs name => 'none'; + node { + name 'coso1'; + attribs name => 'coso_1'; + }; + node { + name 'coso2'; + }; + }; +}; + +diag $_ for @{$tree->draw_ascii_tree()}; +is_deeply($tree->tree_to_lol(), + [['coso1'],['coso2'],'root'], + 'built the tree'); diff --git a/t/02-xslt.t b/t/02-xslt.t new file mode 100644 index 0000000..0870716 --- /dev/null +++ b/t/02-xslt.t @@ -0,0 +1,62 @@ +#!perl + +package Copy;{ +use Tree::Transform::XSLTish; +use Tree::Template::Declare; +use strict; +use warnings; + +tree_rule match => '/', action => sub { + my $t=$_[0]; + tree { + $t->apply_rules; + }; +}; + +tree_rule match => '*', priority => 0, action => sub { + my $t=$_[0]; + node { + name $t->it->name; + attribs %{$t->it->attributes}; + $t->apply_rules; + }; +}; + +} + +package main; +use Test::Most 'no_plan','die'; +use strict; +use warnings; +use Tree::Template::Declare; +use Data::Dumper; + +sub Tree::DAG_Node::XPath::Root::xpath_get_root_node { return $_[0] } +sub Tree::DAG_Node::XPath::Root::xpath_get_parent_node { return } + +my $tree=tree { + node { + name 'root'; + attribs name => 'none'; + node { + name 'coso1'; + attribs name => 'coso_1'; + }; + node { + name 'coso2'; + node { + name 'coso3'; + }; + }; + }; +}; + +diag "transforming"; +my $trans=Copy->new(); +my ($tree2)=$trans->transform($tree); + +diag "comparing"; +is($tree->tree_to_lol_notation(), + $tree2->tree_to_lol_notation(), + 'tree copy'); + |