Aloha,
it looks like Test::More 0.61 broke Glib's test suite again, so I'm
beginning to wonder if we're doing something stupid. Hence the
question: How do you properly test an object's overloaded array
dereference operator @{}?
When we initially wrote the tests, we simply used is_deeply() or
eq(eq_array()), but that stopped working at some point -- I think it was
Test::More 0.60. We then switched to using just is() on the references
which seemed to work for both old and new versions of Test::More (tested
with 0.45 and 0.60). But now there's 0.61 and we fail again.
Concrete details:
We have a package called Glib::Flags which overloads multiple operators,
among them @{}. Now a method called, say, $obj->get returns such an
object. In the beginning we used to test this like so:
is_deeply ($obj->get ('some_flags'), ['value-one', 'value-two']);
With Test::More 0.60 (or a release in its vicinity), this broke and we
got failures like this one:
# Structures begin differing at:
# $got = '[ value-one value-two ]'
# $expected = ARRAY(0x9bfbd94)
Apparently, the stringification operator was called. After some
experimentation, it turned out that is() does exactly what we needed:
is ($obj->get ('some_flags'), ['value-one', 'value-two']);
It even failed if you changed one of the values or added or removed
values! Perfect. Enter Test::More 0.61:
# got: '[ value-one value-two ]'
# expected: 'ARRAY(0x82a8208)'
Stringification again. Changing the tests back to using is_deeply()
doesn't change a thing; same failure. That's where I give up. Where's
the mistake?
In case you need it, here's the complete test:
http://cvs.sourceforge.net/viewcvs.py/gtk2-perl/gtk2-perl-xs/Glib/t/c.t?view=markup
--
Thanks,
-Torsten