summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorZefram <zefram@fysh.org>2010-05-20 21:48:03 +0100
committerDavid Golden <dagolden@cpan.org>2010-05-20 18:56:11 -0400
commit36f77d7116441b32ff6c10307a116e105b7eabb4 (patch)
treeafd7518b5a5cd4b5103cd2805a5cf66a1f80f98c /t
parent3afb2f14ba09da7b54ce62a6f12d9703a7776666 (diff)
downloadperl-36f77d7116441b32ff6c10307a116e105b7eabb4.tar.gz
fully test package-version-block syntax
Extend the exhaustive package-version tests in t/op/packagev.t to test each case using package-block syntax in addition to the package-declaration syntax.
Diffstat (limited to 't')
-rw-r--r--t/op/packagev.t35
1 files changed, 21 insertions, 14 deletions
diff --git a/t/op/packagev.t b/t/op/packagev.t
index 8e8f19f9b3..f4e094c27e 100644
--- a/t/op/packagev.t
+++ b/t/op/packagev.t
@@ -17,8 +17,8 @@ my @syntax_cases = (
my @version_cases = <DATA>;
-plan tests => 5 * @syntax_cases + 5 * (grep { $_ !~ /^#/ } @version_cases)
- + 3;
+plan tests => 7 * @syntax_cases + 7 * (grep { $_ !~ /^#/ } @version_cases)
+ + 2 * 3;
use warnings qw/syntax/;
use version;
@@ -34,6 +34,10 @@ for my $string ( @syntax_cases ) {
is( $@, '', qq/eval "{$string}"/ );
eval "{ $string }";
is( $@, '', qq/eval "{ $string }"/ );
+ eval "${string}{}";
+ is( $@, '', qq/eval "${string}{}"/ );
+ eval "$string {}";
+ is( $@, '', qq/eval "$string {}"/ );
}
LINE:
@@ -52,20 +56,21 @@ for my $line (@version_cases) {
$match =~ s/\s*\z//; # kill trailing spaces
# First handle the 'package NAME VERSION' case
- $withversion::VERSION = undef;
- if ($package eq 'fail') {
- eval "package withversion $v";
- like($@, qr/$match/, "package withversion $v -> syntax error ($match)");
- ok(! version::is_strict($v), qq{... and "$v" should also fail STRICT regex});
- }
- else {
- my $ok = eval "package withversion $v; $v eq \$withversion::VERSION";
- ok($ok, "package withversion $v")
- or diag( $@ ? $@ : "and \$VERSION = $withversion::VERSION");
- ok( version::is_strict($v), qq{... and "$v" should pass STRICT regex});
+ foreach my $suffix (";", "{}") {
+ $withversion::VERSION = undef;
+ if ($package eq 'fail') {
+ eval "package withversion $v$suffix";
+ like($@, qr/$match/, "package withversion $v$suffix -> syntax error ($match)");
+ ok(! version::is_strict($v), qq{... and "$v" should also fail STRICT regex});
+ }
+ else {
+ my $ok = eval "package withversion $v$suffix $v eq \$withversion::VERSION";
+ ok($ok, "package withversion $v$suffix")
+ or diag( $@ ? $@ : "and \$VERSION = $withversion::VERSION");
+ ok( version::is_strict($v), qq{... and "$v" should pass STRICT regex});
+ }
}
-
# Now check the version->new("V") case
my $ver = undef;
eval qq/\$ver = version->new("$v")/;
@@ -105,6 +110,8 @@ for my $line (@version_cases) {
for my $v ("1", "1.23", "v1.2.3") {
ok (run_perl (prog => "package Foo\n$v; print 1;"),
"New line between package name and version");
+ ok (run_perl (prog => "package Foo\n$v { print 1; }"),
+ "New line between package name and version");
}
# The data is organized in tab delimited format with these columns: