This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perlreapi: use parent in example, not base
[perl5.git] / t / io / layers.t
index d0b55f1..86d171c 100644 (file)
@@ -8,8 +8,7 @@ BEGIN {
     require './test.pl';
     skip_all_without_perlio();
     # FIXME - more of these could be tested without Encode or full perl
-    skip_all_if_miniperl("no dynamic loading on miniperl, no Encode");
-    skip_all_without_extension('Encode');
+    skip_all_without_dynamic_extension('Encode');
 
     # Makes testing easier.
     $ENV{PERLIO} = 'stdio' if exists $ENV{PERLIO} && $ENV{PERLIO} eq '';
@@ -36,7 +35,7 @@ if (${^UNICODE} & 1) {
 } else {
     $UTF8_STDIN = 0;
 }
-my $NTEST = 55 - (($DOSISH || !$FASTSTDIO) ? 7 : 0) - ($DOSISH ? 7 : 0)
+my $NTEST = 60 - (($DOSISH || !$FASTSTDIO) ? 7 : 0) - ($DOSISH ? 7 : 0)
     + $UTF8_STDIN;
 
 sub PerlIO::F_UTF8 () { 0x00008000 } # from perliol.h
@@ -228,4 +227,27 @@ __EOH__
 open(UTF, "<:raw:encoding(utf8)", '$afile') or die \$!;
 print ref *PerlIO::Layer::NoWarnings{CODE};
 EOT
+
+    # [perl #97956] Not calling FETCH all the time on tied variables
+    my $f;
+    sub TIESCALAR { bless [] }
+    sub FETCH { ++$f; $_[0][0] = $_[1] }
+    sub STORE { $_[0][0] }
+    tie my $t, "";
+    $t = *f;
+    $f = 0; PerlIO::get_layers $t;
+    is $f, 1, '1 fetch on tied glob';
+    $t = \*f;
+    $f = 0; PerlIO::get_layers $t;
+    is $f, 1, '1 fetch on tied globref';
+    $t = *f;
+    $f = 0; PerlIO::get_layers \$t;
+    is $f, 1, '1 fetch on referenced tied glob';
+    $t = '';
+    $f = 0; PerlIO::get_layers $t;
+    is $f, 1, '1 fetch on tied string';
+
+    # No distinction between nums and strings
+    open "12", "<:crlf", "test.pl" or die "$0 cannot open test.pl: $!";
+    ok PerlIO::get_layers(12), 'str/num arguments are treated identically';
 }