Elm Exactly
Results / elm-core /

StringContainsTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`String.contains` finds a substring that is present, rejects one that is
not, and reports that the empty string is contained in any string.

The haystack is `"Hello"`; the needles are `"ell"`, `"xyz"` and `""`.

Results

elm-0.19.1

passran in 39 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
contains_yes: True
contains_no: False
contains_empty: True

elm-0.19.2

passran in 41 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
contains_yes: True
contains_no: False
contains_empty: True

elm-0.19.3

passran in 37 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
contains_yes: True
contains_no: False
contains_empty: True

lamdera-1.5.0

passran in 42 ms
Output
contains_yes: True
contains_no: False
contains_empty: True

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module StringContainsTest exposing (main)
{-| `String.contains` finds a substring that is present, rejects one that is
not, and reports that the empty string is contained in any string.
The haystack is `"Hello"`; the needles are `"ell"`, `"xyz"` and `""`.
-}
-- CHECK: contains_yes: True
-- CHECK: contains_no: False
-- CHECK: contains_empty: True
import Html exposing (text)
main =
let
_ = Debug.log "contains_yes" (String.contains "ell" "Hello")
_ = Debug.log "contains_no" (String.contains "xyz" "Hello")
_ = Debug.log "contains_empty" (String.contains "" "Hello")
in
text "done"