Subject: | Test::Deep doesn't export some documented functions |
Test::Deep doesn't seem to be handling its exports very well. The script
below shows a basic example:
-----------------------------------------------
#!/usr/bin/perl -w
use strict;
use Test::Deep;
my $got = 'Hello';
my $expected = 'World';
# this works
unless(eq_deeply($got, $expected)) {
print "this works fine!\n---\n";
}
# this doesn't work
print "found an error!\n";
my ($ok, $stack) = cmp_details($got, $expected);
unless ($ok) {
print deep_diag($stack);
}
-----------------------------------------------
Running the script gives the following:
[mauricio@hardrock] ~ % perl test.pl
this works fine!
---
found an error!
Undefined subroutine &main::cmp_details called at test.pl line 19.
Manually importing the desired functions seem to do the trick:
-use Test::Deep;
+use Test::Deep qw(cmp_details deep_diag eq_deeply);
-----------------------------------------------
[mauricio@hardrock] ~ % perl test.pl
this works fine!
---
found an error!
Compared $data
got : 'Hello'
expect : 'World'
-----------------------------------------------
I originally found this while creating my own test class with
Test::Deep::NoTest, which experiences the same error (as it imports
Test::Deep under the hood).
Hope this was clear enough.
Regards,
Mauricio.