Fix occasional failures in svleak.t and DosGlob.t
authorFather Chrysostomos <sprout@cpan.org>
Thu, 13 Dec 2012 01:55:06 +0000 (17:55 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 13 Dec 2012 02:05:10 +0000 (18:05 -0800)
If the random number of ops happens to be 0 the first time, then we
end up with a false positive, as evaluating '$x+<*>' after '<*>' will
vivify the *x glob.

ext/File-DosGlob/t/DosGlob.t
t/op/svleak.t

index b3302b8..edae752 100644 (file)
@@ -147,9 +147,9 @@ SKIP: {
     # Use a random number of ops, so that the glob op does not reuse the
     # same address each time, giving us false passes.
     my($count,$count2);
-    eval '$x+'x(rand() * 100) . '<*>';
+    eval '$x+'x(1+rand() * 100) . '<*>';
     $count = sv_count();
-    eval '$x+'x(rand() * 100) . '<*>';
+    eval '$x+'x(1+rand() * 100) . '<*>';
     $count2 = sv_count();
     is $count2, $count, 'no leak when partly iterated caller is freed';
 }
index b4a3fcf..6baf0e1 100644 (file)
@@ -109,7 +109,7 @@ eleak(2, 0, "$all v111111111111111111111111111111111111111111111111",
 eleak(2, 0, 'sub{<*>}');
 # Use a random number of ops, so that the glob op does not reuse the same
 # address each time, giving us false passes.
-leak(2, 0, sub { eval '$x+'x(rand() * 100) . '<*>'; },
+leak(2, 0, sub { eval '$x+'x(1 + rand() * 100) . '<*>'; },
     'freeing partly iterated glob');
 
 eleak(2, 0, 'goto sub {}', 'goto &sub in eval');