move rest of tests to testament (#16140)

* move rest of tests to testament
* Update tests/stdlib/tsums.nim
This commit is contained in:
flywind 2020-11-28 03:47:49 +08:00 • committed by GitHub
commit bc1db0d6f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 228 additions and 233 deletions

View file

@ -60,27 +60,3 @@ runnableExamples:
const data = [1, 2, 3, 4, 5, 6, 7, 8, 9]
doAssert sumKbn(data) == 45
doAssert sumPairs(data) == 45
when isMainModule:
from math import pow
var epsilon = 1.0
while 1.0 + epsilon != 1.0:
epsilon /= 2.0
let data = @[1.0, epsilon, -epsilon]
assert sumKbn(data) == 1.0
assert sumPairs(data) != 1.0 # known to fail
assert (1.0 + epsilon) - epsilon != 1.0
var tc1: seq[float]
for n in 1 .. 1000:
tc1.add 1.0 / n.float
assert sumKbn(tc1) == 7.485470860550345
assert sumPairs(tc1) == 7.485470860550345
var tc2: seq[float]
for n in 1 .. 1000:
tc2.add pow(-1.0, n.float) / n.float
assert sumKbn(tc2) == -0.6926474305598203
assert sumPairs(tc2) == -0.6926474305598204