perl5171delta: typo
perl5171delta: caller looks beyond cur stack
Teach dump.c about CVf_HASEVAL
[perl #113764] Make &= duping work with PerlIO::scalar

In trying to fix bug #112780, I made in-memory handle duplication tem-
porarily hide the underlying scalar so it wouldn’t be set to the empty
string (commit 49b69fb3a).

I used PerlIO_sv_dup in j rather than PerlIOScalar_arg.  The for-
mer is usually what is called anyway.  There is only one branch of
PerlIOScalar_arg that doesn’t call PerlIO_sv_dup.  I don’t remember
what I was thinking back then, but I think I thought that branch
was there for paranoia.  But actually, it is used for "&=", so this
started failing:

open FILE, '>', \my $content or die "Couldn't open scalar filehandle";
open my $fh, ">&=FILE" or die "Couldn't open: $!";
print $fh "Foo-Bar\n";
close $fh;
close FILE;
print $content;

This commit fixes the bug in the smallest way possible, which means
switching from PerlIO_sv_dup to PerlIOScalar_arg in PerlIOScalar_arg,
which, in turn, entails fiddling with RVs.
Increase $PerlIO::scalar::VERSION to 0.15
Convert lib/File/stat.t from a complex plan calculation to done_testing().

Also replace use_ok (not in BEGIN) with a simple require. If the require
fails it's not worth trying to test anything else, Test::More's END
handing will automatically report a test failure, so the failure will be
recorded.

Add an editor block.
Replace repetitive code in lib/File/stat.t with a data driven loop.
Bring the joy of strict (and warnings) to lib/File/stat.t
In lib/File/stat.t, test everything with and without use filetest "access".

Previously the use filetest "access" tests were separate, and didn't test
all the "should not warn" cases. By moving them into the main data-driven
loop it's trivial to test everything.

Also test that all the correct errors are seen on VMS, and not seen anywhere
else.
Remove needless skip tests from lib/File/stat.t

The stat builtin is always implemented, so no need for an eval {} test to
check for this. The presence or absence of <sys/stat.h> at the C level isn't
going to affect the outcome of this test.

Both have been in the test script since it was added (as t/lib/filestat.t)
by commit f7a45afb043dafc5 in May 2001. I suspect that both were copied
from one of the Net::* test scripts which was being used as the template.
Simplify lib/File/stat.t by using a tempfile as the test victim.

The previous code had got very gnarly trying to use a file from the
distribution for the test file, attempting to cope with
1) Other programs reading the file and hence the atime updating
2) The perl interpreter reading the file and hence the atime updating :-)
3) Building with -Dmksymlinks meaning that the file is a symlink

All these problems and work arounds simply *vanish* if we use a tempfile.
This will also enable us to change its mode in the future for better testing.
*Actually* test that bug 20011110.104 is fixed.

Bug ID 20011110.104 (RT #7896) was fixed by commit 2f173a711df6278f in Nov
2001, but the test that commit added never actually tested this.

The initial problem was that the new code, as written, used C<stat>,
intending that to call File::stat::stat(). However the refactoring of the
test script (all part of the same commit) from C<use File::stat;> to
C<use_ok( 'File::stat' );> (not in a BEGIN block) intentionally eliminated
the export of &File::stat::stat. This means that plain C<stat> is the
core builtin.

Fixing this as-is to File::stat::stat() won't help, as tests have
subsequently been added earlier in the script that trigger the autoloading
of Symbol by File::stat (commit 83716b1ec25b41f2 in Feb 2002). Moving the
tests earlier won't help now that the test uses File::Temp, as that uses
IO::Seekable which uses IO::Handle, which unconditionally loads Symbol.

The simplest solution seems to be to move the test to its own file.
Refactor lib/File/stat.t for robustness.

Use CORE::stat instead of stat, to be clear which is the builtin, and which
is the routine that File::stat is prepared to export. As it is now
unambiguous which is which, remove comments that annotated each use.

Use isa_ok() in place of ok() to test the return value of File::stat::stat.
Use is_deeply() in place of is() and arrays interpolated into strings.

Move the data driven loop that tests most of the -X operators into a
function test_X_ops(), and use this to test both the tempfile
(non-executable) and $^X (executable).

Put the first sanity test of File::stat::stat inside a block so that its
lexicals don't leak.
In lib/File/stat.t, permute the test file's mode for more thorough testing.

For each mode bit set, and all bits clear, test each filetest operator with
and without a File::stat object. Previously the only test was for the mode
the file was created with.
lib/File/stat.t should also test the -X operators on directories.
Test that File::stat exports stat by default, overriding the builtin.

Also, add a test that the array produced by File::stat::stat is identical to
the list produced by the builtin.
Fix File::stat's -x and -X for root for directories and executable files.

Previously File::stat's overloaded -x and -X operators did not give
the correct results for directories or executable files when running as
root. They had been treating executable permissions for root just like for
any other user, performing group membership tests etc. for files not owned
by root. They now follow the correct Unix behaviour - for a directory they
are always true, and for a file if any of the three execute permission bits
are set then they report that root can execute the file. Perl's builtin
-x and -X operators, added in Perl 2, have always been correct.
lib/File/stat.t shouldn't test -A $^X

Testing this fails intermittently on darwin, which has POSIXly-correct atime
semantics. When tests run in parallel, the atime of $^X will update whenever
another perl process starts, which is a race condition with this test.
Merge fix for File::stat's -x and -X for root, and test improvements.