From ef241a9f3297e8df93b04a08c3a9b23efb99eb40 Mon Sep 17 00:00:00 2001 From: Olaf Alders Date: Fri, 12 Oct 2018 16:12:08 -0400 Subject: [PATCH] Move tests to subests --- xt/author/live/encoding.t | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/xt/author/live/encoding.t b/xt/author/live/encoding.t index 6744160b..750344cd 100644 --- a/xt/author/live/encoding.t +++ b/xt/author/live/encoding.t @@ -2,30 +2,35 @@ use strict; use warnings; use constant PAIRS => { - 'https://www.tripadvisor.com/' - => 'utf-8', - 'http://www.liveinternet.ru/users/dashdi/blog' - => 'cp1251', + 'https://www.tripadvisor.com/' => 'utf-8', + 'http://www.liveinternet.ru/users/dashdi/blog' => 'cp1251', }; use Encode; use Test::More; use Test::Needs 'LWP::Protocol::https'; -use Test::RequiresInternet( 'www.tripadvisor.com' => 443, 'www.liveinternet.ru' => 80 ); +use Test::RequiresInternet( + 'www.tripadvisor.com' => 443, + 'www.liveinternet.ru' => 80 +); use WWW::Mechanize; -my %pairs = %{+PAIRS}; +my %pairs = %{ +PAIRS }; for my $url ( sort keys %pairs ) { - my $want_encoding = $pairs{$url}; + subtest $url => sub { + my $want_encoding = $pairs{$url}; - my $mech = WWW::Mechanize->new; + my $mech = WWW::Mechanize->new; - $mech->get( $url ); - is( $mech->response->code, 200, "Fetched $url" ); + $mech->get($url); + is( $mech->response->code, 200, "Fetched $url" ); - like( $mech->res->content_charset, qr/$want_encoding/i, - " ... Got encoding $want_encoding" ); - ok( Encode::is_utf8( $mech->content ), 'Got back UTF-8' ); + like( + $mech->res->content_charset, qr/$want_encoding/i, + " ... Got encoding $want_encoding" + ); + ok( Encode::is_utf8( $mech->content ), 'Got back UTF-8' ); + }; } done_testing();