Skip to content
Browse files

Standardize the tests' Mouse/Moose loading eval/skip code

  • Loading branch information...
1 parent adef406 commit 3e6fe3f466a49f92998129437a818e70225327f6 @sartak committed
View
4 t/000-version.t
@@ -12,10 +12,10 @@ show_version($_) for qw/
sub show_version {
my $klass = shift;
- if (eval "require $klass; 1;") {
+ if (eval "use $klass (); 1") {
no strict 'refs';
diag "$klass: " . ${"${klass}::VERSION"};
} else {
- diag "$klass not found";
+ diag "$klass unavailable: $@";
}
}
View
4 t/001-basic-moose.t
@@ -6,8 +6,8 @@ use Test::More;
BEGIN { delete $ENV{ANY_MOOSE} }
BEGIN {
- eval 'require Moose';
- plan skip_all => 'Moose not available' if $@;
+ eval 'use Moose ()';
+ plan skip_all => "Moose unavailable: $@" if $@;
plan tests => 9;
}
View
9 t/001-basic-mouse.t
@@ -6,8 +6,8 @@ use Test::More;
BEGIN { delete $ENV{ANY_MOOSE} }
BEGIN {
- eval 'require Mouse';
- plan skip_all => 'Mouse not available' if $@;
+ eval 'use Mouse ()';
+ plan skip_all => "Mouse unavailable: $@" if $@;
plan tests => 9;
}
@@ -29,9 +29,8 @@ do {
ok(!Moused::Any::Moose->can('has'), "has was unimported");
SKIP: {
- my $loaded_moose;
- BEGIN { $loaded_moose = eval 'require Moose' }
- skip "Moose required for these tests to be useful" => 3 unless $loaded_moose;
+ eval 'use Moose ()';
+ skip "Moose unavailable: $@" => 3 if $@;
do {
package After::Moose;
View
4 t/002-other-modules-moose.t
@@ -6,8 +6,8 @@ use Test::More;
BEGIN { delete $ENV{ANY_MOOSE} }
BEGIN {
- eval 'require Moose';
- plan skip_all => 'Moose not available' if $@;
+ eval 'use Moose ()';
+ plan skip_all => "Moose unavailable: $@" if $@;
plan tests => 2;
}
View
9 t/002-other-modules-mouse.t
@@ -6,8 +6,8 @@ use Test::More;
BEGIN { delete $ENV{ANY_MOOSE} }
BEGIN {
- eval 'require Mouse';
- plan skip_all => 'Mouse not available' if $@;
+ eval 'use Mouse ()';
+ plan skip_all => "Mouse unavailable: $@" if $@;
plan tests => 2;
}
@@ -21,9 +21,8 @@ do {
};
SKIP: {
- my $loaded_moose;
- BEGIN { $loaded_moose = eval 'require Moose' }
- skip "Moose required for these tests to be useful" => 1 unless $loaded_moose;
+ eval 'use Moose ()';
+ skip "Moose unavailable: $@" => 1 if $@;
do {
package After::Moose;
View
8 t/003-is_moose_loaded.t
@@ -6,8 +6,8 @@ use Test::More;
BEGIN { delete $ENV{ANY_MOOSE} }
BEGIN {
- eval 'require Mouse';
- plan skip_all => 'Mouse not available' if $@;
+ eval 'use Mouse ()';
+ plan skip_all => "Mouse unavailable: $@" if $@;
plan tests => 3;
}
@@ -21,8 +21,8 @@ BEGIN {
package Foo;
BEGIN {
SKIP: {
- eval 'use Moose';
- ::skip 'Moose not installed', 1 if $@;
+ eval 'use Moose ()';
+ ::skip "Moose unavailable: $@", 1 if $@;
::ok(Any::Moose::_is_moose_loaded(), '... Moose is loaded');
}
View
7 t/004-x-modules-moose.t
@@ -6,8 +6,11 @@ use Test::More;
BEGIN { delete $ENV{ANY_MOOSE} }
BEGIN {
- eval 'require Moose; require MooseX::Types';
- plan skip_all => 'Moose or MooseX::Types not available' if $@;
+ eval 'use Moose ()';
+ plan skip_all => "Moose unavailable: $@" if $@;
+ eval 'use MooseX::Types ()';
+ plan skip_all => "Moose::Types unavailable: $@" if $@;
+
plan tests => 2;
}
View
13 t/004-x-modules-mouse.t
@@ -6,7 +6,11 @@ use Test::More;
BEGIN { delete $ENV{ANY_MOOSE} }
BEGIN {
- plan skip_all => 'Mouse or MouseX::Types 0.03 not available' unless eval "require Mouse; require MouseX::Types 0.03;";
+ eval 'use Mouse ()';
+ plan skip_all => "Mouse unavailable: $@" if $@;
+ eval 'use MouseX::Types 0.03';
+ plan skip_all => "Mouse::Types 0.03 unavailable: $@" if $@;
+
plan tests => 2;
}
@@ -19,9 +23,10 @@ do {
};
SKIP: {
- my $loaded_moose;
- BEGIN { $loaded_moose = eval 'require Moose; require MooseX::Types' }
- skip "Moose and MooseX::Types required for these tests to be useful" => 1 unless $loaded_moose;
+ eval 'use Moose ()';
+ skip "Moose unavailable: $@" => 1 if $@;
+ eval 'use MooseX::Types ()';
+ skip "MooseX::Types unavailable: $@" => 1 if $@;
do {
package After::Moose;
View
4 t/005-aliases-moose.t
@@ -6,8 +6,8 @@ use Test::More;
BEGIN { delete $ENV{ANY_MOOSE} }
BEGIN {
- eval 'require Moose;';
- plan skip_all => 'Moose not available' if $@;
+ eval 'use Moose ()';
+ plan skip_all => "Moose unavailable: $@" if $@;
plan tests => 21;
}
View
4 t/005-aliases-mouse.t
@@ -6,8 +6,8 @@ use Test::More;
BEGIN { delete $ENV{ANY_MOOSE} }
BEGIN {
- eval 'require Mouse;';
- plan skip_all => 'Mouse not available' if $@;
+ eval 'use Mouse ()';
+ plan skip_all => "Mouse unavailable: $@" if $@;
plan tests => 21;
}
View
4 t/010-use_mouse_roles.t
@@ -6,8 +6,8 @@ use Test::More;
BEGIN { delete $ENV{ANY_MOOSE} }
BEGIN {
- eval 'require Mouse';
- plan skip_all => 'Mouse not available' if $@;
+ eval 'use Mouse ()';
+ plan skip_all => "Mouse unavailable: $@" if $@;
plan tests => 1;
}
View
4 t/011-use_moose_roles.t
@@ -6,8 +6,8 @@ use Test::More;
BEGIN { delete $ENV{ANY_MOOSE} }
BEGIN {
- eval 'require Moose';
- plan skip_all => 'Moose not available' if $@;
+ eval 'use Moose ()';
+ plan skip_all => "Moose unavailable: $@" if $@;
plan tests => 1;
}
View
4 t/012-use_moose_util.t
@@ -6,8 +6,8 @@ use Test::More;
BEGIN { delete $ENV{ANY_MOOSE} }
BEGIN {
- eval 'require Moose';
- plan skip_all => 'Moose not available' if $@;
+ eval 'use Moose ()';
+ plan skip_all => "Moose unavailable: $@" if $@;
plan tests => 2;
}
View
4 t/012-use_mouse_util.t
@@ -6,8 +6,8 @@ use Test::More;
BEGIN { delete $ENV{ANY_MOOSE} }
BEGIN {
- eval 'require Mouse';
- plan skip_all => 'Mouse not available' if $@;
+ eval 'use Mouse ()';
+ plan skip_all => "Mouse unavailable: $@" if $@;
plan tests => 2;
}

0 comments on commit 3e6fe3f

Please sign in to comment.
Something went wrong with that request. Please try again.