diff --git a/.gitignore b/.gitignore index 982f393..31e01d8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ .DS_Store bin/configlet bin/configlet.exe +elm-stuff CHECKLIST diff --git a/.travis.yml b/.travis.yml index eba5d7e..9ca85d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,17 @@ --- language: bash + + +sudo: false + +install: + - nvm install 0.12 + - nvm use 0.12 + - npm install -g elm@0.16.0 + - elm package install -y + - npm install elm-test + script: -- bin/fetch-configlet -- bin/configlet . + - bin/fetch-configlet + - bin/configlet . + - bin/build.sh diff --git a/TestRunner.elm b/TestRunner.elm new file mode 100644 index 0000000..0baa6f2 --- /dev/null +++ b/TestRunner.elm @@ -0,0 +1,15 @@ +module Main where + +import Signal exposing (Signal) + +import ElmTest exposing (consoleRunner) +import Console exposing (IO, run) +import Task + +import Tests + +console : IO () +console = consoleRunner Tests.all + +port runner : Signal (Task.Task x ()) +port runner = run console diff --git a/bin/build.sh b/bin/build.sh new file mode 100755 index 0000000..1625a86 --- /dev/null +++ b/bin/build.sh @@ -0,0 +1,13 @@ +for example_file in exercises/**/*.example +do + exercise_dir=$(dirname $example_file) + exercise=$(basename $example_file .example) + echo 'setting up .....' + mv "$exercise_dir/$exercise.elm" "$exercise_dir/$exercise.impl" + mv "$exercise_dir/$exercise.example" "$exercise_dir/$exercise.elm" + echo 'building .....' + elm-test exercises/**/*Tests.elm + echo 'tearing down .....' + mv "$exercise_dir/$exercise.elm" "$exercise_dir/$exercise.example" + mv "$exercise_dir/$exercise.impl" "$exercise_dir/$exercise.elm" +done diff --git a/config.json b/config.json index 3fb1036..2fbc5d1 100644 --- a/config.json +++ b/config.json @@ -5,13 +5,15 @@ "active": false, "test_pattern": "TODO", "problems": [ - + "hello_world" ], "deprecated": [ ], "ignored": [ "bin", + "elm-stuff", + "node_modules", "docs" ], "foregone": [ diff --git a/elm-package.json b/elm-package.json new file mode 100644 index 0000000..840b849 --- /dev/null +++ b/elm-package.json @@ -0,0 +1,17 @@ +{ + "version": "1.0.0", + "summary": "Exercism problems in Elm.", + "repository": "https://github.com/exercism/xelm.git", + "license": "BSD3", + "source-directories": [ + ".", + "./exercises/hello_world" + ], + "exposed-modules": [], + "dependencies": { + "deadfoxygrandpa/elm-test": "3.0.1 <= v < 4.0.0", + "elm-lang/core": "2.0.0 <= v < 4.0.0", + "laszlopandy/elm-console": "1.1.0 <= v < 2.0.0" + }, + "elm-version": "0.15.0 <= v < 0.17.0" +} diff --git a/exercises/hello_world/HelloWorld.elm b/exercises/hello_world/HelloWorld.elm new file mode 100644 index 0000000..498ce36 --- /dev/null +++ b/exercises/hello_world/HelloWorld.elm @@ -0,0 +1 @@ +module HelloWorld where diff --git a/exercises/hello_world/HelloWorld.example b/exercises/hello_world/HelloWorld.example new file mode 100644 index 0000000..c1c95c8 --- /dev/null +++ b/exercises/hello_world/HelloWorld.example @@ -0,0 +1,9 @@ +module HelloWorld where + +helloworld : Maybe String -> String +helloworld name = + case name of + Just name -> + "Hello, " ++ name ++ "!" + Nothing -> + "Hello, World!" diff --git a/exercises/hello_world/HelloWorldTests.elm b/exercises/hello_world/HelloWorldTests.elm new file mode 100644 index 0000000..85876fd --- /dev/null +++ b/exercises/hello_world/HelloWorldTests.elm @@ -0,0 +1,20 @@ +import String +import Task + +import Console +import ElmTest exposing (..) +import HelloWorld exposing (..) + + +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"))) + ] + + +port runner : Signal (Task.Task x ()) +port runner = + Console.run (consoleRunner tests)