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.
50 lines
1.1 KiB
Perl
50 lines
1.1 KiB
Perl
#!./perl
|
|
|
|
BEGIN {
|
|
chdir 't' if -d 't';
|
|
require "../t/test.pl";
|
|
set_up_inc('../lib');
|
|
skip_all_without_perlio();
|
|
}
|
|
|
|
plan (15);
|
|
|
|
use warnings 'layer';
|
|
my $warn;
|
|
my $file = "fail$$";
|
|
$SIG{__WARN__} = sub { $warn = shift };
|
|
|
|
END { 1 while unlink($file) }
|
|
|
|
ok(open(FH,">",$file),"Create works");
|
|
close(FH);
|
|
ok(open(FH,"<",$file),"Normal open works");
|
|
|
|
$warn = ''; $! = 0;
|
|
ok(!binmode(FH,":-)"),"All punctuation fails binmode");
|
|
print "# $!\n";
|
|
isnt($!,0,"Got errno");
|
|
like($warn,qr/in PerlIO layer/,"Got warning");
|
|
|
|
$warn = ''; $! = 0;
|
|
ok(!binmode(FH,":nonesuch"),"Bad package fails binmode");
|
|
print "# $!\n";
|
|
isnt($!,0,"Got errno");
|
|
like($warn,qr/nonesuch/,"Got warning");
|
|
close(FH);
|
|
|
|
$warn = ''; $! = 0;
|
|
ok(!open(FH,"<:-)",$file),"All punctuation fails open");
|
|
print "# $!\n";
|
|
isnt($!,"","Got errno");
|
|
like($warn,qr/in PerlIO layer/,"Got warning");
|
|
|
|
$warn = ''; $! = 0;
|
|
ok(!open(FH,"<:nonesuch",$file),"Bad package fails open");
|
|
print "# $!\n";
|
|
isnt($!,0,"Got errno");
|
|
like($warn,qr/nonesuch/,"Got warning");
|
|
|
|
ok(open(FH,"<",$file),"Normal open (still) works");
|
|
close(FH);
|