This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
mktables: Add notes about new access to properties
[perl5.git] / lib / version.t
index 0fb96bb..dd47e87 100644 (file)
@@ -1,8 +1,4 @@
 #! /usr/local/perl -w
-# Before `make install' is performed this script should be runnable with
-# `make test'. After `make install' it should work as `perl test.pl'
-
-#########################
 
 use Test::More qw(no_plan);
 use Data::Dumper;
@@ -217,6 +213,10 @@ sub BaseTests {
     like($@, qr/non-numeric data/,
        "Invalid version format (non-numeric data)");
 
+    eval { $version = $CLASS->$method("-1.23")};
+    like($@, qr/negative version number/,
+       "Invalid version format (negative version number)");
+
     # from here on out capture the warning and test independently
     {
     eval{$version = $CLASS->$method("99 and 44/100 pure")};
@@ -474,6 +474,22 @@ SKIP: {
            'Replacement handles modules without VERSION'); 
        unlink $filename;
     }
+SKIP:    { # https://rt.perl.org/rt3/Ticket/Display.html?id=95544
+       skip "version require'd instead of use'd, cannot test UNIVERSAL::VERSION", 2
+           unless defined $qv_declare;
+       my ($fh, $filename) = tempfile('tXXXXXXX', SUFFIX => '.pm', UNLINK => 1);
+       (my $package = basename($filename)) =~ s/\.pm$//;
+       print $fh "package $package;\n\$VERSION = '3alpha';\n1;\n";
+       close $fh;
+       eval "use lib '.'; use $package; die $package->VERSION";
+       ok ($@ =~ /3alpha/, 'Even a bad $VERSION is returned');
+       eval "use lib '.'; use $package;";
+       unlike ($@, qr/Invalid version format \(non-numeric data\)/,
+           'Do not warn about bad $VERSION unless asked');
+       eval "use lib '.'; use $package 1;";
+       like ($@, qr/Invalid version format \(non-numeric data\)/,
+           'Warn about bad $VERSION when asked');
+    }
 
 SKIP:  {
        skip 'Cannot test bare v-strings with Perl < 5.6.0', 4
@@ -624,7 +640,6 @@ SKIP: {
        my $warning;
        local $SIG{__WARN__} = sub { $warning = $_[0] };
 
-$DB::single = 1;
        my $v = eval { $CLASS->$method('1,7') };
 #      is( $@, "", 'Directly test comma as decimal compliance');