diff options
author | Michiel Beijen <mb@x14.nl> | 2021-12-18 12:10:15 +0100 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2021-12-24 08:26:21 -0700 |
commit | b135e9358aa994456ec32ccfe7a73e685f598797 (patch) | |
tree | 433ea3124e6f7a8e1f4363ee0c29161ee332d6d6 /lib/DB.t | |
parent | ea5f65263ad54bd59f582eb38161753c2546d6b3 (diff) | |
download | perl-b135e9358aa994456ec32ccfe7a73e685f598797.tar.gz |
use is_deeply instead of eq_ Test::More functions
the eq_set, eq_hash, and eq_array functions in Test::More are
discouraged to use, and is_deeply is recommended. Ref:
https://metacpan.org/pod/Test::More#Discouraged-comparison-functions
The reason for this is that, if the tests fail, is_deeply has much
better diagnostics.
The other thing is that is_deeply is a test function directly, where
eq_hash and such need to be wrapped inside ok(). This is easy to forget
-- proof of this is in Benchmark.t, where we had this code, that did not
test anything:
eq_set([keys %$got], [qw(Foo Bar Baz)], 'should be exactly three objects');
It is now replaced by:
is_deeply([sort keys %$got], [sort qw(Foo Bar Baz)], 'should be exactly three objects');
this commit replaces all usage of eq_set, eq_hash, and eq_array in lib/
and ext/ for tests that use Test::More.
One small exception is where a negated test is used; Test::More does not
have is_not_deeply() or such. Test2 has `isnt()` for this, but that is
not in core. In those cases, we still keep using the eq_ operators.
Diffstat (limited to 'lib/DB.t')
-rw-r--r-- | lib/DB.t | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -171,7 +171,7 @@ sub three { two(@_) } my @subs = DB->subs( 'foo', 'boo', 'bar' ); is( scalar @subs, 2, '... should report only for requested subs' ); my @expected = ( [ 'foo', 23, 45 ], [ 'ba:r', 7, 890 ] ); - ok( eq_array( \@subs, \@expected ), '... find file, start, end for subs' ); + is_deeply( \@subs, \@expected, '... find file, start, end for subs' ); } # test DB::filesubs() |