Subject: | Comparisons with sets of multiple all() or any() structures fails |
Comparison with sets (set,bag,subbagof,superbagof,...) of multiple all()
or any() structures fails. For example the following tests
cmp_deeply([], set(all(1),all(2)))
cmp_deeply([], bag(all(1),all(2)))
cmp_deeply([], set(any(1),any(2)))
cmp_deeply([], bag(any(1),any(2)))
all die with the following message
Operation "cmp": no method found,
left argument in overloaded package Test::Deep::All,
right argument in overloaded package Test::Deep::All
at /usr/share/perl5/Test/Deep/Set.pm line 151.
Tested with Test-Deep-0.100, perl 5.8.8 on Linux 2.6.24.
The problem is that the operator '&' is overloaded in Test::Deep::All
and Test::Deep::Any, but without setting fallback. Even though these are
subclasses of Test::Deep::Cmp (where fallback is set), the fallback
option is *not* inherited, as discussed in
http://search.cpan.org/~rgarcia/perl-5.10./lib/overload.pm#Inheritance_and_overloading
As a result, the 'cmp' operator is not available for Test::Deep::All/Any
objects causing the error above.
A simple fix is to use "fallback => 1" in these classes and the examples
above work fine (it shouldn't break anything but I didn't check thoroughly).