]> iEval git - html-element-library.git/blob - t/newchild.t
43b641deeb61f1a9cede496c32037243961e9497
[html-element-library.git] / t / newchild.t
1 #!/usr/bin/perl -T
2
3
4 use warnings;
5 use strict;
6
7 use Test::More;
8 use Test::XML;
9
10 BEGIN {
11 use_ok('HTML::TreeBuilder');
12 use_ok('HTML::Element::Library');
13 }
14
15
16 my $initial_lol = [ note => [ shopping => [ item => 'sample' ] ] ];
17 my $new_lol = HTML::Element::newchild($initial_lol, shopping => shopping_items());
18
19
20 sub shopping_items {
21 my @shopping_items = map { [ item => $_ ] } qw(bread butter beans);
22 @shopping_items;
23 }
24
25 my $expected = [
26 'note',
27 [
28 'shopping',
29 [
30 'item',
31 'bread'
32 ],
33 [
34 'item',
35 'butter'
36 ],
37 [
38 'item',
39 'beans'
40 ]
41 ]
42 ];
43
44 use Data::Dumper;
45 warn Dumper($new_lol);
46
47 is_deeply($new_lol, $expected, 'test unrolling');
48
49
50
51 done_testing;
This page took 0.046365 seconds and 3 git commands to generate.