diff --git a/.travis.yml b/.travis.yml index b809d52..e6a65cc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,9 +5,9 @@ language: bash sudo: false install: - - nvm install 0.12 - - nvm use 0.12 - - npm install -g elm@0.17.0 elm-test@0.16.1-alpha4 + - nvm install 6 + - nvm use 6 + - npm install -g elm@0.17.1 elm-test@0.17.1 - elm package install -y script: diff --git a/bin/build.sh b/bin/build.sh index aef7c67..27fe47b 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -12,7 +12,8 @@ do echo '-------------------------------------------------------' echo "Testing $exercise" - elm-make $exercise_dir/*Tests.elm --yes --output build.js && node build.js + elm-package install + elm-test $exercise_dir/*Tests.elm if [ $? -ne 0 ]; then TEST_RESULT=1 diff --git a/docs/INSTALLATION.md b/docs/INSTALLATION.md index 238d1be..3d8458b 100644 --- a/docs/INSTALLATION.md +++ b/docs/INSTALLATION.md @@ -2,8 +2,8 @@ The simplest way to install Elm is via Node.js/NPM. -If you don't already have Node.js installed on your computer, you can download it from [the official site](https://nodejs.org/). Once you have Node.js up and running, follow these steps to install the Elm platform. +If you don't already have Node.js installed on your computer, you can download it from [the official site](https://nodejs.org/). Once you have Node.js up and running, follow these steps to install the Elm platform and `elm-test`. ```bash -$ npm install --global elm +$ npm install --global elm elm-test ``` diff --git a/docs/TESTS.md b/docs/TESTS.md index eb3a2da..22b65f5 100644 --- a/docs/TESTS.md +++ b/docs/TESTS.md @@ -1,8 +1,8 @@ -Elm exercises within your exercism project directory can be run by changing to the exercise directory, and running `./runtests.sh` (or `runtests.bat` on Windows). +The Elm exercise test suites may be run from the exercise directory. ```bash $ cd exercism/project/directory/elm/hello-world -$ ./runtests.sh +$ elm-test *Tests.elm ``` ## Hints and tips diff --git a/elm-package.json b/elm-package.json index f8b1d08..c76c075 100644 --- a/elm-package.json +++ b/elm-package.json @@ -36,8 +36,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/accumulate/AccumulateTests.elm b/exercises/accumulate/AccumulateTests.elm index 815ca26..b767ad1 100644 --- a/exercises/accumulate/AccumulateTests.elm +++ b/exercises/accumulate/AccumulateTests.elm @@ -1,6 +1,9 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest exposing (..) +import Test.Runner.Node exposing (run) +import Json.Encode exposing (Value) +import Test exposing (..) +import Expect import Accumulate exposing (accumulate) import String @@ -12,18 +15,25 @@ square x = tests : Test tests = - suite "Accumulate" - [ test "[]] Accumulate" - (assertEqual [] (accumulate square [])) - , test "square Accumulate" - (assertEqual [ 1, 4, 9 ] (accumulate square [ 1, 2, 3 ])) - , test "toUpper Accumulate" - (assertEqual [ "HELLO", "WORLD" ] (accumulate String.toUpper [ "hello", "world" ])) - , test "reverse Accumulate" - (assertEqual [ "olleh", "dlrow" ] (accumulate String.reverse [ "hello", "world" ])) + describe "Accumulate" + [ test "[]] Accumulate" <| + \() -> Expect.equal [] (accumulate square []) + , test "square Accumulate" <| + \() -> Expect.equal [ 1, 4, 9 ] (accumulate square [ 1, 2, 3 ]) + , test "toUpper Accumulate" <| + \() -> + Expect.equal [ "HELLO", "WORLD" ] + (accumulate String.toUpper [ "hello", "world" ]) + , test "reverse Accumulate" <| + \() -> + Expect.equal [ "olleh", "dlrow" ] + (accumulate String.reverse [ "hello", "world" ]) ] main : Program Never main = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/accumulate/elm-package.json b/exercises/accumulate/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/accumulate/elm-package.json +++ b/exercises/accumulate/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/accumulate/runtests.bat b/exercises/accumulate/runtests.bat deleted file mode 100755 index 2a38cd8..0000000 --- a/exercises/accumulate/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/accumulate/runtests.sh b/exercises/accumulate/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/accumulate/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js diff --git a/exercises/allergies/AllergiesTests.elm b/exercises/allergies/AllergiesTests.elm index d900caa..9a66f42 100644 --- a/exercises/allergies/AllergiesTests.elm +++ b/exercises/allergies/AllergiesTests.elm @@ -1,52 +1,58 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest exposing (..) +import Test.Runner.Node exposing (run) +import Json.Encode exposing (Value) +import Test exposing (..) +import Expect import Allergies exposing (isAllergicTo, toList) import List tests : Test tests = - suite "Allergies" - [ suite "isAllergicTo" - [ suite "no allergies means not allergic" - [ test "peanuts" - (assert (not (isAllergicTo "peanuts" 0))) - , test "cats" - (assert (not (isAllergicTo "cats" 0))) - , test "strawberries" - (assert (not (isAllergicTo "strawberries" 0))) + describe "Allergies" + [ describe "isAllergicTo" + [ describe "no allergies means not allergic" + [ test "peanuts" <| + \() -> Expect.equal False (isAllergicTo "peanuts" 0) + , test "cats" <| + \() -> Expect.equal False (isAllergicTo "cats" 0) + , test "strawberries" <| + \() -> Expect.equal False (isAllergicTo "strawberries" 0) ] - , test "is allergic to eggs" - (assert (isAllergicTo "eggs" 1)) - , suite "has the right allergies" - [ test "eggs" - (assert (isAllergicTo "eggs" 5)) - , test "shellfish" - (assert (isAllergicTo "shellfish" 5)) - , test "strawberries" - (assert (not (isAllergicTo "strawberries" 5))) + , test "is allergic to eggs" <| + \() -> Expect.equal True (isAllergicTo "eggs" 1) + , describe "has the right allergies" + [ test "eggs" <| + \() -> Expect.equal True (isAllergicTo "eggs" 5) + , test "shellfish" <| + \() -> Expect.equal True (isAllergicTo "shellfish" 5) + , test "strawberries" <| + \() -> Expect.equal False (isAllergicTo "strawberries" 5) ] ] - , suite "toList" - [ test "no allergies at all" - (assertEqual [] (toList (0))) - , test "allergic to just peanuts" - (assertEqual [ "peanuts" ] (toList (2))) - , test "allergic to everything" - (assertEqual (List.sort [ "eggs", "peanuts", "shellfish", "strawberries", "tomatoes", "chocolate", "pollen", "cats" ]) - (255 |> toList |> List.sort) - ) - , test "ignore non allergen score parts" - (assertEqual [ "eggs" ] (toList 257)) - , test "ignore non allergen score parts" - (assertEqual (List.sort [ "eggs", "shellfish", "strawberries", "tomatoes", "chocolate", "pollen", "cats" ]) - (509 |> toList |> List.sort) - ) + , describe "toList" + [ test "no allergies at all" <| + \() -> Expect.equal [] (toList (0)) + , test "allergic to just peanuts" <| + \() -> Expect.equal [ "peanuts" ] (toList (2)) + , test "allergic to everything" <| + \() -> + Expect.equal (List.sort [ "eggs", "peanuts", "shellfish", "strawberries", "tomatoes", "chocolate", "pollen", "cats" ]) + (255 |> toList |> List.sort) + , test "ignore non allergen score parts" <| + \() -> Expect.equal [ "eggs" ] (toList 257) + , test "ignore non allergen score parts" <| + \() -> + Expect.equal (List.sort [ "eggs", "shellfish", "strawberries", "tomatoes", "chocolate", "pollen", "cats" ]) + (509 |> toList |> List.sort) ] ] main : Program Never main = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/allergies/elm-package.json b/exercises/allergies/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/allergies/elm-package.json +++ b/exercises/allergies/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/allergies/runtests.bat b/exercises/allergies/runtests.bat deleted file mode 100755 index 2a38cd8..0000000 --- a/exercises/allergies/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/allergies/runtests.sh b/exercises/allergies/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/allergies/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js diff --git a/exercises/anagram/AnagramTests.elm b/exercises/anagram/AnagramTests.elm index ac57a9e..32b494e 100644 --- a/exercises/anagram/AnagramTests.elm +++ b/exercises/anagram/AnagramTests.elm @@ -1,95 +1,101 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest exposing (..) +import Test.Runner.Node exposing (run) +import Json.Encode exposing (Value) +import Test exposing (..) +import Expect import Anagram exposing (detect) tests : Test tests = - suite "Anagram" - [ test "no matches" - (assertEqual [] - (detect "diaper" [ "hello", "world", "zombies", "pants" ]) - ) - , test "detects simple anagram" - (assertEqual [ "tan" ] - (detect "ant" [ "tan", "stand", "at" ]) - ) - , test "does not detect false positives" - (assertEqual [] - (detect "galea" [ "eagle" ]) - ) - , test "detects multiple anagrams" - (assertEqual [ "stream", "maters" ] - (detect "master" [ "stream", "pigeon", "maters" ]) - ) - , test "does not detect anagram subsets" - (assertEqual [] - (detect "good" [ "dog", "goody" ]) - ) - , test "detects anagram" - (assertEqual [ "inlets" ] - (detect "listen" [ "enlists", "google", "inlets", "banana" ]) - ) - , test "detects multiple anagrams" - (assertEqual [ "gallery", "regally", "largely" ] - (detect "allergy" [ "gallery", "ballerina", "regally", "clergy", "largely", "leading" ]) - ) - , test "does not detect indentical words" - (assertEqual [ "cron" ] - (detect "corn" [ "corn", "dark", "Corn", "rank", "CORN", "cron", "park" ]) - ) - , test "does not detect non-anagrams with identical checksum" - (assertEqual [] - (detect "mass" [ "last" ]) - ) - , test "detects anagrams case-insensitively" - (assertEqual [ "Carthorse" ] - (detect "Orchestra" [ "cashregister", "Carthorse", "radishes" ]) - ) - , test "detects anagrams using case-insensitive subject" - (assertEqual [ "carthorse" ] - (detect "Orchestra" [ "cashregister", "carthorse", "radishes" ]) - ) - , test "detects anagrams using case-insensitve possible matches" - (assertEqual [ "Carthorse" ] - (detect "orchestra" [ "cashregister", "Carthorse", "radishes" ]) - ) - , test "does not detect a word as its own anagram" - (assertEqual [] - (detect "banana" [ "Banana" ]) - ) - , test "does not detect a anagram if the original word is repeated" - (assertEqual [] - (detect "go" [ "go Go GO" ]) - ) - , test "anagrams must use all letters exactly once" - (assertEqual [] - (detect "tapper" [ "patter" ]) - ) - , test "eliminates anagrams with the same checksum" - (assertEqual [] - (detect "mass" [ "last" ]) - ) - , test "detects unicode anagrams" - (assertEqual [ "ΒΓΑ", "γβα" ] - (detect "ΑΒΓ" [ "ΒΓΑ", "ΒΓΔ", "γβα" ]) - ) - , test "eliminates misleading unicode anagrams" - (assertEqual [] - (detect "ΑΒΓ" [ "ABΓ" ]) - ) - , test "capital word is not own anagram" - (assertEqual [] - (detect "BANANA" [ "Banana" ]) - ) - , test "anagrams must use all letters exactly once" - (assertEqual [] - (detect "patter" [ "tapper" ]) - ) + describe "Anagram" + [ test "no matches" <| + \() -> + Expect.equal [] + (detect "diaper" [ "hello", "world", "zombies", "pants" ]) + , test "detects simple anagram" <| + \() -> + Expect.equal [ "tan" ] + (detect "ant" [ "tan", "stand", "at" ]) + , test "does not detect false positives" <| + \() -> + Expect.equal [] + (detect "galea" [ "eagle" ]) + , test "detects multiple anagrams" <| + \() -> + Expect.equal [ "stream", "maters" ] + (detect "master" [ "stream", "pigeon", "maters" ]) + , test "does not detect anagram subsets" <| + \() -> + Expect.equal [] + (detect "good" [ "dog", "goody" ]) + , test "detects anagram" <| + \() -> + Expect.equal [ "inlets" ] + (detect "listen" [ "enlists", "google", "inlets", "banana" ]) + , test "detects multiple anagrams" <| + \() -> + Expect.equal [ "gallery", "regally", "largely" ] + (detect "allergy" [ "gallery", "ballerina", "regally", "clergy", "largely", "leading" ]) + , test "does not detect indentical words" <| + \() -> + Expect.equal [ "cron" ] + (detect "corn" [ "corn", "dark", "Corn", "rank", "CORN", "cron", "park" ]) + , test "does not detect non-anagrams with identical checksum" <| + \() -> + Expect.equal [] + (detect "mass" [ "last" ]) + , test "detects anagrams case-insensitively" <| + \() -> + Expect.equal [ "Carthorse" ] + (detect "Orchestra" [ "cashregister", "Carthorse", "radishes" ]) + , test "detects anagrams using case-insensitive subject" <| + \() -> + Expect.equal [ "carthorse" ] + (detect "Orchestra" [ "cashregister", "carthorse", "radishes" ]) + , test "detects anagrams using case-insensitve possible matches" <| + \() -> + Expect.equal [ "Carthorse" ] + (detect "orchestra" [ "cashregister", "Carthorse", "radishes" ]) + , test "does not detect a word as its own anagram" <| + \() -> + Expect.equal [] + (detect "banana" [ "Banana" ]) + , test "does not detect a anagram if the original word is repeated" <| + \() -> + Expect.equal [] + (detect "go" [ "go Go GO" ]) + , test "anagrams must use all letters exactly once" <| + \() -> + Expect.equal [] + (detect "tapper" [ "patter" ]) + , test "eliminates anagrams with the same checksum" <| + \() -> + Expect.equal [] + (detect "mass" [ "last" ]) + , test "detects unicode anagrams" <| + \() -> + Expect.equal [ "ΒΓΑ", "γβα" ] + (detect "ΑΒΓ" [ "ΒΓΑ", "ΒΓΔ", "γβα" ]) + , test "eliminates misleading unicode anagrams" <| + \() -> + Expect.equal [] + (detect "ΑΒΓ" [ "ABΓ" ]) + , test "capital word is not own anagram" <| + \() -> + Expect.equal [] + (detect "BANANA" [ "Banana" ]) + , test "anagrams must use all letters exactly once" <| + \() -> + Expect.equal [] + (detect "patter" [ "tapper" ]) ] main : Program Never main = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/anagram/elm-package.json b/exercises/anagram/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/anagram/elm-package.json +++ b/exercises/anagram/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/anagram/runtests.bat b/exercises/anagram/runtests.bat deleted file mode 100755 index 2a38cd8..0000000 --- a/exercises/anagram/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/anagram/runtests.sh b/exercises/anagram/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/anagram/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js diff --git a/exercises/atbash-cipher/AtbashCipherTests.elm b/exercises/atbash-cipher/AtbashCipherTests.elm index 5ef2ffb..80e692b 100644 --- a/exercises/atbash-cipher/AtbashCipherTests.elm +++ b/exercises/atbash-cipher/AtbashCipherTests.elm @@ -1,39 +1,45 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest exposing (..) +import Test.Runner.Node exposing (run) +import Json.Encode exposing (Value) +import Test exposing (..) +import Expect import AtbashCipher exposing (encode, decode) tests : Test tests = - suite "AtbashCipher" - [ test "encode no" - (assertEqual "ml" (encode "no")) - , test "encode yes" - (assertEqual "bvh" (encode "yes")) - , test "encode OMG" - (assertEqual "lnt" (encode "OMG")) - , test "encode O M G" - (assertEqual "lnt" (encode "O M G")) - , test "encode long word" - (assertEqual "nrmwy oldrm tob" (encode "mindblowingly")) - , test "encode numbers" - (assertEqual "gvhgr mt123 gvhgr mt" (encode "Testing, 1 2 3, testing.")) - , test "encode sentence" - (assertEqual "gifgs rhurx grlm" (encode "Truth is fiction.")) - , test "encode all things" - (assertEqual "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt" - (encode "The quick brown fox jumps over the lazy dog.") - ) - , test "decode word" - (assertEqual "exercism" (decode "vcvix rhn")) - , test "decode sentence" - (assertEqual "anobstacleisoftenasteppingstone" - (decode "zmlyh gzxov rhlug vmzhg vkkrm thglm v") - ) + describe "AtbashCipher" + [ test "encode no" <| + \() -> Expect.equal "ml" (encode "no") + , test "encode yes" <| + \() -> Expect.equal "bvh" (encode "yes") + , test "encode OMG" <| + \() -> Expect.equal "lnt" (encode "OMG") + , test "encode O M G" <| + \() -> Expect.equal "lnt" (encode "O M G") + , test "encode long word" <| + \() -> Expect.equal "nrmwy oldrm tob" (encode "mindblowingly") + , test "encode numbers" <| + \() -> Expect.equal "gvhgr mt123 gvhgr mt" (encode "Testing, 1 2 3, testing.") + , test "encode sentence" <| + \() -> Expect.equal "gifgs rhurx grlm" (encode "Truth is fiction.") + , test "encode all things" <| + \() -> + Expect.equal "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt" + (encode "The quick brown fox jumps over the lazy dog.") + , test "decode word" <| + \() -> Expect.equal "exercism" (decode "vcvix rhn") + , test "decode sentence" <| + \() -> + Expect.equal "anobstacleisoftenasteppingstone" + (decode "zmlyh gzxov rhlug vmzhg vkkrm thglm v") ] main : Program Never main = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/atbash-cipher/elm-package.json b/exercises/atbash-cipher/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/atbash-cipher/elm-package.json +++ b/exercises/atbash-cipher/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/atbash-cipher/runtests.bat b/exercises/atbash-cipher/runtests.bat deleted file mode 100755 index 2a38cd8..0000000 --- a/exercises/atbash-cipher/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/atbash-cipher/runtests.sh b/exercises/atbash-cipher/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/atbash-cipher/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js diff --git a/exercises/bob/BobTests.elm b/exercises/bob/BobTests.elm index 560bff0..bb2dc23 100644 --- a/exercises/bob/BobTests.elm +++ b/exercises/bob/BobTests.elm @@ -1,6 +1,9 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest exposing (..) +import Test.Runner.Node exposing (run) +import Json.Encode exposing (Value) +import Test exposing (..) +import Expect import String import Char import Random @@ -9,27 +12,106 @@ import Bob tests : Test tests = - suite "Bob" - [ test "stating something" (assertEqual "Whatever." (Bob.hey "Tom-ay-to, tom-aaaah-to.")) - , test "shouting" (assertEqual "Whoa, chill out!" (Bob.hey "WATCH OUT!")) - , test "shouting gibberish" (assertEqual "Whoa, chill out!" (Bob.hey (uppercaseGibberish 10))) - , test "asking a question" (assertEqual "Sure." (Bob.hey "Does this cryogenic chamber make me look fat?")) - , test "asking a numeric question" (assertEqual "Sure." (Bob.hey "You are, what, like 15?")) - , test "asking gibberish" (assertEqual "Sure." (Bob.hey (gibberishQuestion 20))) - , test "talking forcefully" (assertEqual "Whatever." (Bob.hey "Let's go make out behind the gym!")) - , test "using acronyms in regular speech" (assertEqual "Whatever." (Bob.hey "It's OK if you don't want to go to the DMV.")) - , test "forceful questions" (assertEqual "Whoa, chill out!" (Bob.hey "WHAT THE HELL WERE YOU THINKING?")) - , test "shouting numbers" (assertEqual "Whoa, chill out!" (Bob.hey "1, 2, 3 GO!")) - , test "only numbers" (assertEqual "Whatever." (Bob.hey "1, 2, 3")) - , test "question with only numbers" (assertEqual "Sure." (Bob.hey "4?")) - , test "shouting with special characters" (assertEqual "Whoa, chill out!" (Bob.hey "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!)")) - , test "shouting with no exclamation mark" (assertEqual "Whoa, chill out!" (Bob.hey "I HATE YOU")) - , test "statement containing a question mark" (assertEqual "Whatever." (Bob.hey "Ending with ? means a question.")) - , test "prattling on" (assertEqual "Sure." (Bob.hey "Wait! Hang on. Are you going to be OK?")) - , test "silence" (assertEqual "Fine. Be that way!" (Bob.hey "")) - , test "prolonged silence" (assertEqual "Fine. Be that way!" (Bob.hey " ")) - , test "alternate silences" (assertEqual "Fine. Be that way!" (Bob.hey "\t \n \t ")) - , test "on multiple line questions" (assertEqual "Whatever." (Bob.hey "\nDoes this cryogenic chamber make me look fat?\nno")) + describe "Bob" + [ test "stating something" <| + \() -> + Expect.equal "Whatever." + (Bob.hey "Tom-ay-to, tom-aaaah-to.") + , test "shouting" <| + \() -> + Expect.equal + "Whoa, chill out!" + (Bob.hey "WATCH OUT!") + , test "shouting gibberish" <| + \() -> + Expect.equal + "Whoa, chill out!" + (Bob.hey (uppercaseGibberish 10)) + , test "asking a question" <| + \() -> + Expect.equal + "Sure." + (Bob.hey "Does this cryogenic chamber make me look fat?") + , test "asking a numeric question" <| + \() -> + Expect.equal + "Sure." + (Bob.hey "You are, what, like 15?") + , test "asking gibberish" <| + \() -> + Expect.equal + "Sure." + (Bob.hey (gibberishQuestion 20)) + , test "talking forcefully" <| + \() -> + Expect.equal + "Whatever." + (Bob.hey "Let's go make out behind the gym!") + , test "using acronyms in regular speech" <| + \() -> + Expect.equal + "Whatever." + (Bob.hey "It's OK if you don't want to go to the DMV.") + , test "forceful questions" <| + \() -> + Expect.equal + "Whoa, chill out!" + (Bob.hey "WHAT THE HELL WERE YOU THINKING?") + , test "shouting numbers" <| + \() -> + Expect.equal + "Whoa, chill out!" + (Bob.hey "1, 2, 3 GO!") + , test "only numbers" <| + \() -> + Expect.equal + "Whatever." + (Bob.hey "1, 2, 3") + , test "question with only numbers" <| + \() -> + Expect.equal + "Sure." + (Bob.hey "4?") + , test "shouting with special characters" <| + \() -> + Expect.equal + "Whoa, chill out!" + (Bob.hey "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!)") + , test "shouting with no exclamation mark" <| + \() -> + Expect.equal + "Whoa, chill out!" + (Bob.hey "I HATE YOU") + , test "statement containing a question mark" <| + \() -> + Expect.equal + "Whatever." + (Bob.hey "Ending with ? means a question.") + , test "prattling on" <| + \() -> + Expect.equal + "Sure." + (Bob.hey "Wait! Hang on. Are you going to be OK?") + , test "silence" <| + \() -> + Expect.equal + "Fine. Be that way!" + (Bob.hey "") + , test "prolonged silence" <| + \() -> + Expect.equal + "Fine. Be that way!" + (Bob.hey " ") + , test "alternate silences" <| + \() -> + Expect.equal + "Fine. Be that way!" + (Bob.hey "\t \n \t ") + , test "on multiple line questions" <| + \() -> + Expect.equal + "Whatever." + (Bob.hey "\nDoes this cryogenic chamber make me look fat?\nno") ] @@ -70,4 +152,7 @@ gibberishQuestion length = main : Program Never main = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/bob/elm-package.json b/exercises/bob/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/bob/elm-package.json +++ b/exercises/bob/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/bob/runtests.bat b/exercises/bob/runtests.bat deleted file mode 100755 index 2a38cd8..0000000 --- a/exercises/bob/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/bob/runtests.sh b/exercises/bob/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/bob/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js diff --git a/exercises/difference-of-squares/DifferenceOfSquaresTests.elm b/exercises/difference-of-squares/DifferenceOfSquaresTests.elm index cb3589e..2184b05 100644 --- a/exercises/difference-of-squares/DifferenceOfSquaresTests.elm +++ b/exercises/difference-of-squares/DifferenceOfSquaresTests.elm @@ -1,31 +1,47 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest exposing (..) +import Test.Runner.Node exposing (run) +import Json.Encode exposing (Value) +import Test exposing (..) +import Expect import DifferenceOfSquares exposing (squareOfSum, sumOfSquares, difference) tests : Test tests = - suite "DifferenceOfSquares" - [ suite "square the sum of the numbers up to the given number" - [ test "square of sum 5" (assertEqual 225 (squareOfSum 5)) - , test "square of sum 10" (assertEqual 3025 (squareOfSum 10)) - , test "square of sum 100" (assertEqual 25502500 (squareOfSum 100)) + describe "DifferenceOfSquares" + [ describe "square the sum of the numbers up to the given number" + [ test "square of sum 5" <| + \() -> Expect.equal 225 (squareOfSum 5) + , test "square of sum 10" <| + \() -> Expect.equal 3025 (squareOfSum 10) + , test "square of sum 100" <| + \() -> Expect.equal 25502500 (squareOfSum 100) ] - , suite "sum the squares of the numbers up to the given number" - [ test "sum of squares 5" (assertEqual 55 (sumOfSquares 5)) - , test "sum of squares 10" (assertEqual 385 (sumOfSquares 10)) - , test "sum of squares 100" (assertEqual 338350 (sumOfSquares 100)) + , describe "sum the squares of the numbers up to the given number" + [ test "sum of squares 5" <| + \() -> Expect.equal 55 (sumOfSquares 5) + , test "sum of squares 10" <| + \() -> Expect.equal 385 (sumOfSquares 10) + , test "sum of squares 100" <| + \() -> Expect.equal 338350 (sumOfSquares 100) ] - , suite "subtract sum of squares from square of sums" - [ test "difference of squares 0" (assertEqual 0 (difference 0)) - , test "difference of squares 5" (assertEqual 170 (difference 5)) - , test "difference of squares 10" (assertEqual 2640 (difference 10)) - , test "difference of squares 100" (assertEqual 25164150 (difference 100)) + , describe "subtract sum of squares from square of sums" + [ test "difference of squares 0" <| + \() -> Expect.equal 0 (difference 0) + , test "difference of squares 5" <| + \() -> Expect.equal 170 (difference 5) + , test "difference of squares 10" <| + \() -> Expect.equal 2640 (difference 10) + , test "difference of squares 100" <| + \() -> Expect.equal 25164150 (difference 100) ] ] main : Program Never main = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/difference-of-squares/elm-package.json b/exercises/difference-of-squares/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/difference-of-squares/elm-package.json +++ b/exercises/difference-of-squares/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/difference-of-squares/runtests.bat b/exercises/difference-of-squares/runtests.bat deleted file mode 100755 index 2a38cd8..0000000 --- a/exercises/difference-of-squares/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/difference-of-squares/runtests.sh b/exercises/difference-of-squares/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/difference-of-squares/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js diff --git a/exercises/grade-school/GradeSchoolTests.elm b/exercises/grade-school/GradeSchoolTests.elm index eb99ae4..5ebdb44 100644 --- a/exercises/grade-school/GradeSchoolTests.elm +++ b/exercises/grade-school/GradeSchoolTests.elm @@ -1,63 +1,69 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest exposing (..) +import Test.Runner.Node exposing (run) +import Json.Encode exposing (Value) +import Test exposing (..) +import Expect import GradeSchool exposing (addStudent, studentsInGrade, allStudents) tests : Test tests = - suite "GradeSchool" - [ test "add student" - (assertEqual [ "Aimee" ] - (GradeSchool.empty - |> addStudent 2 "Aimee" - |> studentsInGrade 2 - ) - ) - , test "add more students in same class" - (assertEqual [ "Blair", "James", "Paul" ] - (GradeSchool.empty - |> addStudent 2 "James" - |> addStudent 2 "Blair" - |> addStudent 2 "Paul" - |> studentsInGrade 2 - ) - ) - , test "add students to different grades" - (assertEqual [ [ "Chelsea" ], [ "Logan" ] ] - (let - school = - GradeSchool.empty - |> addStudent 3 "Chelsea" - |> addStudent 7 "Logan" - in - [ studentsInGrade 3 school, studentsInGrade 7 school ] - ) - ) - , test "get students in a grade" - (assertEqual [ "Bradley", "Franklin" ] - (GradeSchool.empty - |> addStudent 5 "Franklin" - |> addStudent 5 "Bradley" - |> addStudent 1 "Jeff" - |> studentsInGrade 5 - ) - ) - , test "get all students in the school" - (assertEqual [ ( 3, [ "Kyle" ] ), ( 4, [ "Christopher", "Jennifer" ] ), ( 6, [ "Kareem" ] ) ] - (GradeSchool.empty - |> addStudent 4 "Jennifer" - |> addStudent 6 "Kareem" - |> addStudent 4 "Christopher" - |> addStudent 3 "Kyle" - |> allStudents - ) - ) - , test "get students in a non-existent grade" - (assertEqual [] (studentsInGrade 1 GradeSchool.empty)) + describe "GradeSchool" + [ test "add student" <| + \() -> + Expect.equal [ "Aimee" ] + (GradeSchool.empty + |> addStudent 2 "Aimee" + |> studentsInGrade 2 + ) + , test "add more students in same class" <| + \() -> + Expect.equal [ "Blair", "James", "Paul" ] + (GradeSchool.empty + |> addStudent 2 "James" + |> addStudent 2 "Blair" + |> addStudent 2 "Paul" + |> studentsInGrade 2 + ) + , test "add students to different grades" <| + \() -> + Expect.equal [ [ "Chelsea" ], [ "Logan" ] ] + (let + school = + GradeSchool.empty + |> addStudent 3 "Chelsea" + |> addStudent 7 "Logan" + in + [ studentsInGrade 3 school, studentsInGrade 7 school ] + ) + , test "get students in a grade" <| + \() -> + Expect.equal [ "Bradley", "Franklin" ] + (GradeSchool.empty + |> addStudent 5 "Franklin" + |> addStudent 5 "Bradley" + |> addStudent 1 "Jeff" + |> studentsInGrade 5 + ) + , test "get all students in the school" <| + \() -> + Expect.equal [ ( 3, [ "Kyle" ] ), ( 4, [ "Christopher", "Jennifer" ] ), ( 6, [ "Kareem" ] ) ] + (GradeSchool.empty + |> addStudent 4 "Jennifer" + |> addStudent 6 "Kareem" + |> addStudent 4 "Christopher" + |> addStudent 3 "Kyle" + |> allStudents + ) + , test "get students in a non-existent grade" <| + \() -> Expect.equal [] (studentsInGrade 1 GradeSchool.empty) ] main : Program Never main = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/grade-school/elm-package.json b/exercises/grade-school/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/grade-school/elm-package.json +++ b/exercises/grade-school/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/grade-school/runtests.bat b/exercises/grade-school/runtests.bat deleted file mode 100755 index 2a38cd8..0000000 --- a/exercises/grade-school/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/grade-school/runtests.sh b/exercises/grade-school/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/grade-school/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js diff --git a/exercises/hamming/HammingTests.elm b/exercises/hamming/HammingTests.elm index 80323b6..4497a5f 100644 --- a/exercises/hamming/HammingTests.elm +++ b/exercises/hamming/HammingTests.elm @@ -1,43 +1,49 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest exposing (..) +import Test.Runner.Node exposing (run) +import Json.Encode exposing (Value) +import Test exposing (..) +import Expect import Hamming exposing (distance) tests : Test tests = - suite "Hamming" - [ test "identical strands" - (assertEqual (Just 0) (distance "A" "A")) - , test "long identical strands" - (assertEqual (Just 0) (distance "GGACTGA" "GGACTGA")) - , test "complete distance in single nucleotide strands" - (assertEqual (Just 1) (distance "A" "G")) - , test "complete distance in small strands" - (assertEqual (Just 2) (distance "AG" "CT")) - , test "small distance in small strands" - (assertEqual (Just 1) (distance "AT" "CT")) - , test "small distance" - (assertEqual (Just 1) (distance "GGACG" "GGTCG")) - , test "small distance in long strands" - (assertEqual (Just 2) (distance "ACCAGGG" "ACTATGG")) - , test "non-unique character in first strand" - (assertEqual (Just 1) (distance "AGA" "AGG")) - , test "non-unique character in second strand" - (assertEqual (Just 1) (distance "AGG" "AGA")) - , test "large distance" - (assertEqual (Just 4) (distance "GATACA" "GCATAA")) - , test "large distance in off-by-one strand" - (assertEqual (Just 9) (distance "GGACGGATTCTG" "AGGACGGATTCT")) - , test "empty strands" - (assertEqual (Just 0) (distance "" "")) - , test "disallow first strand longer" - (assertEqual Nothing (distance "AATG" "AAA")) - , test "disallow second strand longer" - (assertEqual Nothing (distance "ATA" "AGTG")) + describe "Hamming" + [ test "identical strands" <| + \() -> Expect.equal (Just 0) (distance "A" "A") + , test "long identical strands" <| + \() -> Expect.equal (Just 0) (distance "GGACTGA" "GGACTGA") + , test "complete distance in single nucleotide strands" <| + \() -> Expect.equal (Just 1) (distance "A" "G") + , test "complete distance in small strands" <| + \() -> Expect.equal (Just 2) (distance "AG" "CT") + , test "small distance in small strands" <| + \() -> Expect.equal (Just 1) (distance "AT" "CT") + , test "small distance" <| + \() -> Expect.equal (Just 1) (distance "GGACG" "GGTCG") + , test "small distance in long strands" <| + \() -> Expect.equal (Just 2) (distance "ACCAGGG" "ACTATGG") + , test "non-unique character in first strand" <| + \() -> Expect.equal (Just 1) (distance "AGA" "AGG") + , test "non-unique character in second strand" <| + \() -> Expect.equal (Just 1) (distance "AGG" "AGA") + , test "large distance" <| + \() -> Expect.equal (Just 4) (distance "GATACA" "GCATAA") + , test "large distance in off-by-one strand" <| + \() -> Expect.equal (Just 9) (distance "GGACGGATTCTG" "AGGACGGATTCT") + , test "empty strands" <| + \() -> Expect.equal (Just 0) (distance "" "") + , test "disallow first strand longer" <| + \() -> Expect.equal Nothing (distance "AATG" "AAA") + , test "disallow second strand longer" <| + \() -> Expect.equal Nothing (distance "ATA" "AGTG") ] main : Program Never main = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/hamming/elm-package.json b/exercises/hamming/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/hamming/elm-package.json +++ b/exercises/hamming/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/hamming/runtests.bat b/exercises/hamming/runtests.bat deleted file mode 100755 index 2a38cd8..0000000 --- a/exercises/hamming/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/hamming/runtests.sh b/exercises/hamming/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/hamming/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js diff --git a/exercises/hello-world/HelloWorldTests.elm b/exercises/hello-world/HelloWorldTests.elm index 6bb3b1c..01db2f8 100644 --- a/exercises/hello-world/HelloWorldTests.elm +++ b/exercises/hello-world/HelloWorldTests.elm @@ -1,18 +1,30 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest exposing (..) +import Test.Runner.Node exposing (run) +import Json.Encode exposing (Value) +import Test exposing (..) +import Expect import HelloWorld exposing (helloWorld) tests : Test tests = - suite "Hello, World!" - [ test "Hello with no name" (assertEqual "Hello, World!" (helloWorld Nothing)) - , test "Hello to a sample name" (assertEqual "Hello, Alice!" (helloWorld (Just "Alice"))) - , test "Hello to another sample name" (assertEqual "Hello, Bob!" (helloWorld (Just "Bob"))) + describe "Hello, World!" + [ test "Hello with no name" <| + \() -> + Expect.equal "Hello, World!" (helloWorld Nothing) + , test "Hello to a sample name" <| + \() -> + Expect.equal "Hello, Alice!" (helloWorld (Just "Alice")) + , test "Hello to another sample name" <| + \() -> + Expect.equal "Hello, Bob!" (helloWorld (Just "Bob")) ] main : Program Never main = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/hello-world/elm-package.json b/exercises/hello-world/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/hello-world/elm-package.json +++ b/exercises/hello-world/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/hello-world/runtests.bat b/exercises/hello-world/runtests.bat deleted file mode 100755 index 2a38cd8..0000000 --- a/exercises/hello-world/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/hello-world/runtests.sh b/exercises/hello-world/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/hello-world/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js diff --git a/exercises/largest-series-product/LargestSeriesProductTests.elm b/exercises/largest-series-product/LargestSeriesProductTests.elm index 9e9bfaf..18b43be 100644 --- a/exercises/largest-series-product/LargestSeriesProductTests.elm +++ b/exercises/largest-series-product/LargestSeriesProductTests.elm @@ -1,49 +1,55 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest exposing (..) +import Test.Runner.Node exposing (run) +import Json.Encode exposing (Value) +import Test exposing (..) +import Expect import LargestSeriesProduct exposing (largestProduct) tests : Test tests = - suite "largestProduct" - [ test "can find the largest product of 2 with numbers in order" - (assertEqual (Just 72) (largestProduct 2 "0123456789")) - , test "can find the largest product of 2" - (assertEqual (Just 48) (largestProduct 2 "576802143")) - , test "finds the largest product if span equals length" - (assertEqual (Just 18) (largestProduct 2 "29")) - , test "can find the largest product of 3 with numbers in order" - (assertEqual (Just 504) (largestProduct 3 "0123456789")) - , test "can find the largest product of 3" - (assertEqual (Just 270) (largestProduct 3 "1027839564")) - , test "can find the largest product of 5 with numbers in order" - (assertEqual (Just 15120) (largestProduct 5 "0123456789")) - , test "can get the largest product of a big number" - (assertEqual (Just 23520) (largestProduct 6 "73167176531330624919225119674426574742355349194934")) - , test "can get the largest product of a big number II" - (assertEqual (Just 28350) (largestProduct 6 "52677741234314237566414902593461595376319419139427")) - , test "can get the largest product of a big number (Project Euler)" - (assertEqual (Just 23514624000) (largestProduct 13 "7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450")) - , test "reports zero if the only digits are zero" - (assertEqual (Just 0) (largestProduct 2 "0000")) - , test "reports zero if all spans include zero" - (assertEqual (Just 0) (largestProduct 3 "99099")) - , test "rejects span longer than string length" - (assertEqual Nothing (largestProduct 4 "123")) - , test "reports 1 for empty string and empty product (0 span)" - (assertEqual (Just 1) (largestProduct 0 "")) - , test "reports 1 for nonempty string and empty product (0 span)" - (assertEqual (Just 1) (largestProduct 0 "123")) - , test "rejects empty string and nonzero span" - (assertEqual Nothing (largestProduct 1 "")) - , test "rejects invalid character in digits" - (assertEqual Nothing (largestProduct 2 "1234a5")) - , test "rejects negative span" - (assertEqual Nothing (largestProduct -1 "12345")) + describe "largestProduct" + [ test "can find the largest product of 2 with numbers in order" <| + \() -> Expect.equal (Just 72) (largestProduct 2 "0123456789") + , test "can find the largest product of 2" <| + \() -> Expect.equal (Just 48) (largestProduct 2 "576802143") + , test "finds the largest product if span equals length" <| + \() -> Expect.equal (Just 18) (largestProduct 2 "29") + , test "can find the largest product of 3 with numbers in order" <| + \() -> Expect.equal (Just 504) (largestProduct 3 "0123456789") + , test "can find the largest product of 3" <| + \() -> Expect.equal (Just 270) (largestProduct 3 "1027839564") + , test "can find the largest product of 5 with numbers in order" <| + \() -> Expect.equal (Just 15120) (largestProduct 5 "0123456789") + , test "can get the largest product of a big number" <| + \() -> Expect.equal (Just 23520) (largestProduct 6 "73167176531330624919225119674426574742355349194934") + , test "can get the largest product of a big number II" <| + \() -> Expect.equal (Just 28350) (largestProduct 6 "52677741234314237566414902593461595376319419139427") + , test "can get the largest product of a big number (Project Euler)" <| + \() -> Expect.equal (Just 23514624000) (largestProduct 13 "7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450") + , test "reports zero if the only digits are zero" <| + \() -> Expect.equal (Just 0) (largestProduct 2 "0000") + , test "reports zero if all spans include zero" <| + \() -> Expect.equal (Just 0) (largestProduct 3 "99099") + , test "rejects span longer than string length" <| + \() -> Expect.equal Nothing (largestProduct 4 "123") + , test "reports 1 for empty string and empty product (0 span)" <| + \() -> Expect.equal (Just 1) (largestProduct 0 "") + , test "reports 1 for nonempty string and empty product (0 span)" <| + \() -> Expect.equal (Just 1) (largestProduct 0 "123") + , test "rejects empty string and nonzero span" <| + \() -> Expect.equal Nothing (largestProduct 1 "") + , test "rejects invalid character in digits" <| + \() -> Expect.equal Nothing (largestProduct 2 "1234a5") + , test "rejects negative span" <| + \() -> Expect.equal Nothing (largestProduct -1 "12345") ] main : Program Never main = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/largest-series-product/elm-package.json b/exercises/largest-series-product/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/largest-series-product/elm-package.json +++ b/exercises/largest-series-product/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/largest-series-product/runtests.bat b/exercises/largest-series-product/runtests.bat deleted file mode 100755 index 2a38cd8..0000000 --- a/exercises/largest-series-product/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/largest-series-product/runtests.sh b/exercises/largest-series-product/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/largest-series-product/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js diff --git a/exercises/leap/LeapTests.elm b/exercises/leap/LeapTests.elm index 38f7800..dc56b0e 100644 --- a/exercises/leap/LeapTests.elm +++ b/exercises/leap/LeapTests.elm @@ -1,22 +1,35 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest exposing (..) +import Test.Runner.Node exposing (run) +import Json.Encode exposing (Value) +import Test exposing (..) +import Expect import Leap tests : Test tests = - suite "Leap" - [ test "leap year" (assertEqual True (Leap.isLeapYear 1996)) - , test "non-leap year" (assertEqual False (Leap.isLeapYear 1997)) - , test "non-leap even year" (assertEqual False (Leap.isLeapYear 1998)) - , test "century" (assertEqual False (Leap.isLeapYear 1900)) - , test "second century" (assertEqual False (Leap.isLeapYear 1800)) - , test "fourth century" (assertEqual True (Leap.isLeapYear 2400)) - , test "y2k" (assertEqual True (Leap.isLeapYear 2000)) + describe "Leap" + [ test "leap year" <| + \() -> Expect.equal True (Leap.isLeapYear 1996) + , test "non-leap year" <| + \() -> Expect.equal False (Leap.isLeapYear 1997) + , test "non-leap even year" <| + \() -> Expect.equal False (Leap.isLeapYear 1998) + , test "century" <| + \() -> Expect.equal False (Leap.isLeapYear 1900) + , test "second century" <| + \() -> Expect.equal False (Leap.isLeapYear 1800) + , test "fourth century" <| + \() -> Expect.equal True (Leap.isLeapYear 2400) + , test "y2k" <| + \() -> Expect.equal True (Leap.isLeapYear 2000) ] main : Program Never main = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/leap/elm-package.json b/exercises/leap/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/leap/elm-package.json +++ b/exercises/leap/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/leap/runtests.bat b/exercises/leap/runtests.bat deleted file mode 100755 index 2a38cd8..0000000 --- a/exercises/leap/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/leap/runtests.sh b/exercises/leap/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/leap/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js diff --git a/exercises/list-ops/ListOpsTests.elm b/exercises/list-ops/ListOpsTests.elm index 16ffb86..b6398fe 100644 --- a/exercises/list-ops/ListOpsTests.elm +++ b/exercises/list-ops/ListOpsTests.elm @@ -1,55 +1,77 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest exposing (..) +import Test.Runner.Node exposing (run) +import Json.Encode exposing (Value) +import Test exposing (..) +import Expect import ListOps exposing (..) tests : Test tests = - suite "List Ops" - [ suite "length" - [ test "empty list" (assertEqual 0 (length [])) - , test "non-empty list" (assertEqual 4 (length [1..4])) + describe "List Ops" + [ describe "length" + [ test "empty list" <| + \() -> Expect.equal 0 (ListOps.length []) + , test "non-empty list" <| + \() -> Expect.equal 4 (ListOps.length [1..4]) ] - , suite "reverse" - [ test "empty list" (assertEqual [] (reverse [])) - , test "non-empty list" (assertEqual [ 4, 3, 2, 1 ] (reverse [1..4])) + , describe "reverse" + [ test "empty list" <| + \() -> Expect.equal [] (ListOps.reverse []) + , test "non-empty list" <| + \() -> Expect.equal [ 4, 3, 2, 1 ] (ListOps.reverse [1..4]) ] - , suite "map" - [ test "empty list" (assertEqual [] (map ((+) 1) [])) - , test "non-empty list" (assertEqual [2..5] (map ((+) 1) [1..4])) + , describe "map" + [ test "empty list" <| + \() -> Expect.equal [] (ListOps.map ((+) 1) []) + , test "non-empty list" <| + \() -> Expect.equal [2..5] (ListOps.map ((+) 1) [1..4]) ] - , suite "filter" - [ test "empty list" (assertEqual [] (filter (\_ -> True) [])) - , test "non-empty list" - (assertEqual [ 2, 4 ] (filter (\x -> x % 2 == 0) [1..4])) + , describe "filter" + [ test "empty list" <| + \() -> Expect.equal [] (ListOps.filter (\_ -> True) []) + , test "non-empty list" <| + \() -> Expect.equal [ 2, 4 ] (ListOps.filter (\x -> x % 2 == 0) [1..4]) ] - , suite "foldl" - [ test "empty list" (assertEqual 0 (foldl (+) 0 [])) - , test "non-empty list" (assertEqual 10 (foldl (+) 0 [1..4])) - , test "direction" (assertEqual [4,3,2,1] (foldl (::) [] [1..4])) + , describe "foldl" + [ test "empty list" <| + \() -> Expect.equal 0 (ListOps.foldl (+) 0 []) + , test "non-empty list" <| + \() -> Expect.equal 10 (ListOps.foldl (+) 0 [1..4]) + , test "direction" <| + \() -> Expect.equal [ 4, 3, 2, 1 ] (ListOps.foldl (::) [] [1..4]) ] - , suite "foldr" - [ test "empty list" (assertEqual 0 (foldr (+) 0 [])) - , test "non-empty list" (assertEqual 10 (foldr (+) 0 [1..4])) - , test "direction" (assertEqual [1..4] (foldr (::) [] [1..4])) + , describe "foldr" + [ test "empty list" <| + \() -> Expect.equal 0 (ListOps.foldr (+) 0 []) + , test "non-empty list" <| + \() -> Expect.equal 10 (ListOps.foldr (+) 0 [1..4]) + , test "direction" <| + \() -> Expect.equal [1..4] (ListOps.foldr (::) [] [1..4]) ] - , suite "append" - [ test "empty lists" (assertEqual [] (append [] [])) - , test "empty and non-empty lists" - (assertEqual [1..4] (append [] [1..4])) - , test "non-empty and empty lists" - (assertEqual [1..4] (append [1..4] [])) - , test "non-empty lists" (assertEqual [1..8] (append [1..4] [5..8])) + , describe "append" + [ test "empty lists" <| + \() -> Expect.equal [] (ListOps.append [] []) + , test "empty and non-empty lists" <| + \() -> Expect.equal [1..4] (ListOps.append [] [1..4]) + , test "non-empty and empty lists" <| + \() -> Expect.equal [1..4] (ListOps.append [1..4] []) + , test "non-empty lists" <| + \() -> Expect.equal [1..8] (ListOps.append [1..4] [5..8]) ] - , suite "concat" - [ test "empty list" (assertEqual [] (concat [])) - , test "list of lists" - (assertEqual [1..10] (concat [ [1..3], [], [4..7], [8..10] ])) + , describe "concat" + [ test "empty list" <| + \() -> Expect.equal [] (ListOps.concat []) + , test "list of lists" <| + \() -> Expect.equal [1..10] (ListOps.concat [ [1..3], [], [4..7], [8..10] ]) ] ] main : Program Never main = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/list-ops/elm-package.json b/exercises/list-ops/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/list-ops/elm-package.json +++ b/exercises/list-ops/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/list-ops/runtests.bat b/exercises/list-ops/runtests.bat deleted file mode 100755 index 2a38cd8..0000000 --- a/exercises/list-ops/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/list-ops/runtests.sh b/exercises/list-ops/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/list-ops/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js diff --git a/exercises/nucleotide-count/NucleotideCountTests.elm b/exercises/nucleotide-count/NucleotideCountTests.elm index e9a28c8..c666ff1 100644 --- a/exercises/nucleotide-count/NucleotideCountTests.elm +++ b/exercises/nucleotide-count/NucleotideCountTests.elm @@ -1,29 +1,35 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest exposing (..) +import Test.Runner.Node exposing (run) +import Json.Encode exposing (Value) +import Test exposing (..) +import Expect import NucleotideCount exposing (nucleotideCounts, version) tests : Test tests = - suite "NucleotideCount" - [ test "the solution is for the correct version of the test" - (assertEqual 2 version) - , test "empty dna strand has no nucleotides" - (assertEqual { a = 0, t = 0, c = 0, g = 0 } - (nucleotideCounts "") - ) - , test "repetitive-sequence-has-only-guanosine" - (assertEqual { a = 0, t = 0, c = 0, g = 8 } - (nucleotideCounts "GGGGGGGG") - ) - , test "counts all nucleotides" - (assertEqual { a = 20, t = 21, c = 12, g = 17 } - (nucleotideCounts "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC") - ) + describe "NucleotideCount" + [ test "the solution is for the correct version of the test" <| + \() -> Expect.equal 2 version + , test "empty dna strand has no nucleotides" <| + \() -> + Expect.equal { a = 0, t = 0, c = 0, g = 0 } + (nucleotideCounts "") + , test "repetitive-sequence-has-only-guanosine" <| + \() -> + Expect.equal { a = 0, t = 0, c = 0, g = 8 } + (nucleotideCounts "GGGGGGGG") + , test "counts all nucleotides" <| + \() -> + Expect.equal { a = 20, t = 21, c = 12, g = 17 } + (nucleotideCounts "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC") ] main : Program Never main = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/nucleotide-count/elm-package.json b/exercises/nucleotide-count/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/nucleotide-count/elm-package.json +++ b/exercises/nucleotide-count/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/nucleotide-count/runtests.bat b/exercises/nucleotide-count/runtests.bat deleted file mode 100755 index 2a38cd8..0000000 --- a/exercises/nucleotide-count/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/nucleotide-count/runtests.sh b/exercises/nucleotide-count/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/nucleotide-count/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js diff --git a/exercises/pangram/PangramTests.elm b/exercises/pangram/PangramTests.elm index 88d4e6e..3ea0556 100644 --- a/exercises/pangram/PangramTests.elm +++ b/exercises/pangram/PangramTests.elm @@ -1,51 +1,57 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest exposing (..) +import Test.Runner.Node exposing (run) +import Json.Encode exposing (Value) +import Test exposing (..) +import Expect import Pangram exposing (isPangram) tests : Test tests = - suite "Pangram" - [ test "sentence empty" - (assertEqual False - (isPangram "") - ) - , test "pangram with only lower case" - (assertEqual True - (isPangram "the quick brown fox jumps over the lazy dog") - ) - , test "missing character 'x'" - (assertEqual False - (isPangram "a quick movement of the enemy will jeopardize five gunboats") - ) - , test "another missing character 'x'" - (assertEqual False - (isPangram "the quick brown fish jumps over the lazy dog") - ) - , test "pangram with underscores" - (assertEqual True - (isPangram "the_quick_brown_fox_jumps_over_the_lazy_dog") - ) - , test "pangram with numbers" - (assertEqual True - (isPangram "the 1 quick brown fox jumps over the 2 lazy dogs") - ) - , test "missing letters replaced by numbers" - (assertEqual False - (isPangram "7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog") - ) - , test "pangram with mixed case and punctuation" - (assertEqual True - (isPangram "\"Five quacking Zephyrs jolt my wax bed.\"") - ) - , test "pangram with non ascii characters" - (assertEqual True - (isPangram "Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich.") - ) + describe "Pangram" + [ test "sentence empty" <| + \() -> + Expect.equal False + (isPangram "") + , test "pangram with only lower case" <| + \() -> + Expect.equal True + (isPangram "the quick brown fox jumps over the lazy dog") + , test "missing character 'x'" <| + \() -> + Expect.equal False + (isPangram "a quick movement of the enemy will jeopardize five gunboats") + , test "another missing character 'x'" <| + \() -> + Expect.equal False + (isPangram "the quick brown fish jumps over the lazy dog") + , test "pangram with underscores" <| + \() -> + Expect.equal True + (isPangram "the_quick_brown_fox_jumps_over_the_lazy_dog") + , test "pangram with numbers" <| + \() -> + Expect.equal True + (isPangram "the 1 quick brown fox jumps over the 2 lazy dogs") + , test "missing letters replaced by numbers" <| + \() -> + Expect.equal False + (isPangram "7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog") + , test "pangram with mixed case and punctuation" <| + \() -> + Expect.equal True + (isPangram "\"Five quacking Zephyrs jolt my wax bed.\"") + , test "pangram with non ascii characters" <| + \() -> + Expect.equal True + (isPangram "Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich.") ] main : Program Never main = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/pangram/elm-package.json b/exercises/pangram/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/pangram/elm-package.json +++ b/exercises/pangram/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/pangram/runtests.bat b/exercises/pangram/runtests.bat deleted file mode 100755 index 2a38cd8..0000000 --- a/exercises/pangram/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/pangram/runtests.sh b/exercises/pangram/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/pangram/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js diff --git a/exercises/phone-number/PhoneNumberTests.elm b/exercises/phone-number/PhoneNumberTests.elm index a65b68f..6041c9a 100644 --- a/exercises/phone-number/PhoneNumberTests.elm +++ b/exercises/phone-number/PhoneNumberTests.elm @@ -1,39 +1,45 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest exposing (..) +import Test.Runner.Node exposing (run) +import Json.Encode exposing (Value) +import Test exposing (..) +import Expect import PhoneNumber exposing (getNumber, prettyPrint) tests : Test tests = - suite "PhoneNumber" - [ test "cleans number" - (assertEqual (Just "1234567890") (getNumber "(123) 456-7890")) - , test "cleans number with dots" - (assertEqual (Just "1234567890") (getNumber "123.456.7890")) - , test "valid when 11 digits and first is 1" - (assertEqual (Just "1234567890") (getNumber "11234567890")) - , test "invalid when 11 digits" - (assertEqual Nothing (getNumber "21234567890")) - , test "invalid when 9 digits" - (assertEqual Nothing (getNumber "123456789")) - , test "invalid when 12 digits" - (assertEqual Nothing (getNumber "123456789012")) - , test "invalid when empty" - (assertEqual Nothing (getNumber "")) - , test "invalid when no digits present" - (assertEqual Nothing (getNumber " (-) ")) - , test "valid with leading characters" - (assertEqual (Just "1234567890") (getNumber "my number is 123 456 7890")) - , test "valid with trailing characters" - (assertEqual (Just "1234567890") (getNumber "123 456 7890 - bob")) - , test "pretty print" - (assertEqual (Just "(123) 456-7890") (prettyPrint "1234567890")) - , test "pretty print with full us phone number" - (assertEqual (Just "(123) 456-7890") (prettyPrint "11234567890")) + describe "PhoneNumber" + [ test "cleans number" <| + \() -> Expect.equal (Just "1234567890") (getNumber "(123) 456-7890") + , test "cleans number with dots" <| + \() -> Expect.equal (Just "1234567890") (getNumber "123.456.7890") + , test "valid when 11 digits and first is 1" <| + \() -> Expect.equal (Just "1234567890") (getNumber "11234567890") + , test "invalid when 11 digits" <| + \() -> Expect.equal Nothing (getNumber "21234567890") + , test "invalid when 9 digits" <| + \() -> Expect.equal Nothing (getNumber "123456789") + , test "invalid when 12 digits" <| + \() -> Expect.equal Nothing (getNumber "123456789012") + , test "invalid when empty" <| + \() -> Expect.equal Nothing (getNumber "") + , test "invalid when no digits present" <| + \() -> Expect.equal Nothing (getNumber " (-) ") + , test "valid with leading characters" <| + \() -> Expect.equal (Just "1234567890") (getNumber "my number is 123 456 7890") + , test "valid with trailing characters" <| + \() -> Expect.equal (Just "1234567890") (getNumber "123 456 7890 - bob") + , test "pretty print" <| + \() -> Expect.equal (Just "(123) 456-7890") (prettyPrint "1234567890") + , test "pretty print with full us phone number" <| + \() -> Expect.equal (Just "(123) 456-7890") (prettyPrint "11234567890") ] main : Program Never main = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/phone-number/elm-package.json b/exercises/phone-number/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/phone-number/elm-package.json +++ b/exercises/phone-number/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/phone-number/runtests.bat b/exercises/phone-number/runtests.bat deleted file mode 100755 index 2a38cd8..0000000 --- a/exercises/phone-number/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/phone-number/runtests.sh b/exercises/phone-number/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/phone-number/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js diff --git a/exercises/raindrops/RaindropsTests.elm b/exercises/raindrops/RaindropsTests.elm index f2fa478..d8a4462 100644 --- a/exercises/raindrops/RaindropsTests.elm +++ b/exercises/raindrops/RaindropsTests.elm @@ -1,30 +1,51 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest exposing (..) +import Test.Runner.Node exposing (run) +import Json.Encode exposing (Value) +import Test exposing (..) +import Expect import Raindrops exposing (raindrops) tests : Test tests = - suite "Raindrops" - [ test "1" (assertEqual "1" (raindrops 1)) - , test "3" (assertEqual "Pling" (raindrops 3)) - , test "5" (assertEqual "Plang" (raindrops 5)) - , test "7" (assertEqual "Plong" (raindrops 7)) - , test "6" (assertEqual "Pling" (raindrops 6)) - , test "9" (assertEqual "Pling" (raindrops 9)) - , test "10" (assertEqual "Plang" (raindrops 10)) - , test "14" (assertEqual "Plong" (raindrops 14)) - , test "15" (assertEqual "PlingPlang" (raindrops 15)) - , test "21" (assertEqual "PlingPlong" (raindrops 21)) - , test "25" (assertEqual "Plang" (raindrops 25)) - , test "35" (assertEqual "PlangPlong" (raindrops 35)) - , test "49" (assertEqual "Plong" (raindrops 49)) - , test "52" (assertEqual "52" (raindrops 52)) - , test "105" (assertEqual "PlingPlangPlong" (raindrops 105)) + describe "Raindrops" + [ test "1" <| + \() -> Expect.equal "1" (raindrops 1) + , test "3" <| + \() -> Expect.equal "Pling" (raindrops 3) + , test "5" <| + \() -> Expect.equal "Plang" (raindrops 5) + , test "7" <| + \() -> Expect.equal "Plong" (raindrops 7) + , test "6" <| + \() -> Expect.equal "Pling" (raindrops 6) + , test "9" <| + \() -> Expect.equal "Pling" (raindrops 9) + , test "10" <| + \() -> Expect.equal "Plang" (raindrops 10) + , test "14" <| + \() -> Expect.equal "Plong" (raindrops 14) + , test "15" <| + \() -> Expect.equal "PlingPlang" (raindrops 15) + , test "21" <| + \() -> Expect.equal "PlingPlong" (raindrops 21) + , test "25" <| + \() -> Expect.equal "Plang" (raindrops 25) + , test "35" <| + \() -> Expect.equal "PlangPlong" (raindrops 35) + , test "49" <| + \() -> Expect.equal "Plong" (raindrops 49) + , test "52" <| + \() -> Expect.equal "52" (raindrops 52) + , test "105" <| + \() -> Expect.equal "PlingPlangPlong" (raindrops 105) ] main : Program Never main = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/raindrops/elm-package.json b/exercises/raindrops/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/raindrops/elm-package.json +++ b/exercises/raindrops/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/raindrops/runtests.bat b/exercises/raindrops/runtests.bat deleted file mode 100755 index 2a38cd8..0000000 --- a/exercises/raindrops/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/raindrops/runtests.sh b/exercises/raindrops/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/raindrops/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js diff --git a/exercises/rna-transcription/RNATranscriptionTests.elm b/exercises/rna-transcription/RNATranscriptionTests.elm index e0cf6bd..3576f97 100644 --- a/exercises/rna-transcription/RNATranscriptionTests.elm +++ b/exercises/rna-transcription/RNATranscriptionTests.elm @@ -1,29 +1,35 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest exposing (..) +import Test.Runner.Node exposing (run) +import Json.Encode exposing (Value) +import Test exposing (..) +import Expect import RNATranscription exposing (toRNA) tests : Test tests = - suite "RNATranscription" - [ test "complement of cytosine is guanine" - (assertEqual (Ok "G") (toRNA "C")) - , test "complement of guanine is cytosine" - (assertEqual (Ok "C") (toRNA "G")) - , test "complement of thymine is adenine" - (assertEqual (Ok "A") (toRNA "T")) - , test "complement of adenine is uracil" - (assertEqual (Ok "U") (toRNA "A")) - , test "complement" - (assertEqual (Ok "UGCACCAGAAUU") (toRNA "ACGTGGTCTTAA")) - , test "correctly handles completely invalid input" - (assertEqual (Err 'X') (toRNA "XXX")) - , test "correctly handles partially invalid input" - (assertEqual (Err 'U') (toRNA "UGAAXXXGACAUG")) + describe "RNATranscription" + [ test "complement of cytosine is guanine" <| + \() -> Expect.equal (Ok "G") (toRNA "C") + , test "complement of guanine is cytosine" <| + \() -> Expect.equal (Ok "C") (toRNA "G") + , test "complement of thymine is adenine" <| + \() -> Expect.equal (Ok "A") (toRNA "T") + , test "complement of adenine is uracil" <| + \() -> Expect.equal (Ok "U") (toRNA "A") + , test "complement" <| + \() -> Expect.equal (Ok "UGCACCAGAAUU") (toRNA "ACGTGGTCTTAA") + , test "correctly handles completely invalid input" <| + \() -> Expect.equal (Err 'X') (toRNA "XXX") + , test "correctly handles partially invalid input" <| + \() -> Expect.equal (Err 'U') (toRNA "UGAAXXXGACAUG") ] main : Program Never main = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/rna-transcription/elm-package.json b/exercises/rna-transcription/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/rna-transcription/elm-package.json +++ b/exercises/rna-transcription/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/rna-transcription/runtests.bat b/exercises/rna-transcription/runtests.bat deleted file mode 100755 index 2a38cd8..0000000 --- a/exercises/rna-transcription/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/rna-transcription/runtests.sh b/exercises/rna-transcription/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/rna-transcription/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js diff --git a/exercises/robot-simulator/RobotSimulatorTests.elm b/exercises/robot-simulator/RobotSimulatorTests.elm index b0b8ad1..ec2a205 100644 --- a/exercises/robot-simulator/RobotSimulatorTests.elm +++ b/exercises/robot-simulator/RobotSimulatorTests.elm @@ -1,117 +1,150 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest exposing (..) +import Test.Runner.Node exposing (run) +import Json.Encode exposing (Value) +import Test exposing (..) +import Expect import RobotSimulator exposing (defaultRobot, Robot, Bearing(North, East, West, South), turnRight, turnLeft, advance, simulate) tests : Test tests = - suite "RobotSimulator" - [ suite "init" + describe "RobotSimulator" + [ describe "init" (let robot = defaultRobot in - [ test "coordinates" (assertEqual { x = 0, y = 0 } robot.coordinates) - , test "bearing" (assertEqual North robot.bearing) + [ test "coordinates" <| + \() -> Expect.equal { x = 0, y = 0 } robot.coordinates + , test "bearing" <| + \() -> Expect.equal North robot.bearing ] ) - , suite "setup" + , describe "setup" (let robot = Robot South { x = -1, y = 1 } in - [ test "coordinates" (assertEqual { x = -1, y = 1 } robot.coordinates) - , test "bearing" (assertEqual South robot.bearing) + [ test "coordinates" <| + \() -> Expect.equal { x = -1, y = 1 } robot.coordinates + , test "bearing" <| + \() -> Expect.equal South robot.bearing ] ) - , suite "turn right" + , describe "turn right" ([1..3] |> List.scanl (\_ r -> turnRight r) defaultRobot |> List.map .bearing |> assertionList [ North, East, South, West ] - |> List.map defaultTest + |> List.indexedMap (\i e -> test ("step " ++ toString i) (\() -> e)) ) - , suite "turn left" + , describe + "turn left" ([1..3] |> List.scanl (\_ r -> turnLeft r) defaultRobot |> List.map .bearing |> assertionList [ North, West, South, East ] - |> List.map defaultTest + |> List.indexedMap (\i e -> test ("step " ++ toString i) (\() -> e)) ) - , suite "advance positive north" + , describe "advance positive north" (let robot = Robot North { x = 0, y = 0 } |> advance in - [ test "coordinates" (assertEqual { x = 0, y = 1 } robot.coordinates) - , test "bearing" (assertEqual North robot.bearing) + [ test "coordinates" <| + \() -> Expect.equal { x = 0, y = 1 } robot.coordinates + , test "bearing" <| + \() -> Expect.equal North robot.bearing ] ) - , suite "advance positive east" + , describe "advance positive east" (let robot = Robot East { x = 0, y = 0 } |> advance in - [ test "coordinates" (assertEqual { x = 1, y = 0 } robot.coordinates) - , test "bearing" (assertEqual East robot.bearing) + [ test "coordinates" <| + \() -> Expect.equal { x = 1, y = 0 } robot.coordinates + , test "bearing" <| + \() -> Expect.equal East robot.bearing ] ) - , suite "advance negative south" + , describe "advance negative south" (let robot = Robot South { x = 0, y = 0 } |> advance in - [ test "coordinates" (assertEqual { x = 0, y = -1 } robot.coordinates) - , test "bearing" (assertEqual South robot.bearing) + [ test "coordinates" <| + \() -> Expect.equal { x = 0, y = -1 } robot.coordinates + , test "bearing" <| + \() -> Expect.equal South robot.bearing ] ) - , suite "advance positive west" + , describe "advance positive west" (let robot = Robot West { x = 0, y = 0 } |> advance in - [ test "coordinates" (assertEqual { x = -1, y = 0 } robot.coordinates) - , test "bearing" (assertEqual West robot.bearing) + [ test "coordinates" <| + \() -> Expect.equal { x = -1, y = 0 } robot.coordinates + , test "bearing" <| + \() -> Expect.equal West robot.bearing ] ) - , suite "simulate prog 1" + , describe "simulate prog 1" (let robot = Robot North { x = 0, y = 0 } |> simulate "LAAARALA" in - [ test "coordinates" (assertEqual { x = -4, y = 1 } robot.coordinates) - , test "bearing" (assertEqual West robot.bearing) + [ test "coordinates" <| + \() -> Expect.equal { x = -4, y = 1 } robot.coordinates + , test "bearing" <| + \() -> Expect.equal West robot.bearing ] ) - , suite "simulate prog 2" + , describe "simulate prog 2" (let robot = Robot East { x = 2, y = -7 } |> simulate "RRAAAAALA" in - [ test "coordinates" (assertEqual { x = -3, y = -8 } robot.coordinates) - , test "bearing" (assertEqual South robot.bearing) + [ test "coordinates" <| + \() -> Expect.equal { x = -3, y = -8 } robot.coordinates + , test "bearing" <| + \() -> Expect.equal South robot.bearing ] ) - , suite "simulate prog 3" + , describe "simulate prog 3" (let robot = Robot South { x = 8, y = 4 } |> simulate "LAAARRRALLLL" in - [ test "coordinates" (assertEqual { x = 11, y = 5 } robot.coordinates) - , test "bearing" (assertEqual North robot.bearing) + [ test "coordinates" <| + \() -> Expect.equal { x = 11, y = 5 } robot.coordinates + , test "bearing" <| + \() -> Expect.equal North robot.bearing ] ) ] +{-| Given a list of values and another list of expected values, +generate a list of Assert Equal assertions. +-} +assertionList : List a -> List a -> List Expect.Expectation +assertionList xs ys = + List.map2 Expect.equal xs ys + + main : Program Never main = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/robot-simulator/elm-package.json b/exercises/robot-simulator/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/robot-simulator/elm-package.json +++ b/exercises/robot-simulator/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/robot-simulator/runtests.bat b/exercises/robot-simulator/runtests.bat deleted file mode 100755 index 2a38cd8..0000000 --- a/exercises/robot-simulator/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/robot-simulator/runtests.sh b/exercises/robot-simulator/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/robot-simulator/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js diff --git a/exercises/roman-numerals/RomanNumerals.example b/exercises/roman-numerals/RomanNumerals.example index 4c42efb..ebc555c 100644 --- a/exercises/roman-numerals/RomanNumerals.example +++ b/exercises/roman-numerals/RomanNumerals.example @@ -6,41 +6,45 @@ import Maybe toRoman : Int -> String toRoman number = - if number == 0 then - "" - else - let - part = largestFactor number - letter = - numerals - |> Dict.get part - |> Maybe.withDefault "" - in - letter ++ (toRoman (number - part)) + if number == 0 then + "" + else + let + part = + largestFactor number + + letter = + numerals + |> Dict.get part + |> Maybe.withDefault "" + in + letter ++ (toRoman (number - part)) + largestFactor : Int -> Int largestFactor number = - numerals - |> Dict.keys - |> List.filter (\p -> p <= number) - |> List.reverse - |> List.head - |> Maybe.withDefault 0 + numerals + |> Dict.keys + |> List.filter (\p -> p <= number) + |> List.reverse + |> List.head + |> Maybe.withDefault 0 numerals : Dict.Dict Int String -numerals = Dict.fromList [ - (1000, "M"), - ( 900, "CM"), - ( 500, "D"), - ( 400, "CD"), - ( 100, "C"), - ( 90, "XC"), - ( 50, "L"), - ( 40, "XL"), - ( 10, "X"), - ( 9, "IX"), - ( 5, "V"), - ( 4, "IV"), - ( 1, "I") - ] +numerals = + Dict.fromList + [ ( 1000, "M" ) + , ( 900, "CM" ) + , ( 500, "D" ) + , ( 400, "CD" ) + , ( 100, "C" ) + , ( 90, "XC" ) + , ( 50, "L" ) + , ( 40, "XL" ) + , ( 10, "X" ) + , ( 9, "IX" ) + , ( 5, "V" ) + , ( 4, "IV" ) + , ( 1, "I" ) + ] diff --git a/exercises/roman-numerals/RomanNumeralsTests.elm b/exercises/roman-numerals/RomanNumeralsTests.elm index ed68abc..07f9750 100644 --- a/exercises/roman-numerals/RomanNumeralsTests.elm +++ b/exercises/roman-numerals/RomanNumeralsTests.elm @@ -1,86 +1,93 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest exposing (..) +import Test.Runner.Node exposing (run) +import Json.Encode exposing (Value) +import Test exposing (..) +import Expect import RomanNumerals exposing (toRoman) tests : Test tests = - suite "Roman Numerals" - [ test "1" - (assertEqual ("I") - (toRoman 1) - ) - , test "2" - (assertEqual ("II") - (toRoman 2) - ) - , test "3" - (assertEqual ("III") - (toRoman 3) - ) - , test "4" - (assertEqual ("IV") - (toRoman 4) - ) - , test "5" - (assertEqual ("V") - (toRoman 5) - ) - , test "6" - (assertEqual ("VI") - (toRoman 6) - ) - , test "9" - (assertEqual ("IX") - (toRoman 9) - ) - , test "27" - (assertEqual ("XXVII") - (toRoman 27) - ) - , test "48" - (assertEqual ("XLVIII") - (toRoman 48) - ) - , test "59" - (assertEqual ("LIX") - (toRoman 59) - ) - , test "93" - (assertEqual ("XCIII") - (toRoman 93) - ) - , test "141" - (assertEqual ("CXLI") - (toRoman 141) - ) - , test "163" - (assertEqual ("CLXIII") - (toRoman 163) - ) - , test "402" - (assertEqual ("CDII") - (toRoman 402) - ) - , test "575" - (assertEqual ("DLXXV") - (toRoman 575) - ) - , test "911" - (assertEqual ("CMXI") - (toRoman 911) - ) - , test "1024" - (assertEqual ("MXXIV") - (toRoman 1024) - ) - , test "3000" - (assertEqual ("MMM") - (toRoman 3000) - ) + describe "Roman Numerals" + [ test "1" <| + \() -> + Expect.equal ("I") + (toRoman 1) + , test "2" <| + \() -> + Expect.equal ("II") + (toRoman 2) + , test "3" <| + \() -> + Expect.equal ("III") + (toRoman 3) + , test "4" <| + \() -> + Expect.equal ("IV") + (toRoman 4) + , test "5" <| + \() -> + Expect.equal ("V") + (toRoman 5) + , test "6" <| + \() -> + Expect.equal ("VI") + (toRoman 6) + , test "9" <| + \() -> + Expect.equal ("IX") + (toRoman 9) + , test "27" <| + \() -> + Expect.equal ("XXVII") + (toRoman 27) + , test "48" <| + \() -> + Expect.equal ("XLVIII") + (toRoman 48) + , test "59" <| + \() -> + Expect.equal ("LIX") + (toRoman 59) + , test "93" <| + \() -> + Expect.equal ("XCIII") + (toRoman 93) + , test "141" <| + \() -> + Expect.equal ("CXLI") + (toRoman 141) + , test "163" <| + \() -> + Expect.equal ("CLXIII") + (toRoman 163) + , test "402" <| + \() -> + Expect.equal ("CDII") + (toRoman 402) + , test "575" <| + \() -> + Expect.equal ("DLXXV") + (toRoman 575) + , test "911" <| + \() -> + Expect.equal ("CMXI") + (toRoman 911) + , test "1024" <| + \() -> + Expect.equal ("MXXIV") + (toRoman 1024) + , test "3000" <| + \() -> + Expect.equal ("MMM") + (toRoman 3000) ] + main : Program Never main = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/roman-numerals/elm-package.json b/exercises/roman-numerals/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/roman-numerals/elm-package.json +++ b/exercises/roman-numerals/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/roman-numerals/runtests.bat b/exercises/roman-numerals/runtests.bat deleted file mode 100644 index 2a38cd8..0000000 --- a/exercises/roman-numerals/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/roman-numerals/runtests.sh b/exercises/roman-numerals/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/roman-numerals/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js diff --git a/exercises/run-length-encoding/RunLengthEncodingTests.elm b/exercises/run-length-encoding/RunLengthEncodingTests.elm index 2850a74..13ffe38 100644 --- a/exercises/run-length-encoding/RunLengthEncodingTests.elm +++ b/exercises/run-length-encoding/RunLengthEncodingTests.elm @@ -1,41 +1,47 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest 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 = - suite "RunLengthEncoding" - [ test "the solution is for the correct version of the test" - (assertEqual 2 version) - , test "encode simple" - (assertEqual "2A3B4C" (encode "AABBBCCCC")) - , test "decode simple" - (assertEqual "AABBBCCCC" (decode "2A3B4C")) - , test "encode with single values" - (assertEqual "12WB12W3B24WB" - (encode "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB") - ) - , test "decode with single values" - (assertEqual "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB" - (decode "12WB12W3B24WB") - ) - , test "(decode (encode (...)) combination" - (assertEqual "zzz ZZ zZ" - (decode (encode "zzz ZZ zZ")) - ) - , test "decode with a x10 value" - (assertEqual "WWWWWWWWWW" - (decode "10W") - ) - , test "encode unicode" - (assertEqual "⏰3⚽2⭐⏰" (encode "⏰⚽⚽⚽⭐⭐⏰")) - , test "decode unicode" - (assertEqual "⏰⚽⚽⚽⭐⭐⏰" (decode "⏰3⚽2⭐⏰")) + 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 = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/run-length-encoding/elm-package.json b/exercises/run-length-encoding/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/run-length-encoding/elm-package.json +++ b/exercises/run-length-encoding/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/run-length-encoding/runtests.bat b/exercises/run-length-encoding/runtests.bat deleted file mode 100755 index 2a38cd8..0000000 --- a/exercises/run-length-encoding/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/run-length-encoding/runtests.sh b/exercises/run-length-encoding/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/run-length-encoding/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js diff --git a/exercises/say/SayTests.elm b/exercises/say/SayTests.elm index fac1a49..8f969f8 100644 --- a/exercises/say/SayTests.elm +++ b/exercises/say/SayTests.elm @@ -1,90 +1,96 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest exposing (..) +import Test.Runner.Node exposing (run) +import Json.Encode exposing (Value) +import Test exposing (..) +import Expect import Say exposing (say, SayError(Negative, TooLarge)) tests : Test tests = - suite "Series" - [ test "one" - (assertEqual (Ok "one") - (say 1) - ) - , test "fourteen" - (assertEqual (Ok "fourteen") - (say 14) - ) - , test "twenty" - (assertEqual (Ok "twenty") - (say 20) - ) - , test "twenty-two" - (assertEqual (Ok "twenty-two") - (say 22) - ) - , test "one hundred" - (assertEqual (Ok "one hundred") - (say 100) - ) - , test "one hundred twenty" - (assertEqual (Ok "one hundred and twenty") - (say 120) - ) - , test "one hundred twenty-three" - (assertEqual (Ok "one hundred and twenty-three") - (say 123) - ) - , test "one thousand" - (assertEqual (Ok "one thousand") - (say 1000) - ) - , test "one thousand two hundred thirty-four" - (assertEqual (Ok "one thousand two hundred and thirty-four") - (say 1234) - ) - , test "one million" - (assertEqual (Ok "one million") - (say 1000000) - ) - , test "one million two" - (assertEqual (Ok "one million and two") - (say 1000002) - ) - , test "1002345" - (assertEqual (Ok "one million two thousand three hundred and forty-five") - (say 1002345) - ) - , test "one billion" - (assertEqual (Ok "one billion") - (say 1000000000) - ) - , test "number too large" - (assertEqual (Err TooLarge) - (say 10000000000000000) - ) - , test "negative number" - (assertEqual (Err Negative) - (say -42) - ) - , test "zero" - (assertEqual (Ok "zero") - (say 0) - ) - , test "987654321123" - (assertEqual - (Ok - ("nine hundred and eighty-seven billion " - ++ "six hundred and fifty-four million " - ++ "three hundred and twenty-one thousand " - ++ "one hundred and twenty-three" + describe "Series" + [ test "one" <| + \() -> + Expect.equal (Ok "one") + (say 1) + , test "fourteen" <| + \() -> + Expect.equal (Ok "fourteen") + (say 14) + , test "twenty" <| + \() -> + Expect.equal (Ok "twenty") + (say 20) + , test "twenty-two" <| + \() -> + Expect.equal (Ok "twenty-two") + (say 22) + , test "one hundred" <| + \() -> + Expect.equal (Ok "one hundred") + (say 100) + , test "one hundred twenty" <| + \() -> + Expect.equal (Ok "one hundred and twenty") + (say 120) + , test "one hundred twenty-three" <| + \() -> + Expect.equal (Ok "one hundred and twenty-three") + (say 123) + , test "one thousand" <| + \() -> + Expect.equal (Ok "one thousand") + (say 1000) + , test "one thousand two hundred thirty-four" <| + \() -> + Expect.equal (Ok "one thousand two hundred and thirty-four") + (say 1234) + , test "one million" <| + \() -> + Expect.equal (Ok "one million") + (say 1000000) + , test "one million two" <| + \() -> + Expect.equal (Ok "one million and two") + (say 1000002) + , test "1002345" <| + \() -> + Expect.equal (Ok "one million two thousand three hundred and forty-five") + (say 1002345) + , test "one billion" <| + \() -> + Expect.equal (Ok "one billion") + (say 1000000000) + , test "number too large" <| + \() -> + Expect.equal (Err TooLarge) + (say 10000000000000000) + , test "negative number" <| + \() -> + Expect.equal (Err Negative) + (say -42) + , test "zero" <| + \() -> + Expect.equal (Ok "zero") + (say 0) + , test "987654321123" <| + \() -> + Expect.equal + (Ok + ("nine hundred and eighty-seven billion " + ++ "six hundred and fifty-four million " + ++ "three hundred and twenty-one thousand " + ++ "one hundred and twenty-three" + ) ) - ) - (say 987654321123) - ) + (say 987654321123) ] main : Program Never main = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/say/elm-package.json b/exercises/say/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/say/elm-package.json +++ b/exercises/say/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/say/runtests.bat b/exercises/say/runtests.bat deleted file mode 100755 index 2a38cd8..0000000 --- a/exercises/say/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/say/runtests.sh b/exercises/say/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/say/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js diff --git a/exercises/series/SeriesTests.elm b/exercises/series/SeriesTests.elm index ccc132b..00d08b4 100644 --- a/exercises/series/SeriesTests.elm +++ b/exercises/series/SeriesTests.elm @@ -1,47 +1,53 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest exposing (..) +import Test.Runner.Node exposing (run) +import Json.Encode exposing (Value) +import Test exposing (..) +import Expect import Series exposing (slices) tests : Test tests = - suite "Series" - [ test "slices of one" - (assertEqual (Ok [ [ 0 ], [ 1 ], [ 2 ], [ 3 ], [ 4 ] ]) - (slices 1 "01234") - ) - , test "slices of two" - (assertEqual (Ok [ [ 9, 7 ], [ 7, 8 ], [ 8, 6 ], [ 6, 7 ], [ 7, 5 ], [ 5, 6 ], [ 6, 4 ] ]) - (slices 2 "97867564") - ) - , test "slices of three" - (assertEqual (Ok [ [ 9, 7, 8 ], [ 7, 8, 6 ], [ 8, 6, 7 ], [ 6, 7, 5 ], [ 7, 5, 6 ], [ 5, 6, 4 ] ]) - (slices 3 "97867564") - ) - , test "slices of four" - (assertEqual (Ok [ [ 0, 1, 2, 3 ], [ 1, 2, 3, 4 ] ]) - (slices 4 "01234") - ) - , test "slices of five" - (assertEqual (Ok [ [ 0, 1, 2, 3, 4 ] ]) - (slices 5 "01234") - ) - , test "overly long slice" - (assertEqual (Ok []) - (slices 4 "012") - ) - , test "overly short slice" - (assertEqual (Err ("Invalid size: 0")) - (slices 0 "01234") - ) - , test "input has non numbers" - (assertEqual (Err "could not convert string 'a' to an Int") - (slices 2 "0123abc") - ) + describe "Series" + [ test "slices of one" <| + \() -> + Expect.equal (Ok [ [ 0 ], [ 1 ], [ 2 ], [ 3 ], [ 4 ] ]) + (slices 1 "01234") + , test "slices of two" <| + \() -> + Expect.equal (Ok [ [ 9, 7 ], [ 7, 8 ], [ 8, 6 ], [ 6, 7 ], [ 7, 5 ], [ 5, 6 ], [ 6, 4 ] ]) + (slices 2 "97867564") + , test "slices of three" <| + \() -> + Expect.equal (Ok [ [ 9, 7, 8 ], [ 7, 8, 6 ], [ 8, 6, 7 ], [ 6, 7, 5 ], [ 7, 5, 6 ], [ 5, 6, 4 ] ]) + (slices 3 "97867564") + , test "slices of four" <| + \() -> + Expect.equal (Ok [ [ 0, 1, 2, 3 ], [ 1, 2, 3, 4 ] ]) + (slices 4 "01234") + , test "slices of five" <| + \() -> + Expect.equal (Ok [ [ 0, 1, 2, 3, 4 ] ]) + (slices 5 "01234") + , test "overly long slice" <| + \() -> + Expect.equal (Ok []) + (slices 4 "012") + , test "overly short slice" <| + \() -> + Expect.equal (Err ("Invalid size: 0")) + (slices 0 "01234") + , test "input has non numbers" <| + \() -> + Expect.equal (Err "could not convert string 'a' to an Int") + (slices 2 "0123abc") ] main : Program Never main = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/series/elm-package.json b/exercises/series/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/series/elm-package.json +++ b/exercises/series/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/series/runtests.bat b/exercises/series/runtests.bat deleted file mode 100755 index 2a38cd8..0000000 --- a/exercises/series/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/series/runtests.sh b/exercises/series/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/series/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js diff --git a/exercises/space-age/SpaceAgeTests.elm b/exercises/space-age/SpaceAgeTests.elm index a320403..311a6fb 100644 --- a/exercises/space-age/SpaceAgeTests.elm +++ b/exercises/space-age/SpaceAgeTests.elm @@ -1,31 +1,37 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest exposing (..) +import Test.Runner.Node exposing (run) +import Json.Encode exposing (Value) +import Test exposing (..) +import Expect import SpaceAge exposing (Planet(..), ageOn) tests : Test tests = - suite "SpaceAge" - [ test "age in earth years" - (assertEqual 32 (round (ageOn Earth 1000000000))) - , test "age in mercury years" - (assertEqual 281 (round (ageOn Mercury 2134835688))) - , test "age in venus years" - (assertEqual 10 (round (ageOn Venus 189839836))) - , test "age on mars" - (assertEqual 39 (round (ageOn Mars 2329871239))) - , test "age on jupiter" - (assertEqual 2 (round (ageOn Jupiter 901876382))) - , test "age on saturn" - (assertEqual 3 (round (ageOn Saturn 3000000000))) - , test "age on uranus" - (assertEqual 1 (round (ageOn Uranus 3210123456))) - , test "age on neptune" - (assertEqual 2 (round (ageOn Neptune 8210123456))) + describe "SpaceAge" + [ test "age in earth years" <| + \() -> Expect.equal 32 (round (ageOn Earth 1000000000)) + , test "age in mercury years" <| + \() -> Expect.equal 281 (round (ageOn Mercury 2134835688)) + , test "age in venus years" <| + \() -> Expect.equal 10 (round (ageOn Venus 189839836)) + , test "age on mars" <| + \() -> Expect.equal 39 (round (ageOn Mars 2329871239)) + , test "age on jupiter" <| + \() -> Expect.equal 2 (round (ageOn Jupiter 901876382)) + , test "age on saturn" <| + \() -> Expect.equal 3 (round (ageOn Saturn 3000000000)) + , test "age on uranus" <| + \() -> Expect.equal 1 (round (ageOn Uranus 3210123456)) + , test "age on neptune" <| + \() -> Expect.equal 2 (round (ageOn Neptune 8210123456)) ] main : Program Never main = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/space-age/elm-package.json b/exercises/space-age/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/space-age/elm-package.json +++ b/exercises/space-age/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/space-age/runtests.bat b/exercises/space-age/runtests.bat deleted file mode 100755 index 2a38cd8..0000000 --- a/exercises/space-age/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/space-age/runtests.sh b/exercises/space-age/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/space-age/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js diff --git a/exercises/strain/StrainTests.elm b/exercises/strain/StrainTests.elm index 88f887e..037cb10 100644 --- a/exercises/strain/StrainTests.elm +++ b/exercises/strain/StrainTests.elm @@ -1,6 +1,9 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest exposing (..) +import Test.Runner.Node exposing (run) +import Json.Encode exposing (Value) +import Test exposing (..) +import Expect import Strain exposing (keep, discard) import String @@ -27,58 +30,61 @@ lessThanTen num = tests : Test tests = - suite "Strain" - [ test "empty keep" - (assertEqual [] - (keep lessThanTen []) - ) - , test "keep everything" - (assertEqual [ 1, 2, 3 ] - (keep lessThanTen [ 1, 2, 3 ]) - ) - , test "keep first and last" - (assertEqual [ 1, 3 ] - (keep odd [ 1, 2, 3 ]) - ) - , test "keep nothing" - (assertEqual [] - (keep even [ 1, 3, 5, 7 ]) - ) - , test "keep neither first nor last" - (assertEqual [ 2 ] - (keep even [ 1, 2, 3 ]) - ) - , test "keep strings" - (assertEqual [ "zebra", "zombies", "zealot" ] - (keep (isFirstLetter "z") [ "apple", "zebra", "banana", "zombies", "cherimoya", "zealot" ]) - ) - , test "empty discard" - (assertEqual [] - (discard lessThanTen []) - ) - , test "discard everything" - (assertEqual [] - (discard lessThanTen [ 1, 2, 3 ]) - ) - , test "discard first and last" - (assertEqual [ 2 ] - (discard odd [ 1, 2, 3 ]) - ) - , test "discard nothing" - (assertEqual [ 1, 3, 5, 7 ] - (discard even [ 1, 3, 5, 7 ]) - ) - , test "discard neither first nor last" - (assertEqual [ 1, 3 ] - (discard even [ 1, 2, 3 ]) - ) - , test "discard strings" - (assertEqual [ "apple", "banana", "cherimoya" ] - (discard (isFirstLetter "z") [ "apple", "zebra", "banana", "zombies", "cherimoya", "zealot" ]) - ) + describe "Strain" + [ test "empty keep" <| + \() -> + Expect.equal [] + (keep lessThanTen []) + , test "keep everything" <| + \() -> + Expect.equal [ 1, 2, 3 ] + (keep lessThanTen [ 1, 2, 3 ]) + , test "keep first and last" <| + \() -> + Expect.equal [ 1, 3 ] + (keep odd [ 1, 2, 3 ]) + , test "keep nothing" <| + \() -> + Expect.equal [] + (keep even [ 1, 3, 5, 7 ]) + , test "keep neither first nor last" <| + \() -> + Expect.equal [ 2 ] + (keep even [ 1, 2, 3 ]) + , test "keep strings" <| + \() -> + Expect.equal [ "zebra", "zombies", "zealot" ] + (keep (isFirstLetter "z") [ "apple", "zebra", "banana", "zombies", "cherimoya", "zealot" ]) + , test "empty discard" <| + \() -> + Expect.equal [] + (discard lessThanTen []) + , test "discard everything" <| + \() -> + Expect.equal [] + (discard lessThanTen [ 1, 2, 3 ]) + , test "discard first and last" <| + \() -> + Expect.equal [ 2 ] + (discard odd [ 1, 2, 3 ]) + , test "discard nothing" <| + \() -> + Expect.equal [ 1, 3, 5, 7 ] + (discard even [ 1, 3, 5, 7 ]) + , test "discard neither first nor last" <| + \() -> + Expect.equal [ 1, 3 ] + (discard even [ 1, 2, 3 ]) + , test "discard strings" <| + \() -> + Expect.equal [ "apple", "banana", "cherimoya" ] + (discard (isFirstLetter "z") [ "apple", "zebra", "banana", "zombies", "cherimoya", "zealot" ]) ] main : Program Never main = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/strain/elm-package.json b/exercises/strain/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/strain/elm-package.json +++ b/exercises/strain/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/strain/runtests.bat b/exercises/strain/runtests.bat deleted file mode 100755 index 2a38cd8..0000000 --- a/exercises/strain/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/strain/runtests.sh b/exercises/strain/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/strain/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js diff --git a/exercises/sublist/SublistTests.elm b/exercises/sublist/SublistTests.elm index b11f5e2..33c2abc 100644 --- a/exercises/sublist/SublistTests.elm +++ b/exercises/sublist/SublistTests.elm @@ -1,53 +1,59 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest exposing (..) +import Test.Runner.Node exposing (run) +import Json.Encode exposing (Value) +import Test exposing (..) +import Expect import Sublist exposing (version, sublist, ListComparison(..)) tests : Test tests = - suite "Sublist" - [ test "the solution is for the correct version of the test" - (assertEqual 2 version) - , test "empty equals empty" - (assertEqual Equal (sublist [] [])) - , test "empty is a sublist of anything" - (assertEqual Sublist (sublist [] [ 1, 2 ])) - , test "anything is a superlist of empty" - (assertEqual Superlist (sublist [ 1, 2 ] [])) - , test "1 is not 2" - (assertEqual Unequal (sublist [ 1 ] [ 2 ])) - , test "compare larger equal lists" - (assertEqual Equal (sublist [ 1, 1, 1 ] [ 1, 1, 1 ])) - , test "sublist at start" - (assertEqual Sublist (sublist [ 1, 2, 3 ] [ 1, 2, 3, 4, 5 ])) - , test "sublist in the middle" - (assertEqual Sublist (sublist [ 4, 3, 2 ] [ 5, 4, 3, 2, 1 ])) - , test "sublist at end" - (assertEqual Sublist (sublist [ 3, 4, 5 ] [ 1, 2, 3, 4, 5 ])) - , test "partially matching sublist at start" - (assertEqual Sublist (sublist [ 1, 1, 2 ] [ 1, 1, 1, 2 ])) - , test "sublist early in huge list" - (assertEqual Sublist (sublist [ 3, 4, 5 ] [1..100000])) - , test "huge sublist not in list" - (assertEqual Unequal (sublist [10..5001] [1..5000])) - , test "superlist at start" - (assertEqual Superlist (sublist [ 1, 2, 3, 4, 5 ] [ 1, 2, 3 ])) - , test "superlist in middle" - (assertEqual Superlist (sublist [ 5, 4, 3, 2, 1 ] [ 4, 3, 2 ])) - , test "superlist at end" - (assertEqual Superlist (sublist [ 1, 2, 3, 4, 5 ] [ 3, 4, 5 ])) - , test "partially matching superlist at start" - (assertEqual Superlist (sublist [ 1, 1, 1, 2 ] [ 1, 1, 2 ])) - , test "superlist early in huge list" - (assertEqual Superlist (sublist [1..100000] [ 3, 4, 5 ])) - , test "recurring values sublist" - (assertEqual Sublist (sublist [ 1, 2, 1, 2, 3 ] [ 1, 2, 3, 1, 2, 1, 2, 3, 2, 1 ])) - , test "recurring values unequal" - (assertEqual Unequal (sublist [ 1, 2, 1, 2, 3 ] [ 1, 2, 3, 1, 2, 3, 2, 3, 2, 1 ])) + describe "Sublist" + [ test "the solution is for the correct version of the test" <| + \() -> Expect.equal 2 version + , test "empty equals empty" <| + \() -> Expect.equal Equal (sublist [] []) + , test "empty is a sublist of anything" <| + \() -> Expect.equal Sublist (sublist [] [ 1, 2 ]) + , test "anything is a superlist of empty" <| + \() -> Expect.equal Superlist (sublist [ 1, 2 ] []) + , test "1 is not 2" <| + \() -> Expect.equal Unequal (sublist [ 1 ] [ 2 ]) + , test "compare larger equal lists" <| + \() -> Expect.equal Equal (sublist [ 1, 1, 1 ] [ 1, 1, 1 ]) + , test "sublist at start" <| + \() -> Expect.equal Sublist (sublist [ 1, 2, 3 ] [ 1, 2, 3, 4, 5 ]) + , test "sublist in the middle" <| + \() -> Expect.equal Sublist (sublist [ 4, 3, 2 ] [ 5, 4, 3, 2, 1 ]) + , test "sublist at end" <| + \() -> Expect.equal Sublist (sublist [ 3, 4, 5 ] [ 1, 2, 3, 4, 5 ]) + , test "partially matching sublist at start" <| + \() -> Expect.equal Sublist (sublist [ 1, 1, 2 ] [ 1, 1, 1, 2 ]) + , test "sublist early in huge list" <| + \() -> Expect.equal Sublist (sublist [ 3, 4, 5 ] [1..100000]) + , test "huge sublist not in list" <| + \() -> Expect.equal Unequal (sublist [10..5001] [1..5000]) + , test "superlist at start" <| + \() -> Expect.equal Superlist (sublist [ 1, 2, 3, 4, 5 ] [ 1, 2, 3 ]) + , test "superlist in middle" <| + \() -> Expect.equal Superlist (sublist [ 5, 4, 3, 2, 1 ] [ 4, 3, 2 ]) + , test "superlist at end" <| + \() -> Expect.equal Superlist (sublist [ 1, 2, 3, 4, 5 ] [ 3, 4, 5 ]) + , test "partially matching superlist at start" <| + \() -> Expect.equal Superlist (sublist [ 1, 1, 1, 2 ] [ 1, 1, 2 ]) + , test "superlist early in huge list" <| + \() -> Expect.equal Superlist (sublist [1..100000] [ 3, 4, 5 ]) + , test "recurring values sublist" <| + \() -> Expect.equal Sublist (sublist [ 1, 2, 1, 2, 3 ] [ 1, 2, 3, 1, 2, 1, 2, 3, 2, 1 ]) + , test "recurring values unequal" <| + \() -> Expect.equal Unequal (sublist [ 1, 2, 1, 2, 3 ] [ 1, 2, 3, 1, 2, 3, 2, 3, 2, 1 ]) ] main : Program Never main = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/sublist/elm-package.json b/exercises/sublist/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/sublist/elm-package.json +++ b/exercises/sublist/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/sublist/runtests.bat b/exercises/sublist/runtests.bat deleted file mode 100755 index 2a38cd8..0000000 --- a/exercises/sublist/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/sublist/runtests.sh b/exercises/sublist/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/sublist/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js diff --git a/exercises/sum-of-multiples/SumOfMultiplesTests.elm b/exercises/sum-of-multiples/SumOfMultiplesTests.elm index eda1f1f..f3bedf0 100644 --- a/exercises/sum-of-multiples/SumOfMultiplesTests.elm +++ b/exercises/sum-of-multiples/SumOfMultiplesTests.elm @@ -1,21 +1,33 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest exposing (..) +import Test.Runner.Node exposing (run) +import Json.Encode exposing (Value) +import Test exposing (..) +import Expect import SumOfMultiples exposing (sumOfMultiples) tests : Test tests = - suite "Sum Of Multiples" - [ test "[3, 5] 15" (assertEqual 45 (sumOfMultiples [ 3, 5 ] 15)) - , test "[7, 13, 17] 20" (assertEqual 51 (sumOfMultiples [ 7, 13, 17 ] 20)) - , test "[4, 6] 15" (assertEqual 30 (sumOfMultiples [ 4, 6 ] 15)) - , test "[5, 6, 8] 150" (assertEqual 4419 (sumOfMultiples [ 5, 6, 8 ] 150)) - , test "[43, 47] 10000" (assertEqual 2203160 (sumOfMultiples [ 43, 47 ] 10000)) - , test "[5, 25] 51" (assertEqual 275 (sumOfMultiples [ 5, 25 ] 51)) + describe "Sum Of Multiples" + [ test "[3, 5] 15" <| + \() -> Expect.equal 45 (sumOfMultiples [ 3, 5 ] 15) + , test "[7, 13, 17] 20" <| + \() -> Expect.equal 51 (sumOfMultiples [ 7, 13, 17 ] 20) + , test "[4, 6] 15" <| + \() -> Expect.equal 30 (sumOfMultiples [ 4, 6 ] 15) + , test "[5, 6, 8] 150" <| + \() -> Expect.equal 4419 (sumOfMultiples [ 5, 6, 8 ] 150) + , test "[43, 47] 10000" <| + \() -> Expect.equal 2203160 (sumOfMultiples [ 43, 47 ] 10000) + , test "[5, 25] 51" <| + \() -> Expect.equal 275 (sumOfMultiples [ 5, 25 ] 51) ] main : Program Never main = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/sum-of-multiples/elm-package.json b/exercises/sum-of-multiples/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/sum-of-multiples/elm-package.json +++ b/exercises/sum-of-multiples/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/sum-of-multiples/runtests.bat b/exercises/sum-of-multiples/runtests.bat deleted file mode 100755 index 2a38cd8..0000000 --- a/exercises/sum-of-multiples/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/sum-of-multiples/runtests.sh b/exercises/sum-of-multiples/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/sum-of-multiples/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js diff --git a/exercises/triangle/TriangleTests.elm b/exercises/triangle/TriangleTests.elm index 5b745b7..8ab6468 100644 --- a/exercises/triangle/TriangleTests.elm +++ b/exercises/triangle/TriangleTests.elm @@ -1,47 +1,51 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest exposing (..) -import Triangle exposing (..) +import Test.Runner.Node exposing (run) +import Json.Encode exposing (Value) +import Test exposing (..) +import Expect +import Triangle exposing (triangleKind, Triangle(..)) tests : Test tests = - suite "triangleKind" - [ test "the solution is for the correct version of the test" - (assertEqual 2 version) - , test "equilateral triangles have equal sides" - (assertEqual (Ok Equilateral) (triangleKind 2 2 2)) - , test "larger equilateral triangles also have equal sides" - (assertEqual (Ok Equilateral) (triangleKind 10 10 10)) - , test "isosceles triangles have last two sides equal" - (assertEqual (Ok Isosceles) (triangleKind 3 4 4)) - , test "isosceles triangles have first and last sides equal" - (assertEqual (Ok Isosceles) (triangleKind 4 3 4)) - , test "isosceles triangles have two first sides equal" - (assertEqual (Ok Isosceles) (triangleKind 4 4 3)) - , test "isosceles triangles have in fact exactly two sides equal" - (assertEqual (Ok Isosceles) (triangleKind 10 10 2)) - , test "scalene triangles have no equal sides" - (assertEqual (Ok Scalene) (triangleKind 3 4 5)) - , test "scalene triangles have no equal sides at a larger scale too" - (assertEqual (Ok Scalene) (triangleKind 10 11 12)) - , test "scalene triangles have no equal sides at a larger scale too 2" - (assertEqual (Ok Scalene) (triangleKind 5 4 2)) - , test "very small triangles are legal" - (assertEqual (Ok Scalene) (triangleKind 0.4 0.6 0.3)) - , test "triangles with no size are illegal" - (assertEqual (Err "Invalid lengths") (triangleKind 0 0 0)) - , test "triangles with negative sides are illegal" - (assertEqual (Err "Invalid lengths") (triangleKind 3 4 -5)) - , test "triangles violating triangle inequality are illegal 1" - (assertEqual (Err "Violates inequality") (triangleKind 1 1 3)) - , test "triangles violating triangle inequality are illegal 2" - (assertEqual (Err "Violates inequality") (triangleKind 2 4 2)) - , test "triangles violating triangle inequality are illegal 3" - (assertEqual (Err "Violates inequality") (triangleKind 7 3 2)) + describe "triangleKind" + [ test "equilateral triangles have equal sides" <| + \() -> Expect.equal (Ok Equilateral) (triangleKind 2 2 2) + , test "larger equilateral triangles also have equal sides" <| + \() -> Expect.equal (Ok Equilateral) (triangleKind 10 10 10) + , test "isosceles triangles have last two sides equal" <| + \() -> Expect.equal (Ok Isosceles) (triangleKind 3 4 4) + , test "isosceles triangles have first and last sides equal" <| + \() -> Expect.equal (Ok Isosceles) (triangleKind 4 3 4) + , test "isosceles triangles have two first sides equal" <| + \() -> Expect.equal (Ok Isosceles) (triangleKind 4 4 3) + , test "isosceles triangles have in fact exactly two sides equal" <| + \() -> Expect.equal (Ok Isosceles) (triangleKind 10 10 2) + , test "scalene triangles have no equal sides" <| + \() -> Expect.equal (Ok Scalene) (triangleKind 3 4 5) + , test "scalene triangles have no equal sides at a larger scale too" <| + \() -> Expect.equal (Ok Scalene) (triangleKind 10 11 12) + , test "scalene triangles have no equal sides at a larger scale too 2" <| + \() -> Expect.equal (Ok Scalene) (triangleKind 5 4 2) + , test "very small triangles are legal" <| + \() -> Expect.equal (Ok Scalene) (triangleKind 0.4 0.6 0.3) + , test "triangles with no size are illegal" <| + \() -> Expect.equal (Err "Invalid lengths") (triangleKind 0 0 0) + , test "triangles with negative sides are illegal" <| + \() -> Expect.equal (Err "Invalid lengths") (triangleKind 3 4 -5) + , test "triangles violating triangle inequality are illegal 1" <| + \() -> Expect.equal (Err "Violates inequality") (triangleKind 1 1 3) + , test "triangles violating triangle inequality are illegal 2" <| + \() -> Expect.equal (Err "Violates inequality") (triangleKind 2 4 2) + , test "triangles violating triangle inequality are illegal 3" <| + \() -> Expect.equal (Err "Violates inequality") (triangleKind 7 3 2) ] main : Program Never main = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/triangle/elm-package.json b/exercises/triangle/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/triangle/elm-package.json +++ b/exercises/triangle/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/triangle/runtests.bat b/exercises/triangle/runtests.bat deleted file mode 100755 index 2a38cd8..0000000 --- a/exercises/triangle/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/triangle/runtests.sh b/exercises/triangle/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/triangle/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js diff --git a/exercises/word-count/WordCountTests.elm b/exercises/word-count/WordCountTests.elm index 3099418..262549a 100644 --- a/exercises/word-count/WordCountTests.elm +++ b/exercises/word-count/WordCountTests.elm @@ -1,40 +1,46 @@ -module Main exposing (..) +port module Main exposing (..) -import ElmTest exposing (..) +import Test.Runner.Node exposing (run) +import Json.Encode exposing (Value) +import Test exposing (..) +import Expect import Dict exposing (Dict) import WordCount exposing (wordCount) tests : Test tests = - suite "Word Count" - [ test "count one word" - (assertEqual [ ( "word", 1 ) ] - (wordCount "word" |> Dict.toList) - ) - , test "count one of each word" - (assertEqual [ ( "each", 1 ), ( "of", 1 ), ( "one", 1 ) ] - (wordCount "one of each" |> Dict.toList) - ) - , test "multiple occurrences of a word" - (assertEqual [ ( "blue", 1 ), ( "fish", 4 ), ( "one", 1 ), ( "red", 1 ), ( "two", 1 ) ] - (wordCount "one fish two fish red fish blue fish" |> Dict.toList) - ) - , test "ignore punctuation" - (assertEqual [ ( "as", 1 ), ( "car", 1 ), ( "carpet", 1 ), ( "java", 1 ), ( "javascript", 1 ) ] - (wordCount "car : carpet as java : javascript!!&@$%^&" |> Dict.toList) - ) - , test "include numbers" - (assertEqual [ ( "1", 1 ), ( "2", 1 ), ( "testing", 2 ) ] - (wordCount "testing, 1, 2 testing" |> Dict.toList) - ) - , test "normalize case" - (assertEqual [ ( "go", 3 ), ( "stop", 2 ) ] - (wordCount "go Go GO Stop stop" |> Dict.toList) - ) + describe "Word Count" + [ test "count one word" <| + \() -> + Expect.equal [ ( "word", 1 ) ] + (wordCount "word" |> Dict.toList) + , test "count one of each word" <| + \() -> + Expect.equal [ ( "each", 1 ), ( "of", 1 ), ( "one", 1 ) ] + (wordCount "one of each" |> Dict.toList) + , test "multiple occurrences of a word" <| + \() -> + Expect.equal [ ( "blue", 1 ), ( "fish", 4 ), ( "one", 1 ), ( "red", 1 ), ( "two", 1 ) ] + (wordCount "one fish two fish red fish blue fish" |> Dict.toList) + , test "ignore punctuation" <| + \() -> + Expect.equal [ ( "as", 1 ), ( "car", 1 ), ( "carpet", 1 ), ( "java", 1 ), ( "javascript", 1 ) ] + (wordCount "car : carpet as java : javascript!!&@$%^&" |> Dict.toList) + , test "include numbers" <| + \() -> + Expect.equal [ ( "1", 1 ), ( "2", 1 ), ( "testing", 2 ) ] + (wordCount "testing, 1, 2 testing" |> Dict.toList) + , test "normalize case" <| + \() -> + Expect.equal [ ( "go", 3 ), ( "stop", 2 ) ] + (wordCount "go Go GO Stop stop" |> Dict.toList) ] main : Program Never main = - runSuite tests + run emit tests + + +port emit : ( String, Value ) -> Cmd msg diff --git a/exercises/word-count/elm-package.json b/exercises/word-count/elm-package.json index 1ab2bdf..d8a672c 100644 --- a/exercises/word-count/elm-package.json +++ b/exercises/word-count/elm-package.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "3.0.0", "summary": "Exercism problems in Elm.", "repository": "https://github.com/exercism/xelm.git", "license": "BSD3", @@ -8,8 +8,9 @@ ], "exposed-modules": [], "dependencies": { - "elm-community/elm-test": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0" + "elm-lang/core": "4.0.0 <= v < 5.0.0", + "elm-community/elm-test": "2.0.0 <= v < 3.0.0", + "rtfeldman/node-test-runner": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.17.0 <= v < 0.18.0" } diff --git a/exercises/word-count/runtests.bat b/exercises/word-count/runtests.bat deleted file mode 100755 index 2a38cd8..0000000 --- a/exercises/word-count/runtests.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -for %%f in (*Tests.elm) do ( - elm-make %%f --yes --output build.js && node build.js -) diff --git a/exercises/word-count/runtests.sh b/exercises/word-count/runtests.sh deleted file mode 100755 index 2bed7b2..0000000 --- a/exercises/word-count/runtests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -elm-make *Tests.elm --yes --output build.js && node build.js