Re: [PATCH] Re: Lack of error for large string on Solaris
[p5sagit/p5-mst-13.2.git] / t / op / ver.t
index 4f79acf..79c36b6 100755 (executable)
@@ -11,9 +11,9 @@ $DOWARN = 1; # enable run-time warnings now
 use Config;
 
 require "test.pl";
-plan( tests => 47 );
+plan( tests => 53 );
 
-eval { use v5.5.640; };
+eval 'use v5.5.640';
 is( $@, '', "use v5.5.640; $@");
 
 require_ok('v5.5.640');
@@ -52,7 +52,7 @@ is(v1.20.300.4000, "\x{1}\x{14}\x{12c}\x{fa0}",'compare embedded \x{} string');
 
 #
 # now do the same without the "v"
-eval { use 5.5.640; };
+eval 'use 5.5.640';
 is( $@, '', "use 5.5.640; $@");
 
 require_ok('5.5.640');
@@ -180,7 +180,7 @@ is('foo',((chr(193) eq 'A') ? v134.150.150 : v102.111.111),"v-string ne ''");
 # Chapter 15, pp403
 
 # See if sane addr and gethostbyaddr() work
-eval { require Socket; gethostbyaddr(v127.0.0.1, Socket::AF_INET) };
+eval { require Socket; gethostbyaddr(v127.0.0.1, &Socket::AF_INET) };
 if ($@) {
     # No - so do not test insane fails.
     $@ =~ s/\n/\n# /g;
@@ -189,7 +189,7 @@ SKIP: {
     skip("No Socket::AF_INET # $@") if $@;
     my $ip   = v2004.148.0.1;
     my $host;
-    eval { $host = gethostbyaddr($ip,Socket::AF_INET) };
+    eval { $host = gethostbyaddr($ip,&Socket::AF_INET) };
     like($@, qr/Wide character/, "Non-bytes leak to gethostbyaddr");
 }
 
@@ -205,9 +205,20 @@ is(v200, eval("+v200"), 'v200 eq eval("+v200")' );
 # Tests for string/numeric value of $] itself
 my ($revision,$version,$subversion) = split '\.', sprintf("%vd",$^V);
 
+print "# revision   = '$revision'\n";
+print "# version    = '$version'\n";
+print "# subversion = '$subversion'\n";
+
 my $v = sprintf("%d.%.3d%.3d",$revision,$version,$subversion);
 
-ok( $v eq "$]", qq{"\$^V eq "\$]"});
+print "# v = '$v'\n";
+print "# ] = '$]'\n";
+
+$v =~ s/000$// if $subversion == 0;
+
+print "# v = '$v'\n";
+
+ok( $v eq "$]", qq{\$^V eq "\$]"});
 
 $v = $revision + $version/1000 + $subversion/1000000;
 
@@ -234,3 +245,22 @@ SKIP: {
     }
   }
 }
+
+# Tests for magic v-strings 
+
+$v = 1.2.3;
+is( ref(\$v), 'VSTRING', 'v-string objects' );
+
+$v = v1.2_3;
+is( ref(\$v), 'VSTRING', 'v-string objects with v' );
+is( sprintf("%vd", $v), '1.23', 'v-string ignores underscores' );
+
+# [perl #16010]
+%h = (v65 => 42);
+ok( exists $h{v65}, "v-stringness is not engaged for vX" );
+%h = (v65.66 => 42);
+ok( exists $h{chr(65).chr(66)}, "v-stringness is engaged for vX.Y" );
+%h = (65.66.67 => 42);
+ok( exists $h{chr(65).chr(66).chr(67)}, "v-stringness is engaged for X.Y.Z" );
+
+