mirror of
https://github.com/Perl/perl5.git
synced 2026-01-26 08:38:23 +00:00
Use set_up_inc when require.pl is loaded move plan outside of BEGIN block when no tests are run at BEGIN time. Using set_up_inc allow to run these tests under minitest but also compile them using B::C. This also has the advantage to use a single control point for @INC setup. Note: some tests cannot use 'require test.pl', unshfit is then used for them.
85 lines
2.4 KiB
Perl
85 lines
2.4 KiB
Perl
#!./perl
|
|
|
|
# Test that various IO functions don't try to treat PVBMs as
|
|
# filehandles. Most of these will segfault perl if they fail.
|
|
|
|
BEGIN {
|
|
chdir 't' if -d 't';
|
|
require "./test.pl";
|
|
set_up_inc(qw(. ../lib));
|
|
}
|
|
|
|
BEGIN { $| = 1 }
|
|
|
|
plan(28);
|
|
|
|
sub PVBM () { 'foo' }
|
|
{ my $dummy = index 'foo', PVBM }
|
|
|
|
{
|
|
my $which;
|
|
{
|
|
package Tie;
|
|
|
|
sub TIEHANDLE { $which = 'TIEHANDLE' }
|
|
sub TIESCALAR { $which = 'TIESCALAR' }
|
|
}
|
|
my $pvbm = PVBM;
|
|
|
|
tie $pvbm, 'Tie';
|
|
is ($which, 'TIESCALAR', 'PVBM gets TIESCALAR');
|
|
}
|
|
|
|
{
|
|
my $pvbm = PVBM;
|
|
ok (scalar eval { untie $pvbm; 1 }, 'untie(PVBM) doesn\'t segfault');
|
|
ok (scalar eval { tied $pvbm; 1 }, 'tied(PVBM) doesn\'t segfault');
|
|
}
|
|
|
|
{
|
|
my $pvbm = PVBM;
|
|
|
|
ok (scalar eval { pipe $pvbm, PIPE; }, 'pipe(PVBM, ) succeeds');
|
|
close foo;
|
|
close PIPE;
|
|
ok (scalar eval { pipe PIPE, $pvbm; }, 'pipe(, PVBM) succeeds');
|
|
close foo;
|
|
close PIPE;
|
|
ok (!eval { pipe \$pvbm, PIPE; }, 'pipe(PVBM ref, ) fails');
|
|
ok (!eval { pipe PIPE, \$pvbm; }, 'pipe(, PVBM ref) fails');
|
|
|
|
ok (!eval { truncate $pvbm, 0 }, 'truncate(PVBM) fails');
|
|
ok (!eval { truncate \$pvbm, 0}, 'truncate(PVBM ref) fails');
|
|
|
|
ok (!eval { stat $pvbm }, 'stat(PVBM) fails');
|
|
ok (!eval { stat \$pvbm }, 'stat(PVBM ref) fails');
|
|
|
|
ok (!eval { lstat $pvbm }, 'lstat(PVBM) fails');
|
|
ok (!eval { lstat \$pvbm }, 'lstat(PVBM ref) fails');
|
|
|
|
ok (!eval { chdir $pvbm }, 'chdir(PVBM) fails');
|
|
ok (!eval { chdir \$pvbm }, 'chdir(pvbm ref) fails');
|
|
|
|
ok (!eval { close $pvbm }, 'close(PVBM) fails');
|
|
ok (!eval { close $pvbm }, 'close(PVBM ref) fails');
|
|
|
|
ok (!eval { chmod 0600, $pvbm }, 'chmod(PVBM) fails');
|
|
ok (!eval { chmod 0600, \$pvbm }, 'chmod(PVBM ref) fails');
|
|
|
|
SKIP: {
|
|
skip('chown() not implemented on Win32', 2) if $^O eq 'MSWin32';
|
|
ok (!eval { chown 0, 0, $pvbm }, 'chown(PVBM) fails');
|
|
ok (!eval { chown 0, 0, \$pvbm }, 'chown(PVBM ref) fails');
|
|
}
|
|
|
|
ok (!eval { utime 0, 0, $pvbm }, 'utime(PVBM) fails');
|
|
ok (!eval { utime 0, 0, \$pvbm }, 'utime(PVBM ref) fails');
|
|
|
|
ok (!eval { <$pvbm> }, '<PVBM> fails');
|
|
ok (!eval { readline $pvbm }, 'readline(PVBM) fails');
|
|
ok (!eval { readline \$pvbm }, 'readline(PVBM ref) fails');
|
|
|
|
ok (!eval { open $pvbm, '<', 'none.such' }, 'open(PVBM) fails');
|
|
ok (!eval { open \$pvbm, '<', 'none.such', }, 'open(PVBM ref) fails');
|
|
}
|