]> iEval git - html-element-library.git/blame - t/highlander2.t
fixed test suite
[html-element-library.git] / t / highlander2.t
CommitLineData
67e78ff2 1# This might look like shell script, but it's actually -*- perl -*-
2use strict;
3use lib qw(t/ t/m/);
4
5use File::Slurp;
6use Test::More qw(no_plan);
7
8use TestUtils;
9use HTML::TreeBuilder;
10use HTML::Element::Library;
11
12sub replace_age {
13 my $branch = shift;
14 my $age = shift;
15 $branch->look_down(id => 'age')->replace_content($age);
16}
17
18
19sub 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
50tage($_) for qw(5 15 27);
This page took 0.021082 seconds and 4 git commands to generate.