This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Guard write test against miniperl
[perl5.git] / t / op / write.t
old mode 100755 (executable)
new mode 100644 (file)
index 96e99e4..4038f43
@@ -61,7 +61,7 @@ for my $tref ( @NumTests ){
 my $bas_tests = 20;
 
 # number of tests in section 3
-my $bug_tests = 4 + 3 * 3 * 5 * 2 * 3;
+my $bug_tests = 4 + 3 * 3 * 5 * 2 * 3 + 2 + 2 + 1;
 
 # number of tests in section 4
 my $hmb_tests = 35;
@@ -569,6 +569,15 @@ for my $tref ( @NumTests ){
   }
 }
 
+{
+  # This will fail an assertion in 5.10.0 built with -DDEBUGGING (because
+  # pp_formline attempts to set SvCUR() on an SVt_RV). I suspect that it will
+  # be doing something similarly out of bounds on everything from 5.000
+  my $ref = [];
+  is swrite('>^*<', $ref), ">$ref<";
+  is swrite('>@*<', $ref), ">$ref<";
+}
+
 format EMPTY =
 .
 
@@ -598,6 +607,40 @@ $= = 10;
 select $oldfh;
 close STDOUT_DUP;
 
+*CmT =  *{$::{Comment}}{FORMAT};
+ok  defined *{$::{CmT}}{FORMAT}, "glob assign";
+
+if ($ENV{PERL_CORE_MINITEST}) {
+    ok 1, "Skip test for miniperl, as it does not support scalario";
+}
+else {
+    my $buf = "";
+    open my $fh, ">", \$buf;
+    my $old_fh = select $fh;
+    local $~ = "CmT";
+    write;
+    select $old_fh;
+    close $fh;
+    is $buf, "ok $test\n", "write to duplicated format";
+}
+
+fresh_perl_like(<<'EOP', qr/^Format STDOUT redefined at/, {stderr => 1}, '#64562 - Segmentation fault with redefined formats and warnings');
+#!./perl
+
+use strict;
+use warnings; # crashes!
+
+format =
+.
+
+write;
+
+format =
+.
+
+write;
+EOP
+
 #############################
 ## Section 4
 ## Add new tests *above* here
@@ -608,7 +651,7 @@ close STDOUT_DUP;
 # Just a complete test for format, including top-, left- and bottom marging
 # and format detection through glob entries
 
-if ($^O eq 'VMS' || $^O eq 'MSWin32' || $^O eq 'dos' || $^O eq 'MacOS' ||
+if ($^O eq 'VMS' || $^O eq 'MSWin32' || $^O eq 'dos' ||
     ($^O eq 'os2' and not eval '$OS2::can_fork')) {
   $test = curr_test();
  SKIP: {