| 1 |
#!/usr/bin/perl -w |
| 2 |
use strict; |
| 3 |
use lib './inc'; |
| 4 |
use IO::Catch; |
| 5 |
|
| 6 |
use File::Temp qw( tempfile ); |
| 7 |
our ($_STDOUT_, $_STDERR_); |
| 8 |
|
| 9 |
# pre-5.8.0's warns aren't caught by a tied STDERR. |
| 10 |
tie *STDOUT, 'IO::Catch', '_STDOUT_' or die $!; |
| 11 |
tie *STDERR, 'IO::Catch', '_STDERR_' or die $!; |
| 12 |
|
| 13 |
use Test::More tests => 7; |
| 14 |
|
| 15 |
# Disable all ReadLine functionality |
| 16 |
$ENV{PERL_RL} = 0; |
| 17 |
|
| 18 |
use_ok('WWW::Mechanize::Shell'); |
| 19 |
|
| 20 |
sub command_ok { |
| 21 |
my ($command,$expected,$name) = @_; |
| 22 |
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef ); |
| 23 |
$s->agent->get("file:t/17-eval-multiline.t"); |
| 24 |
eval { $s->cmd($command) }; |
| 25 |
is($@,"","$name does not crash") |
| 26 |
or diag "Crash on '$command'"; |
| 27 |
is($_STDERR_,undef,"$name produces no warnings"); |
| 28 |
is($_STDOUT_,$expected,"$name produces the desired output") |
| 29 |
or diag "Command: '$command'"; |
| 30 |
undef $_STDOUT_; |
| 31 |
undef $_STDERR_; |
| 32 |
}; |
| 33 |
|
| 34 |
command_ok('eval "Hello", |
| 35 |
" World"', "Hello World\n","Multiline eval"); |
| 36 |
command_ok('eval "Hello from ", |
| 37 |
$self->agent->uri || ""', "Hello from file:t/17-eval-multiline.t\n","Multiline eval substitution"); |