diff options
author | S. Gilles <sgilles@math.umd.edu> | 2019-05-01 16:02:26 -0400 |
---|---|---|
committer | S. Gilles <sgilles@math.umd.edu> | 2019-05-01 16:02:26 -0400 |
commit | 303798469e8afe0e514c667f3c8c7ae2c65e58c5 (patch) | |
tree | d29610c74026436aba1aceca728c4317139eefea | |
parent | b889eefb13a9f1e41a3d0a85b23b69c058847ef3 (diff) | |
download | mc-303798469e8afe0e514c667f3c8c7ae2c65e58c5.tar.gz |
Test the slow2sum function.
The singular piece of test data is the tuple that caused me to spend far
too long realizing that fast2sum is not always appropriate.
-rw-r--r-- | lib/math/test/util.myr | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/math/test/util.myr b/lib/math/test/util.myr new file mode 100644 index 0000000..d16b5ed --- /dev/null +++ b/lib/math/test/util.myr @@ -0,0 +1,29 @@ +use std +use math +use testr + +const main = { + math.fptrap(false) + testr.run([ + [.name="slow2sum-01", .fn = slow2sum01], + ][:]) +} + +const slow2sum01 = {c + var inputs : (uint64, uint64, uint64, uint64)[:] = [ + (0xbc29505efc367580, 0xc000000000000000, 0xc000000000000000, 0xbc29505efc367580) + ][:] + + for (x, y, s, t) : inputs + var xf : flt64 = std.flt64frombits(x) + var yf : flt64 = std.flt64frombits(y) + var r1, r2 + (r1, r2) = math.slow2sum(xf, yf) + var r1u = std.flt64bits(r1) + var r2u = std.flt64bits(r2) + testr.check(c, r1u == s && r2u == t, + "2sum(0x{b=16,w=16,p=0}, 0x{b=16,w=16,p=0) is (0x{b=16,w=16,p=0}, 0x{b=16,w=16,p=0}), should be (0x{b=16,w=16,p=0}, 0x{b=16,w=16,p=0})", + x, y, r1u, r2u, s, t) + + ;; +} |