elm-explorations / elm-explorations/test
usesFloat incorrectly identifies union type as a float
- Dominant language
- Elm
- Stars
- 244
- Forks
- 40
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 2
Description
The logic `elm-test` uses to identify floats incorrectly identifies a union type with a potential value of `Infinity` as a float. This is because `String.toFloat "Infinity" == Just Infinity`.
This error *only* happens when the name of the union potential value is `Infinity`.
# SSCE
```elm
module Example exposing (..)
import Expect exposing (Expectation)
import Fuzz exposing (Fuzzer, int, list, string)
import Test exposing (..)
type UnionType =
Infinity
suite : Test
suite =
test "should not give a 'use float' error" <|
\() ->
Infinity
|> Expect.equal Infinity
```
Running `elm-test` with the latest (beta) version gives:
```
Running 1 test. To reproduce these results, run: elm-test --fuzz 100 --seed 241676437961883
↓ Example
✗ should not give a 'use float' error
Do not use Expect.equal with floats. Use Float.within instead.
```
I do not know what the solution is for this, I just renamed my union types as a work around.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.