mirror of
https://github.com/correl/elm.git
synced 2024-11-16 11:09:29 +00:00
54e3017815
* Update exercises to elm-test 2.0 * Update docs to mention `elm-test` again * Update .travis.yml to the correct version of elm-test * Conform to the `<| \() ->` convention
47 lines
1.6 KiB
Elm
47 lines
1.6 KiB
Elm
port module Main exposing (..)
|
|
|
|
import Test.Runner.Node exposing (run)
|
|
import Json.Encode exposing (Value)
|
|
import Test exposing (..)
|
|
import Expect
|
|
import RunLengthEncoding exposing (version, decode, encode)
|
|
|
|
|
|
tests : Test
|
|
tests =
|
|
describe "RunLengthEncoding"
|
|
[ test "the solution is for the correct version of the test" <|
|
|
\() -> Expect.equal 2 version
|
|
, test "encode simple" <|
|
|
\() -> Expect.equal "2A3B4C" (encode "AABBBCCCC")
|
|
, test "decode simple" <|
|
|
\() -> Expect.equal "AABBBCCCC" (decode "2A3B4C")
|
|
, test "encode with single values" <|
|
|
\() ->
|
|
Expect.equal "12WB12W3B24WB"
|
|
(encode "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB")
|
|
, test "decode with single values" <|
|
|
\() ->
|
|
Expect.equal "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB"
|
|
(decode "12WB12W3B24WB")
|
|
, test "(decode (encode (...)) combination" <|
|
|
\() ->
|
|
Expect.equal "zzz ZZ zZ"
|
|
(decode (encode "zzz ZZ zZ"))
|
|
, test "decode with a x10 value" <|
|
|
\() ->
|
|
Expect.equal "WWWWWWWWWW"
|
|
(decode "10W")
|
|
, test "encode unicode" <|
|
|
\() -> Expect.equal "⏰3⚽2⭐⏰" (encode "⏰⚽⚽⚽⭐⭐⏰")
|
|
, test "decode unicode" <|
|
|
\() -> Expect.equal "⏰⚽⚽⚽⭐⭐⏰" (decode "⏰3⚽2⭐⏰")
|
|
]
|
|
|
|
|
|
main : Program Never
|
|
main =
|
|
run emit tests
|
|
|
|
|
|
port emit : ( String, Value ) -> Cmd msg
|