Skip to content

Commit

Permalink
more Mojo::Loader tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jun 16, 2015
1 parent 7ddfa5c commit 7abe608
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Mojo/Loader.pm
Expand Up @@ -37,7 +37,7 @@ sub find_modules {
sub find_packages {
my $ns = shift;
no strict 'refs';
return sort map { $_ =~ /^(.+)::$/ ? ("${ns}::$1") : () } keys %{"${ns}::"};
return sort map { /^(.+)::$/ ? "${ns}::$1" : () } keys %{"${ns}::"};
}

sub load_class {
Expand Down
3 changes: 3 additions & 0 deletions t/mojo/loader.t
Expand Up @@ -64,11 +64,14 @@ is_deeply \@modules,
is_deeply [find_modules "Mojo'LoaderTest"],
[qw(Mojo'LoaderTest::A Mojo'LoaderTest::B Mojo'LoaderTest::C)],
'found the right modules';
is_deeply [find_modules 'MyLoaderTest::DoesNotExist'], [], 'no modules found';

# Search packages
my @pkgs = find_packages 'MyLoaderTest::Foo';
is_deeply \@pkgs, ['MyLoaderTest::Foo::Bar', 'MyLoaderTest::Foo::Baz'],
'found the right packages';
is_deeply [find_packages 'MyLoaderTest::DoesNotExist'], [],
'no packages found';

# Load
ok !load_class("Mojo'LoaderTest::A"), 'loaded successfully';
Expand Down

0 comments on commit 7abe608

Please sign in to comment.