LanX has asked for the wisdom of the Perl Monks concerning the following question:
I have a deeply nested data-structure supposed to return contain scalar refs.
But is_deeply() digs into the refs and compares the scalar values.
I can understand why array- and hash-refs are dereferenced ...
Any elegant way to solve this? I also tried Test::Deep::cmp_deeply() but no success
will try Test::Differences now ...
use strict; use warnings; use Data::Dump qw/pp dd/; use Test::More; use Test::Deep; my ($pos1,$pos2)=("a","a"); diag \$pos1,", ",\$pos2; diag 0+\$pos1,", ",0+\$pos2; diag pp \$pos1,\$pos2; is_deeply( \$pos1, \$pos2,"is_deeply"); #should fail cmp_deeply( \$pos1, \$pos2,"cmp_deeply"); #should fail done_testing;
C:/Perl_524/bin\perl.exe -w d:/exp/pm_is_deeply.pl ok 1 - is_deeply ok 2 - cmp_deeply # SCALAR(0xd286e8), SCALAR(0xd28d48) # 13797096, 13798728 # (\"a", \"a") 1..2
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Test scalar refs (not values) in deeply nested structure
by Corion (Patriarch) on Jul 23, 2020 at 19:50 UTC | |
by LanX (Saint) on Jul 23, 2020 at 19:58 UTC | |
by Corion (Patriarch) on Jul 23, 2020 at 20:21 UTC | |
by LanX (Saint) on Jul 23, 2020 at 20:31 UTC | |
|
Re: Test scalar refs (not values) in deeply nested structure
by syphilis (Archbishop) on Jul 24, 2020 at 03:51 UTC | |
by perlfan (Parson) on Jul 24, 2020 at 04:46 UTC | |
by LanX (Saint) on Jul 24, 2020 at 06:23 UTC | |
|
Re: Test scalar refs (not values) in deeply nested structure (workaround)
by LanX (Saint) on Jul 23, 2020 at 20:29 UTC |