danprince / wasm-challenges

🤖 Tiny challenges for learning WebAssembly
0 stars 1 forks source link

Make test suite more lenient towards float equality #1

Open sroelants opened 6 days ago

sroelants commented 6 days ago

e.g. in the lerp.wat tests, the test will pass or fail depending on how you structure the operations (because IEEE).

// equal(lerp(10, 0, 1.1), -1)
let works = 10 - 1.1 * 10 + 1.1 * 0  // -1
let fails = (1 - 1.1) * 10 + 1.1 * 0 // -1.0000000000000009
danprince commented 6 days ago

Most of the other float tests either use equalClose directly, or alias it to equal.

https://github.com/danprince/wasm-challenges/blob/79200c7d37dc9dcd5fac80fee086505de307465a/tests.mjs#L590

Must have just missed it for the lerp tests!