'.$input;
$input =~ s/(dest=address)/$1 sqlquery=1/;
$input .= <<'END_OF_HTML';
Names = $address->names$
Values = $address->values$
Update = $address->update$
END_OF_HTML
$output .= <<'END_OF_HTML';
Names = date2,date3,city,name,zip,date1,street
Values = '1998-07-02','2008-07-02','Metzingen','joe',72555,'1998-07-02','Am Eisteich 9'
Update = date2='1998-07-02',date3='2008-07-02',city='Metzingen',name='joe',zip=72555,date1='1998-07-02',street='Am Eisteich 9'
END_OF_HTML
$parser = HTML::EP->new();
Test2($parser->Run($input), $output,
"Object input with 'sqlquery' set.\n");
}
$ENV{QUERY_STRING} = 'art_0_t_name=Book&art_0_n_price=5.00'
. '&art_1_t_name=Donut&art_1_n_price=1.00';
$input = <<'_END_OF_HTML';
Name = $a->name->val$, Price = $a->price->val$, Item = $a->i$
_END_OF_HTML
$output = <<'_END_OF_HTML';
Name = Book, Price = 5.00, Item = 0
Name = Donut, Price = 1.00, Item = 1
_END_OF_HTML
undef @CGI::QUERY_PARAM; # Arrgh! CGI caches :-(
$parser = HTML::EP->new();
Test2($parser->Run($input), $output, "Object list input.\n");
$input = <<'_END_OF_HTML';
0123
_END_OF_HTML
for (my $i = 0; $i < 4; $i++) {
$output = <<"_END_OF_HTML";
$i
_END_OF_HTML
$parser = HTML::EP->new();
$parser->{i} = $i;
Test2($parser->Run($input), $output, "If: $i.\n");
}
$input = <<'_END_OF_HTML';
i is < 0.
i equals 0.
j is < 0.
j equals 0.
Both numbers are > 0.
_END_OF_HTML
my $ref;
my @conditionals = (
[ -1, -1, "i is < 0." ],
[ -1, 0, "i is < 0." ],
[ -1, 1, "i is < 0." ],
[ 0, -1, "i equals 0." ],
[ 0, 0, "i equals 0." ],
[ 0, 1, "i equals 0." ],
[ 1, -1, "j is < 0." ],
[ 1, 0, "j equals 0." ],
[ 1, 1, "Both numbers are > 0." ]
);
foreach $ref (@conditionals) {
$parser = HTML::EP->new();
$parser->{i} = $ref->[0];
$parser->{j} = $ref->[1];
my $result = $ref->[2];
$output = <<"_END_OF_HTML";
$result
_END_OF_HTML
Test2($parser->Run($input), $output);
}
$input = <<'_END_OF_HTML';
i is < 0.
i equals 0.
j is < 0.
j equals 0.
Both numbers are > 0.
_END_OF_HTML
foreach $ref (@conditionals) {
$parser = HTML::EP->new();
$parser->{i} = $ref->[0];
$parser->{j} = $ref->[1];
my $result = $ref->[2];
$output = <<"_END_OF_HTML";
$result
_END_OF_HTML
Test2($parser->Run($input), $output);
}
my $cfg;
if (-f "lib/HTML/EP/Config.pm") {
$cfg = do "lib/HTML/EP/Config.pm";
}
if (!$cfg->{email} || $cfg->{email} eq 'none' || !$cfg->{mailhost}) {
Test(1);
} else {
print("Sending mail to ", $cfg->{email}, " via mail server ",
$cfg->{mailhost}, "\n");
$input = <<'_END_OF_HTML';
Hello,
this is a testmail from the script t/misc.t in the HTML::EP distribution.
You may safely ignore it. It was sent to $cgi->email$ by using the mailserver
$cgi->mailhost$.
You should be alarmed, though, if it doesn't reach you. :-)
Yours sincerely,
Jochen Wiedmann
_END_OF_HTML
$output = <<'_END_OF_HTML';
_END_OF_HTML
$ENV{QUERY_STRING} = 'email=' . CGI->escape($cfg->{email}) .
'&mailhost=' . CGI->escape($cfg->{mailhost});
undef @CGI::QUERY_PARAM; # Arrgh! CGI caches :-(
$parser = HTML::EP->new();
Test2($parser->Run($input), $output);
}
print "Checking nested loops.\n";
$input = q{
j$j$k$k$l$l$};
$output = "\n";
for (my $j = 1; $j < 4; $j++) {
for (my $k = 4; $k < 7; $k++) {
for (my $l = 7; $l < 10; $l++) {
$output .= "j${j}k${k}l$l";
}
}
}
$parser = HTML::EP->new();
Test2($parser->Run($input), $output);
print "Checking nested loop/if.\n";
$input = q{
aok$j$b};
$output = "\naok1baok2babab";
$parser = HTML::EP->new();
Test2($parser->Run($input), $output);
print "Checking nested if/loop.\n";
$input = q{a$j$};
$output = "a1a2a3a4";
$parser = HTML::EP->new();
$parser->{'a'} = 1;
Test2($parser->Run($input), $output);
$parser = HTML::EP->new();
$parser->{'a'} = 0;
Test2($parser->Run($input), "");
print "Checking repeated ep-package\n";
$input = q{
};
$parser = HTML::EP->new();
Test2($parser->Run($input), "\n\n\n");
Test(ref($parser) eq "HTML::EP::PACK2")
or print "$parser is a ", ref($parser), "\n";
Test(@HTML::EP::PACK2::ISA == 2 &&
$HTML::EP::PACK2::ISA[0] eq 'HTML::EP::EditTable' &&
$HTML::EP::PACK2::ISA[1] eq 'HTML::EP::Locale')
or print "Wrong ISA, got\n", map { " $_\n " } @HTML::EP::PACK2::ISA;
print "Checking ep-set nested with ep-list.\n";
$parser = HTML::EP->new();
$parser->{'list'} = [1,2,3,4];
$input = '$l$$Foo$';
Test2($parser->Run($input), "1234");
END { unlink 'foo' }