package if;
-$VERSION = '0.0604';
+$VERSION = '0.0605';
sub work {
my $method = shift() ? 'import' : 'unimport';
- die "Too few arguments to 'use if' (some code returning an empty list in list context?)"
- unless @_ >= 2;
+ unless (@_ >= 2) {
+ my $type = ($method eq 'import') ? 'use' : 'no';
+ die "Too few arguments to '$type if' (some code returning an empty list in list context?)"
+ }
return unless shift; # CONDITION
my $p = $_[0]; # PACKAGE
Ilya Zakharevich L<mailto:ilyaz@cpan.org>.
=cut
-
#!./perl
use strict;
-use Test::More tests => 6;
+use Test::More tests => 10;
my $v_plus = $] + 1;
my $v_minus = $] - 1;
# Use 'open' =>, since pre-5.6.0 could interpret differently
is( (eval "use if ($v_plus > \$]), 'open' => IN => ':crlf'; 12" || 0), 12,
'"use if" with open');
+
+is(eval "use if ($v_plus > \$])", undef,
+ "Too few args to 'use if' returns <undef>");
+like($@, qr/Too few arguments to 'use if'/, " ... and returns correct error");
+
+is(eval "no if ($v_plus > \$])", undef,
+ "Too few args to 'no if' returns <undef>");
+like($@, qr/Too few arguments to 'no if'/, " ... and returns correct error");