my $bas_tests = 20;
# number of tests in section 3
-my $bug_tests = 4 + 3 * 3 * 3;
+my $bug_tests = 4 + 3 * 3 * 5 * 2 * 3 + 2 + 1;
# number of tests in section 4
my $hmb_tests = 35;
}
{
- my ($pound_utf8, $pm_utf8) = map { my $a = "$_\x{100}"; chop $a; $a}
+ package Count;
+
+ sub TIESCALAR {
+ my $class = shift;
+ bless [shift, 0, 0], $class;
+ }
+
+ sub FETCH {
+ my $self = shift;
+ ++$self->[1];
+ $self->[0];
+ }
+
+ sub STORE {
+ my $self = shift;
+ ++$self->[2];
+ $self->[0] = shift;
+ }
+}
+
+{
+ my ($pound_utf8, $pm_utf8) = map { my $a = "$_\x{100}"; chop $a; $a}
my ($pound, $pm) = ("\xA3", "\xB1");
foreach my $first ('N', $pound, $pound_utf8) {
foreach my $base ('N', $pm, $pm_utf8) {
- foreach my $second ($base, "$base\n", "$base\nMoo!") {
- my $name = "$first, $second";
- $name =~ s/\n/\\n/;
-
- my ($copy1, $copy2) = ($first, $second);
- $first =~ /(.+)/ or die $first;
- my $expect = "1${1}2";
- $second =~ /(.+)/ or die $second;
- $expect .= " 3${1}4";
-
- is swrite('1^*2 3^*4', $copy1, $copy2), $expect, $name;
+ foreach my $second ($base, "$base\n", "$base\nMoo!", "$base\nMoo!\n",
+ "$base\nMoo!\n",) {
+ foreach (['^*', qr/(.+)/], ['@*', qr/(.*?)$/s]) {
+ my ($format, $re) = @$_;
+ foreach my $class ('', 'Count') {
+ my $name = "$first, $second $format $class";
+ $name =~ s/\n/\\n/g;
+
+ $first =~ /(.+)/ or die $first;
+ my $expect = "1${1}2";
+ $second =~ $re or die $second;
+ $expect .= " 3${1}4";
+
+ if ($class) {
+ my $copy1 = $first;
+ my $copy2;
+ tie $copy2, $class, $second;
+ is swrite("1^*2 3${format}4", $copy1, $copy2), $expect, $name;
+ my $obj = tied $copy2;
+ is $obj->[1], 1, 'value read exactly once';
+ } else {
+ my ($copy1, $copy2) = ($first, $second);
+ is swrite("1^*2 3${format}4", $copy1, $copy2), $expect, $name;
+ }
+ }
+ }
}
}
}
}
+{
+ # 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 =
.
select $oldfh;
close STDOUT_DUP;
+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