| 1 |
#!/usr/bin/perl -w |
| 2 |
use strict; |
| 3 |
use lib './inc'; |
| 4 |
use IO::Catch; |
| 5 |
|
| 6 |
our ($_STDOUT_, $_STDERR_ ); |
| 7 |
|
| 8 |
# pre-5.8.0's warns aren't caught by a tied STDERR. |
| 9 |
tie *STDOUT, 'IO::Catch', '_STDOUT_' or die $!; |
| 10 |
tie *STDERR, 'IO::Catch', '_STDERR_' or die $!; |
| 11 |
|
| 12 |
our @comments = ( "#", "# a test", "#eval 1", "# eval 1", "## eval 1" ); |
| 13 |
|
| 14 |
# Disable all ReadLine functionality |
| 15 |
$ENV{PERL_RL} = 0; |
| 16 |
|
| 17 |
use Test::More; |
| 18 |
plan tests => 1 + scalar @comments * 3; |
| 19 |
SKIP: { |
| 20 |
#skip "Can't load Term::ReadKey without a terminal", 1 + scalar @comments * 3 |
| 21 |
# unless -t STDIN; |
| 22 |
#eval { require Term::ReadKey; Term::ReadKey::GetTerminalSize(); }; |
| 23 |
#if ($@) { |
| 24 |
# no warnings 'redefine'; |
| 25 |
# *Term::ReadKey::GetTerminalSize = sub {80,24}; |
| 26 |
# diag "Term::ReadKey seems to want a terminal"; |
| 27 |
#}; |
| 28 |
|
| 29 |
use_ok('WWW::Mechanize::Shell'); |
| 30 |
|
| 31 |
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef ); |
| 32 |
|
| 33 |
for (@comments) { |
| 34 |
$_STDOUT_ = ""; |
| 35 |
$_STDERR_ = ""; |
| 36 |
eval { $s->cmd($_); }; |
| 37 |
is($@,"","Comment '$_' produces no error"); |
| 38 |
is($_STDOUT_,"","Comment '$_' produces no output"); |
| 39 |
is($_STDERR_,"","Comment '$_' produces no error output"); |
| 40 |
}; |
| 41 |
|
| 42 |
}; |
| 43 |
|
| 44 |
|