@@ -6,20 +6,6 @@ use warnings;
66use Test::More;
77use HTML::Form;
88
9- # this handles all versions of HTTP::Message, both before and after
10- # 7.01, when the stringification of requests changed
11- sub is_maybe_nl {
12- my ($got , $expected , $message ) = @_ ;
13-
14- local $Test::Builder::Level = $Test::Builder::Level + 1;
15-
16- if ($got !~ m {\n $} && $expected =~ m {\n $} ) {
17- chomp ($expected );
18- }
19-
20- is($got , $expected , $message );
21- }
22-
239my @warn ;
2410$SIG {__WARN__ } = sub { push ( @warn , $_ [0] ) };
2511
9783# print $f->dump;
9884# print $f->click->as_string;
9985
100- is_maybe_nl( $f -> click -> as_string, <<'EOT' );
86+ chomp ( my $expected_advanced = <<'EOT' );
10187POST http://localhost/
10288Content-Length: 86
10389Content-Type: application/x-www-form-urlencoded
10490
10591i.x=1&i.y=1&c=on&r=b&t=&p=&tel=&date=&h=xyzzy&f=&x=&a=%0D%0Aabc%0D%0A+++&s=bar&m=a&m=b
10692EOT
93+ is( $f -> click-> as_string, $expected_advanced );
10794
10895is( @warn , 1 );
10996like( $warn [0], qr / ^Unknown input type 'xyzzy'/ );
@@ -477,22 +464,24 @@ EOT
477464ok( $f -> find_input(" randomkey" ) );
478465is( $f -> find_input(" randomkey" )-> challenge, " 1234567890" );
479466is( $f -> find_input(" randomkey" )-> keytype, " rsa" );
480- is_maybe_nl( $f -> click -> as_string, <<EOT );
467+ chomp ( my $expected_keygen = <<EOT );
481468POST http://example.com/secure/keygen/test.cgi
482469Content-Length: 19
483470Content-Type: application/x-www-form-urlencoded
484471
485472Field1=Default+Text
486473EOT
474+ is( $f -> click-> as_string, $expected_keygen );
487475
488476$f -> value( randomkey => " foo" );
489- is_maybe_nl( $f -> click -> as_string, <<EOT );
477+ chomp ( my $expected_keygen_foo = <<EOT );
490478POST http://example.com/secure/keygen/test.cgi
491479Content-Length: 33
492480Content-Type: application/x-www-form-urlencoded
493481
494482randomkey=foo&Field1=Default+Text
495483EOT
484+ is( $f -> click-> as_string, $expected_keygen_foo );
496485
497486$f = HTML::Form-> parse( <<EOT , " http://www.example.com" );
498487<form ACTION="http://example.com/">
@@ -616,13 +605,14 @@ $f = HTML::Form->parse( <<EOT, base => "http://localhost/" );
616605</form>
617606EOT
618607
619- is_maybe_nl( $f -> click -> as_string, <<EOT );
608+ chomp ( my $expected_button_go = <<EOT );
620609POST http://localhost/
621610Content-Length: 9
622611Content-Type: application/x-www-form-urlencoded
623612
624613submit=go
625614EOT
615+ is( $f -> click-> as_string, $expected_button_go );
626616
627617$f = HTML::Form-> parse( <<EOT , base => " http://localhost/" );
628618<form method=post>
@@ -631,13 +621,14 @@ $f = HTML::Form->parse( <<EOT, base => "http://localhost/" );
631621</form>
632622EOT
633623
634- is_maybe_nl( $f -> click -> as_string, <<EOT );
624+ chomp ( my $expected_button_empty = <<EOT );
635625POST http://localhost/
636626Content-Length: 7
637627Content-Type: application/x-www-form-urlencoded
638628
639629submit=
640630EOT
631+ is( $f -> click-> as_string, $expected_button_empty );
641632
642633# select with a name followed by select without a name GH#2
643634$f = HTML::Form-> parse( <<EOT , " http://localhost/" );
0 commit comments