]>
Commit | Line | Data |
---|---|---|
271d5078 TB |
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' ] ] ]; | |
855ca7e9 | 17 | my $new_lol = HTML::Element::newchild($initial_lol, shopping => shopping_items()); |
271d5078 TB |
18 | |
19 | ||
20 | sub shopping_items { | |
21 | my @shopping_items = map { [ item => $_ ] } qw(bread butter beans); | |
855ca7e9 | 22 | @shopping_items; |
271d5078 TB |
23 | } |
24 | ||
25 | my $expected = [ | |
26 | 'note', | |
27 | [ | |
28 | 'shopping', | |
271d5078 TB |
29 | [ |
30 | 'item', | |
31 | 'bread' | |
32 | ], | |
33 | [ | |
34 | 'item', | |
35 | 'butter' | |
36 | ], | |
37 | [ | |
38 | 'item', | |
39 | 'beans' | |
40 | ] | |
271d5078 TB |
41 | ] |
42 | ]; | |
43 | ||
855ca7e9 TB |
44 | use Data::Dumper; |
45 | warn Dumper($new_lol); | |
46 | ||
271d5078 TB |
47 | is_deeply($new_lol, $expected, 'test unrolling'); |
48 | ||
49 | ||
50 | ||
51 | done_testing; |