CoreIssue1142StringToIntMaxSafeTest
Tags:elm19-bug
Issue: elm/core#1142
`String.toInt` is off by one for integers near 2^53. <https://github.com/elm/core/issues/1142> Elm 0.19.1 computes `10 * total + code - 0x30`, which rounds before subtracting, so `String.toInt "9007199254740991"` is `Just 9007199254740992`. Both inputs below are exactly representable (within the JavaScript safe-integer range) and must round-trip.
Results
elm-0.19.1
failran in 91 msMissing pattern: max safe: Just 9007199254740991 --- output --- Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. max safe: Just 9007199254740992 near max: Just 9007199254740944
elm-0.19.2
failran in 68 msMissing pattern: max safe: Just 9007199254740991 --- output --- Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. max safe: Just 9007199254740992 near max: Just 9007199254740944
elm-0.19.3
failran in 78 msMissing pattern: max safe: Just 9007199254740991 --- output --- Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. max safe: Just 9007199254740992 near max: Just 9007199254740944
lamdera-1.5.0
failran in 72 msMissing pattern: max safe: Just 9007199254740991 --- output --- max safe: Just 9007199254740992 near max: Just 9007199254740944
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-core/CoreIssue1142StringToIntMaxSafeTest] in its title.
Source
The -- CHECK: lines give the expected output.
module CoreIssue1142StringToIntMaxSafeTest exposing (main)
{-| `String.toInt` is off by one for integers near 2^53.
<https://github.com/elm/core/issues/1142>
Elm 0.19.1 computes `10 * total + code - 0x30`, which rounds before subtracting, so
`String.toInt "9007199254740991"` is `Just 9007199254740992`. Both inputs below are exactly
representable (within the JavaScript safe-integer range) and must round-trip.
-}
-- TAGS: elm19-bug
-- CHECK: max safe: Just 9007199254740991
-- CHECK: near max: Just 9007199254740945
import Html exposing (text)
main =
let
_ =
Debug.log "max safe" (String.toInt "9007199254740991")
_ =
Debug.log "near max" (String.toInt "9007199254740945")
in
text "done"