| 1 |
#!/usr/bin/perl -w |
| 2 |
use strict; |
| 3 |
use lib './inc'; |
| 4 |
use IO::Catch; |
| 5 |
|
| 6 |
our ($_STDOUT_, $_STDERR_); |
| 7 |
tie *STDOUT, 'IO::Catch', '_STDOUT_' or die $!; |
| 8 |
tie *STDERR, 'IO::Catch', '_STDERR_' or die $!; |
| 9 |
|
| 10 |
use Test::More tests => 4; |
| 11 |
|
| 12 |
# Disable all ReadLine functionality |
| 13 |
$ENV{PERL_RL} = 0; |
| 14 |
delete $ENV{PAGER} |
| 15 |
if $ENV{PAGER}; |
| 16 |
$ENV{PERL_HTML_DISPLAY_CLASS}="HTML::Display::Dump"; |
| 17 |
|
| 18 |
my @warnings; |
| 19 |
|
| 20 |
use_ok('WWW::Mechanize::Shell'); |
| 21 |
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef ); |
| 22 |
|
| 23 |
{ no warnings qw'redefine once'; |
| 24 |
*WWW::Mechanize::Shell::status = sub {}; |
| 25 |
}; |
| 26 |
|
| 27 |
$s->agent->{base} = 'http://www.google.com/'; |
| 28 |
$s->agent->update_html("<html><body>No form here</body></html>\n"); |
| 29 |
|
| 30 |
eval { |
| 31 |
$s->cmd("form foo"); |
| 32 |
}; |
| 33 |
is($@, '', "Can execute 'form' for a page without forms"); |
| 34 |
is($_STDOUT_,"There is no form on this page.\n","Message was printed"); |
| 35 |
is($_STDERR_,undef,"No warnings printed"); |
| 36 |
|
| 37 |
#$_STDOUT_ = undef; |
| 38 |
#$_STDERR_ = undef; |
| 39 |
|
| 40 |
#$s->cmd("save /does-not-exist/"); |
| 41 |
#is($_STDOUT_,"No match for /(?-xism:does-not-exist)/.\n","save RE error message"); |
| 42 |
#is($_STDERR_,undef,"No warnings"); |
| 43 |
|
| 44 |
|