* mop.c
- Applied an MS VC++ compilation fix from Taro Nishino. RT #48072
+ * Class::MOP
+ - The load_class function no longer returns a value, since it's return
+ value was confusing (either a metaclass object or a class name). It
+ either loads a class or dies trying. Addresses RT #45883. (Dave
+ Rolsky)
+
0.92_01 Thu, Sep 10, 2009
* Class::MOP::Package
- Backwards compatibility tweaks to XS for 5.8.1. (Goro Fuji)
}
sub load_class {
- my $class = load_first_existing_class($_[0]);
- return get_metaclass_by_name($class) || $class;
+ load_first_existing_class($_[0]);
+
+ return;
}
sub _is_valid_class_name {
This will load the specified C<$class_name>, if it is not already
loaded (as reported by C<is_class_loaded>). This function can be used
in place of tricks like C<eval "use $module"> or using C<require>
-unconditionally. This will return the metaclass of C<$class_name> if
-one exists, otherwise it will return C<$class_name>.
+unconditionally.
=item B<Class::MOP::is_class_loaded($class_name)>
use strict;
use warnings;
-use Test::More tests => 36;
+use Test::More tests => 32;
use Test::Exception;
require Class::MOP;
Class::MOP::load_class('__PACKAGE__')
} qr/__PACKAGE__\.pm.*\@INC/, 'errors sanely on __PACKAGE__.pm';
-my $meta = Class::MOP::load_class('BinaryTree');
-ok($meta, "successfully loaded the class BinaryTree");
-is($meta->name, "BinaryTree", "load_class returns the metaclass");
+Class::MOP::load_class('BinaryTree');
can_ok('BinaryTree' => 'traverse');
do {
};
-my $ret = Class::MOP::load_class('Class');
-ok($ret, "this should not die!");
-is( $ret, "Class", "class name returned" );
+{
+ local $@;
+ eval { Class::MOP::load_class('Class') };
+ ok( ! $@, 'load_class never dies' );
+}
ok( !Class::MOP::does_metaclass_exist("Class"), "no metaclass for non MOP class" );
use metaclass;
}
-isa_ok( Class::MOP::load_class("Lala"), "Class::MOP::Class", "when an object has a metaclass it is returned" );
-
lives_ok {
is(Class::MOP::load_first_existing_class("Lala", "Does::Not::Exist"), "Lala", 'load_first_existing_class 1/2 params ok, class name returned');
is(Class::MOP::load_first_existing_class("Does::Not::Exist", "Lala"), "Lala", 'load_first_existing_class 2/2 params ok, class name returned');