Various is_class_loaded/load_class nits
[gitmo/Mouse.git] / t / 020-load-class.t
CommitLineData
c3398f5b 1#!/usr/bin/env perl
2use strict;
3use warnings;
262801ef 4use Test::More tests => 11;
c3398f5b 5use Test::Exception;
6
7require Mouse;
8use lib 't/lib';
9
262801ef 10for my $method ('load_class', 'is_class_loaded') {
11 my $code = Mouse->can($method);
12 ok(!$code->(), "$method with no argument returns false");
13 ok(!$code->(''), "can't load the empty class");
14 ok(!$code->(\"foo"), "can't load a class name reference??");
15}
16
c3398f5b 17ok(Mouse::load_class('Anti::Mouse'));
18can_ok('Anti::Mouse' => 'antimouse');
19
20do {
21 package Class;
2a674d23 22 sub yay {}
c3398f5b 23};
24
25ok(Mouse::load_class('Class'), "this should not die!");
26
2a674d23 27throws_ok {
28 Mouse::load_class('FakeClassOhNo');
29} qr/Can't locate /;
c3398f5b 30
31throws_ok {
32 Mouse::load_class('Anti::MouseError');
33} qr/Missing right curly/;
34