This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
numeric.c:S_mulexp10 -- quit when you can
[perl5.git] / t / op / override.t
index db94ed0..1a4e5e0 100755 (executable)
@@ -6,7 +6,7 @@ BEGIN {
     push @INC, '../lib';
 }
 
-print "1..10\n";
+print "1..17\n";
 
 #
 # This file tries to test builtin override using CORE::GLOBAL
@@ -61,3 +61,30 @@ print "ok 9\n";
 eval "use 5.6";
 print "not " unless $r eq "5.6";
 print "ok 10\n";
+
+# localizing *CORE::GLOBAL::foo should revert to finding CORE::foo
+{
+    local(*CORE::GLOBAL::require);
+    $r = '';
+    eval "require NoNeXiSt;";
+    print "not " if $r or $@ !~ /^Can't locate NoNeXiSt/i;
+    print "ok 11\n";
+}
+
+#
+# readline() has special behaviour too
+#
+
+$r = 11;
+BEGIN { *CORE::GLOBAL::readline = sub (;*) { ++$r }; }
+print <FH>     == 12 ? "ok 12\n" : "not ok 12\n";
+print <$fh>    == 13 ? "ok 13\n" : "not ok 13\n";
+my $pad_fh;
+print <$pad_fh>        == 14 ? "ok 14\n" : "not ok 14\n";
+
+# Non-global readline() override
+BEGIN { *Rgs::readline = sub (;*) { --$r }; }
+package Rgs;
+print <FH>     == 13 ? "ok 15\n" : "not ok 15\n";
+print <$fh>    == 12 ? "ok 16\n" : "not ok 16\n";
+print <$pad_fh>        == 11 ? "ok 17\n" : "not ok 17\n";