Elm Exactly
Results / elm-core /

StringToFloatOutOfRangeTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
Checks that `String.toFloat` accepts a well-formed number whose magnitude is outside the range of a finite `Float`: an overflow gives `Infinity` (or `-Infinity`) and an underflow gives `0`.

A number in range, `"1e300"`, is also parsed, as `Just 1e300`.

Results

elm-0.19.1

passran in 46 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
overflow: Just Infinity
negOverflow: Just -Infinity
underflow: Just 0
inRange: Just 1e+300

elm-0.19.2

passran in 44 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
overflow: Just Infinity
negOverflow: Just -Infinity
underflow: Just 0
inRange: Just 1e+300

elm-0.19.3

passran in 48 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
overflow: Just Infinity
negOverflow: Just -Infinity
underflow: Just 0
inRange: Just 1e+300

lamdera-1.5.0

passran in 49 ms
Output
overflow: Just Infinity
negOverflow: Just -Infinity
underflow: Just 0
inRange: Just 1e+300

Discussions

Discuss this test·Search the discussions on GitHub

Discussions are on GitHub; one about this test has [t:elm-core/StringToFloatOutOfRangeTest] in its title.

Source

The -- CHECK: lines give the expected output.

module StringToFloatOutOfRangeTest exposing (main)
{-| Checks that `String.toFloat` accepts a well-formed number whose magnitude is outside the range of a finite `Float`: an overflow gives `Infinity` (or `-Infinity`) and an underflow gives `0`.
A number in range, `"1e300"`, is also parsed, as `Just 1e300`.
-}
-- CHECK: overflow: Just Infinity
-- CHECK: negOverflow: Just -Infinity
-- CHECK: underflow: Just 0
-- CHECK: inRange: Just 1e+300
import Html exposing (text)
main =
let
_ =
Debug.log "overflow" (String.toFloat "1e400")
_ =
Debug.log "negOverflow" (String.toFloat "-1e400")
_ =
Debug.log "underflow" (String.toFloat "1.5e-400")
_ =
Debug.log "inRange" (String.toFloat "1e300")
in
text "done"