@@ -6,6 +6,20 @@ 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+
923my @warn ;
1024$SIG {__WARN__ } = sub { push ( @warn , $_ [0] ) };
1125
8397# print $f->dump;
8498# print $f->click->as_string;
8599
86- is ( $f -> click-> as_string, <<'EOT' );
100+ is_maybe_nl ( $f -> click-> as_string, <<'EOT' );
87101POST http://localhost/
88102Content-Length: 86
89103Content-Type: application/x-www-form-urlencoded
463477ok( $f -> find_input(" randomkey" ) );
464478is( $f -> find_input(" randomkey" )-> challenge, " 1234567890" );
465479is( $f -> find_input(" randomkey" )-> keytype, " rsa" );
466- is ( $f -> click-> as_string, <<EOT );
480+ is_maybe_nl ( $f -> click-> as_string, <<EOT );
467481POST http://example.com/secure/keygen/test.cgi
468482Content-Length: 19
469483Content-Type: application/x-www-form-urlencoded
@@ -472,7 +486,7 @@ Field1=Default+Text
472486EOT
473487
474488$f -> value( randomkey => " foo" );
475- is ( $f -> click-> as_string, <<EOT );
489+ is_maybe_nl ( $f -> click-> as_string, <<EOT );
476490POST http://example.com/secure/keygen/test.cgi
477491Content-Length: 33
478492Content-Type: application/x-www-form-urlencoded
@@ -602,7 +616,7 @@ $f = HTML::Form->parse( <<EOT, base => "http://localhost/" );
602616</form>
603617EOT
604618
605- is ( $f -> click-> as_string, <<EOT );
619+ is_maybe_nl ( $f -> click-> as_string, <<EOT );
606620POST http://localhost/
607621Content-Length: 9
608622Content-Type: application/x-www-form-urlencoded
@@ -617,7 +631,7 @@ $f = HTML::Form->parse( <<EOT, base => "http://localhost/" );
617631</form>
618632EOT
619633
620- is ( $f -> click-> as_string, <<EOT );
634+ is_maybe_nl ( $f -> click-> as_string, <<EOT );
621635POST http://localhost/
622636Content-Length: 7
623637Content-Type: application/x-www-form-urlencoded
@@ -674,4 +688,4 @@ GET http://localhost/target.html?foo=option+in+named
674688EOT
675689}
676690
677- done_testing;
691+ done_testing;
0 commit comments