Test::More has is_deeply()
and mentions in the documentation that it should be used instead of eq_array()
or eq_hash()
because it has better diagnostics, and it states ...They may be deprecated in future versions
Now I'm replacing the use of eq_...()
functions for is_deeply()
but I run into a problem, there is no is_not_deeply()
or such function, and I have a test like this:
ok (!eq_hash(\%h1, \%h2));
Is there an idiomatic alternative I can use to test deep inequality, preferably using Test::More?
Unlike eq_hash()
, which just returns true or false and needs to be wrapped in ok()
, is_deeply()
itself is a test. So if you wrap it in "ok()" like below:
ok(!is_deeply(\%h1, \%h2));
There are now TWO tests, is_deeply()
which is failing and ok()
, which would pass!
CodePudding user response:
It seems like this feature is not readily available with Test::More
. Then I would recommend using Test2
instead:
use strict;
use warnings;
use Test2::V0;
my %h1 = (a => [1,2,3], b=>"x");
my %h2 = (a => [1,2,3], b=>"x");
isnt (\%h1, \%h2, "Hashes are not equal" );
done_testing;