Subject: | Changing "package Foo" to "package Foo::Bar" makes extend.t fail |
Test::MockObject::Extends::check_class_loaded has a typo which means
that it reports false for any module that doesn't have a .pm file,
EXCEPT if the module is a root namespace.
To update the tests to check for this, in extends.t change "package Foo"
at the bottom (and all related uses) to "package Foo::Bar"
The actual line that is the problem is
Test::MockObject::Extends::check_class_loaded(/usr/local/share/perl/5.8.4/Test/MockObject/Extends.pm:42):
42: $symbol = $symtable->{ $symbol . '::' };
Which should actually be...
42: $symtable = $symtable->{ $symbol . '::' };
On a more general note, it may well not be a great idea to re-implement
this function yourself. Something like Class::Inspector->loaded is
likely to be much more thoroughly tested and deal with edge cases than
the hand-rolled one (and probably be faster).
It could well be an unnecesary dependency (although it's pretty common
now, and you have a number of other dependencies already).
At the very least, steal the Class::Inspector->loaded implementation and
consider using that, OR steal the section of the test suite for
Class::Inspector->loaded and make sure that your implementation passes
all the same tests.
If you find something that C:I->loaded does wrong, let me know and I'll
add support for whatever you think is missing.
But "is a class loaded" is a somewhat non-trivial question, so it would
be good to have a very well tested implementation.