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

22
tests/stdlib/tsums.nim Normal file
View file

@ -0,0 +1,22 @@
import std/sums
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 in 64 bits
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