diff options
author | Florent <florent@napalu.ch> | 2017-03-03 01:30:49 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-03-03 01:30:49 +0100 |
commit | f7af16a1c90914901082ad6a0ba3a7a891f807ee (patch) | |
tree | 90973dd273a32f0dc229746e4891683e04bcb8b2 /tests/stdlib | |
parent | a81247dcbe95eaac8338e478d8837cbcf57a0f3e (diff) | |
download | Nim-f7af16a1c90914901082ad6a0ba3a7a891f807ee.tar.gz |
More robust tests for #5453 (#5469)
Diffstat (limited to 'tests/stdlib')
-rw-r--r-- | tests/stdlib/nre/find.nim | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/tests/stdlib/nre/find.nim b/tests/stdlib/nre/find.nim index 116d2111c..caa953ff4 100644 --- a/tests/stdlib/nre/find.nim +++ b/tests/stdlib/nre/find.nim @@ -30,17 +30,12 @@ suite "find": test "bail early": ## we expect nothing to be found and we should be bailing out early which means that ## the timing difference between searching in small and large data should be well - ## within a tolerance area - const tolerance = 0.0001 - var smallData = repeat("url.sequence = \"http://whatever.com/jwhrejrhrjrhrjhrrjhrjrhrjrh\"", 10) - var largeData = repeat("url.sequence = \"http://whatever.com/jwhrejrhrjrhrjhrrjhrjrhrjrh\"", 1000000) - var start = cpuTime() - check(largeData.findAll(re"url.*? = '(.*?)'") == newSeq[string]()) - var stop = cpuTime() - var elapsedLarge = stop - start - start = cpuTime() - check(smallData.findAll(re"url.*? = '(.*?)'") == newSeq[string]()) - stop = cpuTime() - var elapsedSmall = stop - start - var difference = elapsedLarge - elapsedSmall - check(difference < tolerance) + ## within a tolerance margin + const small = 10 + const large = 1000 + var smallData = repeat("url.sequence = \"http://whatever.com/jwhrejrhrjrhrjhrrjhrjrhrjrh\" ", small) + var largeData = repeat("url.sequence = \"http://whatever.com/jwhrejrhrjrhrjhrrjhrjrhrjrh\" ", large) + var expression = re"^url.* = "(.*?)"" + + check(smallData.findAll(expression) == newSeq[string]()) + check(largeData.findAll(expression) == newSeq[string]()) |