Subject: | Selftest-failure: "equality" for coordinate-matrix comparisons |
Date: | Mon, 09 Jan 2012 17:56:56 -0500 |
To: | bug-Chemistry-File-InternalCoords [...] rt.cpan.org |
From: | "Daniel Macks" <dmacks [...] netspace.org> |
CPAN Testers Reports has several reports of failure when Chemistry::File::InternalCoords 0.03 does comparisons of Math::VectorReal and Chemistry::File::InternalCoords->coords (which is a Math::VectorReal) matrices. For example:
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
# Testing Chemistry::File::InternalCoords 0.03, Perl 5.008006, /usr/bin/perl
t/00-load.t ....... ok
t/boilerplate.t ... ok
# Failed test 'H1: coords'
# at t/hydrogen.t line 36.
# An error occurred while using eq:
# ------------------------------------
# Operation `eq': no method found,
# left argument in overloaded package Math::VectorReal,
# right argument in overloaded package Math::VectorReal at (eval in cmp_ok) t/hydrogen.t line 36.
#
# ------------------------------------
# got: '[ 0.000000000000E+00 0.000000000000E+00 0.000000000000E+00 ]
# '
# expected: '[ 0.000000000000E+00 0.000000000000E+00 0.000000000000E+00 ]
# '
t/hydrogen.t line 36 is:
is($atom->coords, Math::VectorReal->new(0,0,0), "H1: coords");
and the failure is because that is() is doing 'eq' comparison of objects that do not have a comparison operator defined (at least as of Math::VectorReal 1.02). A simple solution for the test failure is to stringify the matrices before comparing them:
is($atom->coords->stringify, Math::VectorReal->new(0,0,0)->stringify, "H1: coords");
I'll also file this as a bug^Wmissing feature in Math::VectorReal, so maybe the solution here will really be a versioned dependency on a new release of that.
dan
--
Daniel Macks
dmacks@netspace.org