$JSON_Class is not JSON::XS if version < 3.0
[p5sagit/JSON-MaybeXS.git] / t / xs.t
diff --git a/t/xs.t b/t/xs.t
index 1fa4fa9..f768a3b 100644 (file)
--- a/t/xs.t
+++ b/t/xs.t
@@ -3,17 +3,14 @@ use warnings;
 
 # hide Cpanel::JSON::XS
 use lib map {
-    my ( $m, $c ) = ( $_, qq{die "Can't locate $_ (hidden)\n"} );
-    sub { return unless $_[1] eq $m; open my $fh, "<", \$c; return $fh }
+    my $m = $_;
+    sub { return unless $_[1] eq $m; die "Can't locate $m in \@INC (hidden).\n" };
 } qw{Cpanel/JSON/XS.pm};
 
 use Test::More 0.88;
 use JSON::MaybeXS;
 
-unless ( eval { require JSON::XS; 1 } ) {
-    plan skip_all => 'No JSON::XS';
-}
-
+use Test::Needs { 'JSON::XS' => '3.0' };  # load first, before JSON::MaybeXS
 diag 'Using JSON::XS ', JSON::XS->VERSION;
 
 is( JSON, 'JSON::XS', 'Correct JSON class' );