This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
charnames.t: Don't call srand(undef)
authorKarl Williamson <public@khwilliamson.com>
Fri, 10 Sep 2010 00:06:22 +0000 (18:06 -0600)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 25 Sep 2010 07:47:00 +0000 (00:47 -0700)
srand(undef) is the same as srand(0).  The code is trying to get random
seeds, not a fixed one.

lib/charnames.t

index eb7358c..43f4857 100644 (file)
@@ -776,9 +776,15 @@ is("\N{U+1D0C5}", "\N{BYZANTINE MUSICAL SYMBOL FTHORA SKLIRON CHROMA VASIS}");
 
     # For randomized tests below.
     my $seed;
 
     # For randomized tests below.
     my $seed;
-    $seed = $ENV{PERL_TEST_CHARNAMES_SEED} if
-                                    defined $ENV{PERL_TEST_CHARNAMES_SEED};
-    $seed = srand($seed);
+    if (defined $ENV{PERL_TEST_CHARNAMES_SEED}) {
+        $seed = srand($ENV{PERL_TEST_CHARNAMES_SEED});
+        if ($seed != $ENV{PERL_TEST_CHARNAMES_SEED}) {
+            die "srand returned '$seed' instead of '$ENV{PERL_TEST_CHARNAMES_SEED}'";
+        };
+    }
+    else {
+        $seed = srand;
+    }
 
     # We will look at the data grouped in "blocks" of the following
     # size.
 
     # We will look at the data grouped in "blocks" of the following
     # size.