Debian Codegraph @

t/02-fallback-HTML-TableExtract.t

raw
1 use strict;
2 use Test::More tests => 4;
3
4 # Disable all ReadLine functionality
5 $ENV{PERL_RL} = 0;
6
7 SKIP: {
8 #skip "Can't load Term::ReadKey without a terminal", 4
9 # unless -t STDIN;
10
11 eval {
12 require Test::Without::Module;
13 Test::Without::Module->import('HTML::TableExtract')
14 };
15 skip "Need Test::Without::Module to test the fallback", 4
16 if $@;
17
18 #eval { require Term::ReadKey; Term::ReadKey::GetTerminalSize(); };
19 #if ($@) {
20 # no warnings 'redefine';
21 # *Term::ReadKey::GetTerminalSize = sub {80,24};
22 # diag "Term::ReadKey seems to want a terminal";
23 #};
24
25 use_ok("WWW::Mechanize::Shell");
26 my $shell = do {
27 WWW::Mechanize::Shell->new("shell", rcfile => undef, warnings => undef );
28 };
29
30 isa_ok($shell,"WWW::Mechanize::Shell");
31 my $text;
32
33 my $warned;
34 {
35 local $SIG{__WARN__} = sub {
36 $warned = $_[0];
37 };
38
39 $shell->option('warnings',1);
40 eval {
41 $shell->cmd("tables");
42 };
43 };
44 is( $@, '', "No error without HTML::TableExtract");
45 my $pass = ($warned =~ qr'^HTML\W+TableExtract\.pm did not return a true value')
46 || ($warned =~ qr!^Can't locate HTML/TableExtract.pm in \@INC!);
47 ok $pass, "Missing HTML::TableExtract raises warning"
48 or diag "Caught warning '$warned'";
49 };