Subject: | Breaks with deep Readonly data structures |
Test example:
------------------------------------
use 5.18.0;
use warnings;
use Test::More;
use Ref::Util 'is_hashref';
use Readonly;
# Read/write
{
my $rh1 = { a => 1 };
is ref($rh1), 'HASH', 'RW rh1 - old-school ref-eq';
ok is_hashref($rh1), 'RW rh1 - new-school Ref::Util::is_hashref';
my $rh2 = { a => { b => 2 } };
is ref($rh2), 'HASH', 'RW rh2 - old-school ref-eq';
ok is_hashref($rh2), 'RW rh2 - old-school Ref::Util::is_hashref';
is ref($rh2->{a}), 'HASH', 'RW rh2->{a} - old-school ref-eq';
ok is_hashref($rh2->{a}), 'RW rh2->{a} - old-school Ref::Util::is_hashref';
}
note "-" x 50;
# Readonly
{
Readonly::Scalar my $rh1 => { a => 1 };
is ref($rh1), 'HASH', 'RW rh1 - old-school ref-eq';
ok is_hashref($rh1), 'RW rh1 - new-school Ref::Util::is_hashref';
Readonly::Scalar my $rh2 => { a => { b => 2 } };
is ref($rh2), 'HASH', 'RW rh2 - old-school ref-eq';
ok is_hashref($rh2), 'RW rh2 - old-school Ref::Util::is_hashref';
is ref($rh2->{a}), 'HASH', 'RW rh2->{a} - old-school ref-eq';
ok is_hashref($rh2->{a}), 'RW rh2->{a} - old-school Ref::Util::is_hashref';
}
done_testing();
------------------------------------
alex@七番:~$ prove -v ref_util_readonly.t
ref_util_readonly.t ..
ok 1 - RW rh1 - old-school ref-eq
ok 2 - RW rh1 - new-school Ref::Util::is_hashref
ok 3 - RW rh2 - old-school ref-eq
ok 4 - RW rh2 - old-school Ref::Util::is_hashref
ok 5 - RW rh2->{a} - old-school ref-eq
ok 6 - RW rh2->{a} - old-school Ref::Util::is_hashref
# --------------------------------------------------
ok 7 - RW rh1 - old-school ref-eq
ok 8 - RW rh1 - new-school Ref::Util::is_hashref
ok 9 - RW rh2 - old-school ref-eq
ok 10 - RW rh2 - old-school Ref::Util::is_hashref
ok 11 - RW rh2->{a} - old-school ref-eq
not ok 12 - RW rh2->{a} - old-school Ref::Util::is_hashref
1..12
# Failed test 'RW rh2->{a} - old-school Ref::Util::is_hashref'
# at ref_util_readonly.t line 34.
# Looks like you failed 1 test of 12.
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/12 subtests
Test Summary Report
-------------------
ref_util_readonly.t (Wstat: 256 Tests: 12 Failed: 1)
Failed test: 12
Non-zero exit status: 1
Files=1, Tests=12, 0 wallclock secs ( 0.03 usr 0.01 sys + 0.02 cusr 0.00 csys = 0.06 CPU)
Result: FAIL
------------------------------------