Debian lenny version packages
[pkg-perl] / deb-src / libwww-mechanize-perl / libwww-mechanize-perl-1.34 / t / autocheck.t
1 #!perl -Tw
2
3 use warnings;
4 use strict;
5 use Test::More;
6
7 use constant NONEXISTENT => 'http://blahblablah.xx-nonexistent.';
8
9 BEGIN {
10     if (gethostbyname('blahblahblah.xx-nonexistent.')) {
11         plan skip_all => 'Found an A record for the non-existent domain';
12     }
13 }
14
15 BEGIN {
16     eval 'use Test::Exception';
17     plan skip_all => 'Test::Exception required to test autocheck' if $@;
18     plan tests => 5;
19 }
20
21 BEGIN { delete @ENV{ qw( http_proxy HTTP_PROXY ) }; }
22 BEGIN {
23     use_ok( 'WWW::Mechanize' );
24 }
25
26 AUTOCHECK_OFF: {
27     my $mech = WWW::Mechanize->new;
28     isa_ok( $mech, 'WWW::Mechanize' );
29
30     $mech->get( NONEXISTENT );
31     ok( !$mech->success, q{Didn't fetch, but didn't die, either} );
32 }
33
34 AUTOCHECK_ON: {
35     my $mech = WWW::Mechanize->new( autocheck => 1 );
36     isa_ok( $mech, 'WWW::Mechanize' );
37
38     dies_ok {
39         $mech->get( NONEXISTENT );
40     } 'Mech would die 4 u';
41 }