diff options
author | franck cuny <franck@lumberjaph.net> | 2010-08-11 11:12:49 +0200 |
---|---|---|
committer | franck cuny <franck@lumberjaph.net> | 2010-08-11 11:12:49 +0200 |
commit | 0d4d7d0d13bb122af3744bc5a61775c1bc8a978b (patch) | |
tree | f451db1848c10c456c78e080c187343aa12e89b0 | |
parent | initial commit (diff) | |
download | moosex-abstractfactory-0d4d7d0d13bb122af3744bc5a61775c1bc8a978b.tar.gz |
use Class::MOP::load_class instead of plain eval - if the module is not found, die with message (close RT#59776) master
Diffstat (limited to '')
-rw-r--r-- | lib/MooseX/AbstractFactory/Role.pm | 2 | ||||
-rw-r--r-- | t/06_die_with_inexistant_class.t | 18 |
2 files changed, 19 insertions, 1 deletions
diff --git a/lib/MooseX/AbstractFactory/Role.pm b/lib/MooseX/AbstractFactory/Role.pm index d560ca9..3b27f60 100644 --- a/lib/MooseX/AbstractFactory/Role.pm +++ b/lib/MooseX/AbstractFactory/Role.pm @@ -22,7 +22,7 @@ sub create { # pull in our implementation class $factory->_validate_implementation_class($iclass); - eval "use $iclass"; + Class::MOP::load_class($iclass); my $options = $factory->_options(); diff --git a/t/06_die_with_inexistant_class.t b/t/06_die_with_inexistant_class.t new file mode 100644 index 0000000..fcf600b --- /dev/null +++ b/t/06_die_with_inexistant_class.t @@ -0,0 +1,18 @@ +use strict; +use warnings; +use Test::More tests => 2; +use Test::Exception; + +BEGIN { + package My::Factory; + use MooseX::AbstractFactory; + use Moose; +} + +dies_ok { + my $imp = My::Factory->create( + 'FooBar', {} + ); +} "Factory->new() die"; + +like $@, qr/Can't locate My\/Factory\/FooBar.pm/; |