Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Sync up tests with upstream version.pm

Pull in the contents of t/coretests.pm (more or less) from the CPAN
release of version.pm.

Signed-off-by: David Golden <dagolden@cpan.org>
  • Loading branch information...
commit 249f7ddc6a71afa99cbcae72f08451ee2462c7c5 1 parent 573a19f
authored December 06, 2011 dagolden committed December 09, 2011

Showing 1 changed file with 45 additions and 18 deletions. Show diff stats Hide diff stats

  1. 63  lib/version.t
63  lib/version.t
@@ -486,14 +486,12 @@ SKIP:    { # https://rt.perl.org/rt3/Ticket/Display.html?id=95544
486 486
 	(my $package = basename($filename)) =~ s/\.pm$//;
487 487
 	print $fh "package $package;\n\$VERSION = '3alpha';\n1;\n";
488 488
 	close $fh;
489  
-	eval "use lib '.'; use $package; die $package->VERSION";
490  
-	ok ($@ =~ /3alpha/, 'Even a bad $VERSION is returned');
491  
-	eval "use lib '.'; use $package;";
492  
-	unlike ($@, qr/Invalid version format \(non-numeric data\)/,
493  
-	    'Do not warn about bad $VERSION unless asked');
  489
+	eval "use lib '.'; use $package; print $package->VERSION";
  490
+	like ($@, qr/Invalid version format \(non-numeric data\)/,
  491
+	    'Warn about bad \$VERSION');
494 492
 	eval "use lib '.'; use $package 1;";
495 493
 	like ($@, qr/Invalid version format \(non-numeric data\)/,
496  
-	    'Warn about bad $VERSION when asked');
  494
+	    'Warn about bad $VERSION');
497 495
     }
498 496
 
499 497
 SKIP: 	{
@@ -720,6 +718,32 @@ EOF
720 718
 	my $badv2 = bless { qv => 1, version => [1,2,3] }, "version";
721 719
 	is $badv2, 'v1.2.3', "Deal with badly serialized versions from YAML ";	
722 720
     }
  721
+
  722
+    {
  723
+	# https://rt.cpan.org/Public/Bug/Display.html?id=70950
  724
+	# test indirect usage of version objects
  725
+	my $sum = 0;
  726
+	eval '$sum += $CLASS->$method("v2.0.0")';
  727
+	like $@, qr/operation not supported with version object/,
  728
+	    'No math operations with version objects';
  729
+	# test direct usage of version objects
  730
+	my $v = $CLASS->$method("v2.0.0");
  731
+	eval '$v += 1';
  732
+	like $@, qr/operation not supported with version object/,
  733
+	    'No math operations with version objects';
  734
+    }
  735
+
  736
+    {
  737
+	# https://rt.cpan.org/Ticket/Display.html?id=72365
  738
+	# https://rt.perl.org/rt3/Ticket/Display.html?id=102586
  739
+	eval 'my $v = $CLASS->$method("version")';
  740
+	like $@, qr/Invalid version format/,
  741
+	    'The string "version" is not a version';
  742
+	eval 'my $v = $CLASS->$method("ver510n")';
  743
+	like $@, qr/Invalid version format/,
  744
+	    'All strings starting with "v" are not versions';
  745
+    }
  746
+
723 747
 SKIP: {
724 748
 	if ( $] < 5.006_000 ) {
725 749
 	    skip 'No v-string support at all < 5.6.0', 2; 
@@ -742,20 +766,23 @@ SKIP: {
742 766
 	ok $CLASS->$method("1.2.3") < $CLASS->$method("1.2.3.1"), 'Compare 3 and 4 digit v-strings, quoted';
743 767
 	ok $CLASS->$method("v1.2.3") < $CLASS->$method("v1.2.3.1"), 'Compare 3 and 4 digit v-strings, quoted leading v';
744 768
     }
745  
-}
746 769
 
747  
-eval { version->new("version") };
748  
-pass('no crash with version->new("version")');
749  
-{
750  
-    package _102586;
751  
-    sub TIESCALAR { bless [] }
752  
-    sub FETCH { "version" }
753  
-    sub STORE { }
754  
-    tie my $v, __PACKAGE__;
755  
-    $v = version->new(1);
756  
-    eval { version->new($v) };
  770
+    {
  771
+	eval '$CLASS->$method("version")';
  772
+	pass("no crash with ${CLASS}->${method}('version')");
  773
+	{
  774
+	    package _102586;
  775
+	    sub TIESCALAR { bless [] }
  776
+	    sub FETCH { "version" }
  777
+	    sub STORE { }
  778
+	    my $v;
  779
+	    tie $v, __PACKAGE__;
  780
+	    $v = $CLASS->$method(1);
  781
+	    eval '$CLASS->$method($v)';
  782
+	}
  783
+	pass('no crash with version->new($tied) where $tied returns "version"');
  784
+    }
757 785
 }
758  
-pass('no crash with version->new($tied) where $tied returns "version"');
759 786
 
760 787
 1;
761 788
 

0 notes on commit 249f7dd

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