This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #115254] Fix flag check on scope exit
[perl5.git] / t / lib / universal.t
index 71223b4..d3510c4 100644 (file)
@@ -6,11 +6,11 @@ BEGIN {
     chdir 't' if -d 't';
     @INC = '../lib';
     require './test.pl';
-    plan( tests => 13 );
+    plan( tests => 16 );
 }
 
 for my $arg ('', 'q[]', qw( 1 undef )) {
-    fresh_perl_is(<<"----", <<'====', "Internals::* functions check their argument under func() AND &func() [perl #77776]");
+    fresh_perl_is(<<"----", <<'====', {}, "Internals::* functions check their argument under func() AND &func() [perl #77776]");
 sub tryit { eval shift or warn \$@ }
 tryit "&Internals::SvREADONLY($arg)";
 tryit "&Internals::SvREFCNT($arg)";
@@ -60,3 +60,12 @@ Internals::SvREADONLY($h{b},0);
 $h{b} =~ y/ia/ao/;
 is __PACKAGE__, 'main',
   'turning off a cow’s readonliness did not affect sharers of the same PV';
+
+&Internals::SvREADONLY(\!0, 0);
+eval { ${\!0} = 7 };
+like $@, qr "^Modification of a read-only value",
+    'protected values still croak on assignment after SvREADONLY(..., 0)';
+is ${\3} == 3, "1", 'attempt to modify failed';
+
+eval { { my $x = ${qr//}; Internals::SvREADONLY $x, 1; () } };
+is $@, "", 'read-only lexical regexps on scope exit [perl #115254]';