DebugToStringAsValueTest
`Debug.toString` passed as a function value to `List.map` works on lists of `Float`s, of number literals and of `String`s in the same program. The number literals `[ 1, 2 ]` have the type `number`, which defaults to `Int`, and print as `"1"` and `"2"`. `Debug.toString` of a `String` includes its quotes, which appear escaped when the list of results is logged.
Results
elm-0.19.1
passran in 48 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. floats: ["1.5","2.5"] ints: ["1","2"] strings: ["\"a\"","\"b\""]
elm-0.19.2
passran in 42 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. floats: ["1.5","2.5"] ints: ["1","2"] strings: ["\"a\"","\"b\""]
elm-0.19.3
passran in 84 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. floats: ["1.5","2.5"] ints: ["1","2"] strings: ["\"a\"","\"b\""]
lamdera-1.5.0
passran in 41 msOutput
floats: ["1.5","2.5"] ints: ["1","2"] strings: ["\"a\"","\"b\""]
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-core/DebugToStringAsValueTest] in its title.
Source
The -- CHECK: lines give the expected output.
module DebugToStringAsValueTest exposing (main)
{-| `Debug.toString` passed as a function value to `List.map` works on lists of
`Float`s, of number literals and of `String`s in the same program.
The number literals `[ 1, 2 ]` have the type `number`, which defaults to `Int`,
and print as `"1"` and `"2"`. `Debug.toString` of a `String` includes its quotes, which appear escaped when
the list of results is logged.
-}
-- CHECK: floats: ["1.5","2.5"]
-- CHECK: ints: ["1","2"]
-- CHECK: strings: ["\"a\"","\"b\""]
import Html exposing (text)
main =
let
_ =
Debug.log "floats" (List.map Debug.toString [ 1.5, 2.5 ])
_ =
Debug.log "ints" (List.map Debug.toString [ 1, 2 ])
_ =
Debug.log "strings" (List.map Debug.toString [ "a", "b" ])
in
text "done"