]> iEval git - html-element-library.git/blame - t/newchild.t
fixes
[html-element-library.git] / t / newchild.t
CommitLineData
271d5078
TB
1#!/usr/bin/perl -T
2
3
4use warnings;
5use strict;
6
7use Test::More;
8use Test::XML;
9
10BEGIN {
11 use_ok('HTML::TreeBuilder');
12 use_ok('HTML::Element::Library');
13}
14
15
16my $initial_lol = [ note => [ shopping => [ item => 'sample' ] ] ];
855ca7e9 17my $new_lol = HTML::Element::newchild($initial_lol, shopping => shopping_items());
271d5078
TB
18
19
20sub shopping_items {
21 my @shopping_items = map { [ item => $_ ] } qw(bread butter beans);
855ca7e9 22 @shopping_items;
271d5078
TB
23}
24
25my $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
44use Data::Dumper;
45warn Dumper($new_lol);
46
271d5078
TB
47is_deeply($new_lol, $expected, 'test unrolling');
48
49
50
51done_testing;
This page took 0.026654 seconds and 4 git commands to generate.