perl
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
t/run/switches.t view on Meta::CPAN
like( runperl( switches => [ '-M-=' ], stderr => 1,
prog => 'die q{oops}' ),
qr/Module name required with -M option\b/,
"-M- not allowed" );
} # disable TODO on VMS
}
is runperl(stderr => 1, prog => '#!perl -m'),
qq 'Too late for "-m" option at -e line 1.\n', '#!perl -m';
is runperl(stderr => 1, prog => '#!perl -M'),
qq 'Too late for "-M" option at -e line 1.\n', '#!perl -M';
# Tests for -V
{
local $TODO = ''; # these ones should work on VMS
# basic perl -V should generate significant output.
# we don't test actual format too much since it could change
like( runperl( switches => ['-V'] ), qr/(\n.*){20}/,
'-V generates 20+ lines' );
like( runperl( switches => ['-V'] ),
qr/\ASummary of my perl5 .*configuration:/,
'-V looks okay' );
# lookup a known config var
chomp( $r=runperl( switches => ['-V:osname'] ) );
is( $r, "osname='$^O';", 'perl -V:osname');
# lookup a nonexistent var
chomp( $r=runperl( switches => ['-V:this_var_makes_switches_test_fail'] ) );
is( $r, "this_var_makes_switches_test_fail='UNKNOWN';",
'perl -V:unknown var');
# regexp lookup
# platforms that don't like this quoting can either skip this test
# or fix test.pl _quote_args
$r = runperl( switches => ['"-V:i\D+size"'] );
# should be unlike( $r, qr/^$|not found|UNKNOWN/ );
like( $r, qr/^(?!.*(not found|UNKNOWN))./, 'perl -V:re got a result' );
# make sure each line we got matches the re
ok( !( grep !/^i\D+size=/, split /^/, $r ), '-V:re correct' );
}
# Tests for -v
{
local $TODO = ''; # these ones should work on VMS
# There may be build configs where this test will fail; DG/UX was one,
# but we no longer support it. Maybe we should remove these special cases?
SKIP:
{
skip "Win32 miniperl produces a default archname in -v", 1
if $^O eq 'MSWin32' && is_miniperl;
my $v = sprintf "%vd", $^V;
my $ver = $Config{PERL_VERSION};
my $rel = $Config{PERL_SUBVERSION};
like( runperl( switches => ['-v'] ),
qr/This is perl 5, version \Q$ver\E, subversion \Q$rel\E \(v\Q$v\E(?:[-*\w]+| \([^)]+\))?\) built for \Q$Config{archname}\E.+Copyright.+Larry Wall.+Artistic License.+GNU General Public License/s,
'-v looks okay' );
}
}
# Tests for -h and -?
{
local $TODO = ''; # these ones should work on VMS
like( runperl( switches => ['-h'] ),
qr/Usage: .+(?i:perl(?:$Config{_exe})?).+switches.+programfile.+arguments/,
'-h looks okay' );
like( runperl( switches => ['-?'] ),
qr/Usage: .+(?i:perl(?:$Config{_exe})?).+switches.+programfile.+arguments/,
'-? looks okay' );
}
# Tests for switches which do not exist
foreach my $switch (split //, "ABbGHJjKkLNOoPQqRrYyZz123456789_")
{
local $TODO = ''; # these ones should work on VMS
like( runperl( switches => ["-$switch"], stderr => 1,
prog => 'die q{oops}' ),
qr/\QUnrecognized switch: -$switch (-h will show valid options)./,
"-$switch correctly unknown" );
# [perl #104288]
like( runperl( stderr => 1, prog => "#!perl -$switch" ),
qr/^Unrecognized switch: -$switch \(-h will show valid (?x:
)options\) at -e line 1\./,
"-$switch unrecognised on #! line" );
}
# Tests for unshebangable switches
for (qw( e f x E S V )) {
$r = runperl(
stderr => 1,
prog => "#!perl -$_",
);
is $r, "Can't emulate -$_ on #! line at -e line 1.\n","-$_ on #! line";
}
# Tests for -i
SKIP:
{
local $TODO = ''; # these ones should work on VMS
sub do_i_unlink { unlink_all("tmpswitches", "tmpswitches.bak") }
open(FILE, ">tmpswitches") or die "$0: Failed to create 'tmpswitches': $!";
my $yada = <<__EOF__;
foo yada dada
bada foo bing
king kong foo
__EOF__
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.456 second using v1.00-cache-2.02-grep-82fe00e-cpan-1925d2aa809 )