Skip to content

Commit

Permalink
t: Either skip a test or run, not both
Browse files Browse the repository at this point in the history
When $host was down the test crashed, because match method would be
called on an undefined value.

Also as per S24 "The C<skip()> function is called I<instead> of the some
tests (usually because they would die), and emits C<$count> SKIP markers
in the TAP output".
  • Loading branch information
Maxim Vuets committed Nov 30, 2014
1 parent 5ecdf4c commit 5afc078
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions t/custom-headers-and-content.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ my %headers = ( 'Content-Type' => 'application/json' );
my $content = '{"method":"echo","params":["Hello from Perl6"],"id":1}';
my $html = LWP::Simple.post($host, %headers, $content);

skip("Unable to connect to test site '$host'", 1) unless $html;
ok(
$html.match('Hello from Perl6'),
'call to JSON-RPC service using headers and content params'
);
if $html {
ok(
$html.match('Hello from Perl6'),
'call to JSON-RPC service using headers and content params'
);
}
else {
skip("Unable to connect to test site '$host'", 1);
}

done;

0 comments on commit 5afc078

Please sign in to comment.