3
# Main testing for LWP-Online
11
use Test::More tests => 6;
12
use LWP::Online 'online', 'offline';
14
ok( defined &online, 'LWP::Online exports the online function' );
15
ok( defined &offline, 'LWP::Online exports the offline function' );
17
# We can't actually be sure if we are online or not currently.
18
# So as long as calling online never crashes, and returns EITHER
19
# 1 or '', then it is a success.
20
diag("\nLooking for the internet, this may take a few minutes if you are offline...");
22
my $rv = eval { online() };
23
is( $@, '', 'Call to online() does not crash' );
24
ok( ($rv eq '1' or $rv eq ''), "online() returns a valid result '$rv'" );
26
diag("You are online");
28
diag("You are not online");
30
my $off = eval { offline() };
31
is( $@, '', 'Call to offline() does not crash' );
32
is( $off, ! $rv, 'online() and offline() return opposite results' );