Skip to content

Commit

Permalink
added a few more loader tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 5, 2011
1 parent 8da8921 commit efe9ff9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/Mojo/Loader.pm
Expand Up @@ -15,7 +15,7 @@ sub load {
my ($self, $module) = @_;

# Check module name
return 1 if !$module || $module !~ /^[\w\:\']+$/;
return 1 if !$module || $module !~ /^\w[\w\:\']+\w$/;

# Already loaded
return if $module->can('new');
Expand Down
17 changes: 10 additions & 7 deletions t/mojo/loader.t
@@ -1,7 +1,7 @@
#!/usr/bin/env perl
use Mojo::Base -strict;

use Test::More tests => 41;
use Test::More tests => 44;

use FindBin;
use lib "$FindBin::Bin/lib";
Expand Down Expand Up @@ -67,11 +67,14 @@ ok !!LoaderTest::B->can('new'), 'loaded successfully';
ok !!LoaderTest::C->can('new'), 'loaded successfully';

# Class does not exist
ok !!$loader->load('LoaderTest'), 'nothing to load';
is $loader->load('LoaderTest'), 1, 'nothing to load';

# Invalid class
ok !!$loader->load('Mojolicious/Lite'), 'nothing to load';
ok !!$loader->load('Mojolicious/Lite.pm'), 'nothing to load';
ok !!$loader->load('Mojolicious\Lite'), 'nothing to load';
ok !!$loader->load('Mojolicious\Lite.pm'), 'nothing to load';
ok !$loader->load('Mojolicious::Lite'), 'loaded successfully';
is $loader->load('Mojolicious/Lite'), 1, 'nothing to load';
is $loader->load('Mojolicious/Lite.pm'), 1, 'nothing to load';
is $loader->load('Mojolicious\Lite'), 1, 'nothing to load';
is $loader->load('Mojolicious\Lite.pm'), 1, 'nothing to load';
is $loader->load('::Mojolicious::Lite'), 1, 'nothing to load';
is $loader->load('Mojolicious::Lite::'), 1, 'nothing to load';
is $loader->load('::Mojolicious::Lite::'), 1, 'nothing to load';
is $loader->load('Mojolicious::Lite'), undef, 'loaded successfully';

0 comments on commit efe9ff9

Please sign in to comment.