$| = 1;
-use Test::More tests => 76;
+use Test::More tests => 79;
my $fh;
my $var = "aaa\n";
pass 'seeking on a glob copy from the end';
}
+# [perl #108398]
sub has_trailing_nul(\$) {
my ($ref) = @_;
my $sv = B::svref_2object($ref);
my $trailing = unpack 'P', pack 'J', $pv_addr+$cur;
return $trailing eq "\0";
}
+SKIP: {
+ if ($Config::Config{'extensions'} !~ m!\bPerlIO/scalar\b!) {
+ skip "no B", 1;
+ }
+ require B;
+
+ open my $fh, ">", \my $memfile or die $!;
+
+ print $fh "abc";
+ ok has_trailing_nul $memfile,
+ 'write appends trailing null when growing string';
+
+ seek $fh, 0,SEEK_SET;
+ print $fh "abc";
+ ok has_trailing_nul $memfile,
+ 'write appends trailing null when not growing string';
+
+ seek $fh, 200, SEEK_SET;
+ print $fh "abc";
+ ok has_trailing_nul $memfile,
+ 'write appends null when growing string after seek past end';
+}