move rest of tests to testament (#16140)
* move rest of tests to testament * Update tests/stdlib/tsums.nim
This commit is contained in:
parent
c9a10bb9e4
commit
bc1db0d6f1
12 changed files with 228 additions and 233 deletions
22
tests/stdlib/tsums.nim
Normal file
22
tests/stdlib/tsums.nim
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue