use utf8; use strict; use warnings; use lib 't/lib'; use Encode; use Text::Xatena::Test; use Cache::MemoryCache; use LWP::UserAgent; use LWP::Simple; local $Text::Xatena::Test::INLINE = "Text::Xatena::Inline::Aggressive"; local $Text::Xatena::Test::INLINE_ARGS = [ cache => Cache::MemoryCache->new ]; { no warnings 'redefine'; *LWP::UserAgent::get = sub { my ($self, $uri) = @_; my $res = { 'http://example.com/' => sub { HTTP::Response->new(200, "OK", ['Content-Type' => 'text/html'], "Example Web Page"); }, 'http://example.com/utf-8' => sub { HTTP::Response->new(200, "OK", ['Content-Type' => 'text/html'], encode("utf-8", "エグザンプルウェブページ")); }, 'http://example.com/shift_jis' => sub { HTTP::Response->new(200, "OK", ['Content-Type' => 'text/html'], encode("shift_jis", "エグザンプルウェブページ")); }, 'http://example.com/euc-jp' => sub { HTTP::Response->new(200, "OK", ['Content-Type' => 'text/html'], encode("euc-jp", "エグザンプルウェブページ")); }, 'http://example.com/shift_jis_ct' => sub { HTTP::Response->new(200, "OK", ['Content-Type' => 'text/html; charset=shift_jis'], encode("shift_jis", "エグザンプルウェブページ")); }, }; my $sub = $res->{$uri} or BAIL_OUT("Unexpected web access"); $sub->(); }; }; plan tests => 1 * blocks; run_html; __END__ === test --- input http://example.com/ --- expected

http://example.com/

=== test --- input http://example.com/ --- expected

http://example.com/

=== test --- input mailto:cho45@lowreal.net --- expected

cho45@lowreal.net

=== test --- input [http://example.com/] --- expected

http://example.com/

=== test --- input [http://example.com/:title=Foo bar] --- expected

Foo bar

=== test --- input [http://example.com/:barcode] --- expected

=== test --- input []http://example.com/[] --- expected

http://example.com/

=== test --- input http://example.com/ --- expected

http://example.com/

=== test --- input http://example.com/ --- expected

http://example.com/

=== http title --- input [http://example.com/:title] --- expected

Example Web Page

=== http title --- input [http://example.com/utf-8:title] --- expected

エグザンプルウェブページ

=== http title --- input [http://example.com/shift_jis:title] --- expected

エグザンプルウェブページ

=== http title --- input [http://example.com/euc-jp:title] --- expected

エグザンプルウェブページ

=== http title --- input [http://example.com/shift_jis_ct:title] --- expected

エグザンプルウェブページ