This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Filehandle method calls load IO::File on demand
[perl5.git] / t / io / open.t
index 5bbcb0b..5a8f008 100644 (file)
@@ -10,7 +10,7 @@ $|  = 1;
 use warnings;
 use Config;
 
-plan tests => 111;
+plan tests => 114;
 
 my $Perl = which_perl();
 
@@ -347,3 +347,13 @@ fresh_perl_is(
         # when this fails, it leaves an extra file:
         or unlink \*STDOUT;
 }
+
+# check that we can call methods on filehandles auto-magically
+# and have IO::File loaded for us
+{
+    is( $INC{'IO/File.pm'}, undef, "IO::File not loaded" );
+    my $var = "";
+    open my $fh, ">", \$var;
+    ok( eval { $fh->autoflush(1); 1 }, '$fh->autoflush(1) lives' );
+    ok( $INC{'IO/File.pm'}, "IO::File now loaded" );
+}