summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorSimon Hafner <hafnersimon@gmail.com>2012-09-06 17:25:52 -0500
committerSimon Hafner <hafnersimon@gmail.com>2012-09-06 17:25:52 -0500
commite9bbc7235dc017a97fdc831efdaacb5325984d18 (patch)
treef794657f289f518d6a99aa765a161dbd6eab5d12
parent33cabeb04d4dc00f4edf40096f790b510f915dd9 (diff)
downloadNim-e9bbc7235dc017a97fdc831efdaacb5325984d18.tar.gz
no uniqueCounter it is
-rwxr-xr-xlib/pure/math.nim7
-rw-r--r--tests/run/tmath.nim9
2 files changed, 7 insertions, 9 deletions
diff --git a/lib/pure/math.nim b/lib/pure/math.nim
index d20fbc2ca..8a894e080 100755
--- a/lib/pure/math.nim
+++ b/lib/pure/math.nim
@@ -188,11 +188,10 @@ when not defined(ECMAScript):
   proc rand(): cint {.importc: "rand", nodecl.}
   proc drand48(): float {.importc: "drand48", nodecl.}
     
-  var uniqueCounter: int = 0
   proc randomize() =
-    srand(gettime(nil) + cint(uniqueCounter))
-    srand48(gettime(nil) + cint(uniqueCounter))
-    atomicInc(uniqueCounter)
+    let x = gettime(nil)
+    srand(x)
+    srand48(x)
   proc random(max: int): int =
     result = int(rand()) mod max
   proc random(max: float): float =
diff --git a/tests/run/tmath.nim b/tests/run/tmath.nim
index 67837b21a..65124306e 100644
--- a/tests/run/tmath.nim
+++ b/tests/run/tmath.nim
@@ -5,11 +5,10 @@ import sets
 suite "random int":
   test "there might be some randomness":
     var set = initSet[int](128)
-    for i in 1..10:
-      for j in 1..10:
-        randomize()
-        incl(set, random(high(int)))
-    check len(set) == 100
+    randomize()
+    for i in 1..1000:
+      incl(set, random(high(int)))
+    check len(set) == 1000
   test "single number bounds work":
     randomize()
     var rand: int