-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unconditional failing when Floats equality is asserted breaks Elm Verify Examples #88
Comments
Oof. No obvious solution here so I'll invite brainstorming. |
Floating point functions change depending on os, browser and cpu generation, so I don't think float equality is a good idea here either. Sooner or later someone will test a non-trivial float function, and it'll break. Maybe Stoeffel can add a second syntax for |
There is another related issue where records that contain floating point values are really hard to test as you have to compare all keys one by one.
As an aside - I believe the IEEE floating point spec has in fact locked down the behaviour of floating point functions. |
Yes, but IEEE754 is so relaxed that it allows for all these implementation-specific differences. I ran into this issue with elm-test in 2018, where I had unit tests for exact equality of floats, and the tests passed on mac but not on windows. |
Hmm... maybe something like:
There was a related discussion here: stoeffel/elm-verify-examples#39. Personally I agree with @stoeffel - these are just examples, so the additional syntax should be as straight forward as possible. Perhaps it could be possible to detect floats (like this package is doing) and generate different test code using |
Unfortunately, the errors build up. You'd have to specify both a relative (multiplicative) tolerance, and an absolute (additive) tolerance. |
Sure, but not as an example in the docs, right? If we can come up with a reasonable tolerance I think that would be ideal. Maybe allowing it to pass if within an absolute or a relative tolerance? |
We can give it a try and see what happens ¯\_(ツ)_/¯ I think exact equality would be best in that case. |
Why not? I mean the examples should be simple, but the internals of a tested function can be complex. I'm not saying it's impossible to come up with a reasonable tolerance, but the first assumption doesn't seem sound. |
test/src/Expect.elm
Lines 747 to 748 in f42d322
This creates some problems with
elm-verify-examples
. See stoeffel/elm-verify-examples#83. Perhaps there could be a command line switch or something likeExpect.strictlyEqual
to allow to do this kind of comparison.For reference here is a discussion that introduced this feature: elm-community/elm-test#230
The text was updated successfully, but these errors were encountered: