From 38cca38c46f7613dcd5aff2e11ba6ad6153d0269 Mon Sep 17 00:00:00 2001 From: Gianni Ceccarelli Date: Fri, 27 Mar 2009 15:28:02 +0100 Subject: test multiple calls to attribs --- lib/Tree/Template/Declare/DAG_Node.pm | 2 +- t/01-basic.t | 5 ++++- t/03-html.t | 4 +++- t/04-xml.t | 3 ++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/Tree/Template/Declare/DAG_Node.pm b/lib/Tree/Template/Declare/DAG_Node.pm index 45321da..806413d 100644 --- a/lib/Tree/Template/Declare/DAG_Node.pm +++ b/lib/Tree/Template/Declare/DAG_Node.pm @@ -50,7 +50,7 @@ sub set_node_name { sub set_node_attributes { my ($self,$node,$attrs)=@_; - return $node->attributes($attrs); + return $node->attributes({%{$node->attributes},%$attrs}); } 1; diff --git a/t/01-basic.t b/t/01-basic.t index fe205e1..c6b1e8a 100644 --- a/t/01-basic.t +++ b/t/01-basic.t @@ -12,6 +12,7 @@ my $tree=tree { node { name 'coso1'; attribs name => 'coso_1'; + attribs other => 'some'; }; node { name 'coso2'; @@ -19,7 +20,9 @@ my $tree=tree { }; }; -diag $_ for @{$tree->draw_ascii_tree()}; is_deeply($tree->tree_to_lol(), [['coso1'],['coso2'],'root'], 'built the tree'); +is_deeply(($tree->daughters)[0]->attributes, + {name => 'coso_1', other => 'some'}, + 'attributes'); diff --git a/t/03-html.t b/t/03-html.t index 27cac64..d805e56 100644 --- a/t/03-html.t +++ b/t/03-html.t @@ -24,6 +24,8 @@ my $tree=tree { name 'body'; node { name 'p'; + attribs id => 'p1'; + attribs class => 'para'; node { name '~text'; attribs text => 'Page para' }; }; }; @@ -31,6 +33,6 @@ my $tree=tree { }; is($tree->as_HTML(), - qq{Page title

Page para\n}, + qq{Page title

Page para\n}, 'HTML tree' ); diff --git a/t/04-xml.t b/t/04-xml.t index 9ec5924..b7b0af8 100644 --- a/t/04-xml.t +++ b/t/04-xml.t @@ -18,7 +18,8 @@ sub make_tree { name 'stuff'; node { name 'test:elem1'; - attribs id => 1, 'test:buh' => 'testing'; + attribs 'test:buh' => 'testing'; + attribs id => 1; node { name 'test:sub1'; } -- cgit v1.2.3