]> iEval git - html-element-library.git/blob - t/highlander2.t
fixed test suite
[html-element-library.git] / t / highlander2.t
1 # This might look like shell script, but it's actually -*- perl -*-
2 use strict;
3 use lib qw(t/ t/m/);
4
5 use File::Slurp;
6 use Test::More qw(no_plan);
7
8 use TestUtils;
9 use HTML::TreeBuilder;
10 use HTML::Element::Library;
11
12 sub replace_age {
13 my $branch = shift;
14 my $age = shift;
15 $branch->look_down(id => 'age')->replace_content($age);
16 }
17
18
19 sub tage {
20 my $age = shift;
21 my $tree = HTML::TreeBuilder->new_from_file('t/html/highlander2.html');
22 my $if_then = $tree->look_down(id => 'age_dialog');
23
24 $if_then->highlander2(
25 cond => [
26 under10 => [
27 sub { $_[0] < 10} ,
28 \&replace_age
29 ],
30 under18 => [
31 sub { $_[0] < 18} ,
32 \&replace_age
33 ],
34 welcome => [
35 sub { 1 },
36 \&replace_age
37 ]
38 ],
39 cond_arg => [ $age ]
40 );
41
42 my $root = "t/html/highlander2-$age";
43
44 my $generated_html = ptree($tree, "$root.gen");
45
46 is ($generated_html, File::Slurp::read_file("$root.exp"), "HTML for $age");
47 }
48
49
50 tage($_) for qw(5 15 27);
This page took 0.044881 seconds and 4 git commands to generate.