#!./perl
BEGIN {
chdir 't' if -d 't';
}
#
# This file tries to test builtin override using CORE::GLOBAL
#
my $dirsep = "/";
my $t = 42;
#
# require has special behaviour
#
my $r;
require Foo;
require 'Foo';
require 5.6;
require v5.6;
eval "use Foo";
eval "use Foo::Bar";
eval "use 5.6";
# localizing *CORE::GLOBAL::foo should revert to finding CORE::foo
{
$r = '';
eval "require NoNeXiSt;";
}
#
# readline() has special behaviour too
#
$r = 11;
BEGIN { *CORE::GLOBAL::readline = sub (;*) { ++$r }; }
is( <FH> , 12 );
is( <$fh> , 13 );
my $pad_fh;
is( <$pad_fh> , 14 );
# Non-global readline() override
BEGIN { *Rgs::readline = sub (;*) { --$r }; }
package Rgs;
::is( <FH> , 13 );
::is( <$fh> , 12 );
::is( <$pad_fh> , 11 );
# by the indirect object notation
{
};
}