Replies: 1 comment
-
Comparisons of primitives are based on function equalsVector (_, actual, expected) {
t.is(actual.length, expected.length)
const equals = actual.every((v, i) => expected[i] === v)
if (!equals) {
t.log({ actual, expected })
t.fail('Vectors did not equal')
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Apologies if this is ridiculous; I realize that
0
and-0
are two distinct values, when it comes to textual representations and binary encodings, however from the perspective of mathematical operations in, say, linear algebra, they are equivalent.Goal
I am trying to test an unorthodox project, with some bespoke math libraries. Converting CSG volumes in a very particular format (Quake 1 .MAP format and Half-Life 1 .MAP format, specifically) to triangle-mesh, among other things.
Reproduction
I have some Objects with Static Methods
Vec3.add(v1, v2, vecOutput)
rather thanv1.add(v2)
for instance, so there are no private state surprises, etc.Given something like the following:
I get an error stating that
[0, -0, 1] != [0, 0, 1]
becauseRunning a simpler test
test("0 is 0", (_) => _.is(-0, 0))
produces the same error.Expectation
test("0 is 0", (_) => _.assert(_.is(-0, 0)))
test("0s are 0s", (_) => _.assert(_.deepEqual([-0, -0, -0], [0, 0, 0])))
I can manually craft each and every expected value to incorporate -0 in all components, but when it comes time to validate even a trivial Quake map, converted to a mesh suitable for uploading to WebGPU shaders, or the like, that's going to be a lot of manual effort.
Version
ava@latest
("^5.2.0"
) added yesterdayConfig
Default config (no config files; no package.json changes).
Runtime
package.json:
{ "scripts": { "dev:test": "ava --watch" } }
shell:
npm run dev:test
Beta Was this translation helpful? Give feedback.
All reactions