mirror of
https://github.com/correl/elm.git
synced 2024-11-15 19:19:31 +00:00
Setup Hello World and top level testing
This commit is contained in:
parent
d518a9b629
commit
8c8481fb8f
9 changed files with 93 additions and 3 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,4 +2,5 @@
|
|||
.DS_Store
|
||||
bin/configlet
|
||||
bin/configlet.exe
|
||||
elm-stuff
|
||||
CHECKLIST
|
||||
|
|
16
.travis.yml
16
.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
|
||||
|
|
15
TestRunner.elm
Normal file
15
TestRunner.elm
Normal file
|
@ -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
|
13
bin/build.sh
Executable file
13
bin/build.sh
Executable file
|
@ -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
|
|
@ -5,13 +5,15 @@
|
|||
"active": false,
|
||||
"test_pattern": "TODO",
|
||||
"problems": [
|
||||
|
||||
"hello_world"
|
||||
],
|
||||
"deprecated": [
|
||||
|
||||
],
|
||||
"ignored": [
|
||||
"bin",
|
||||
"elm-stuff",
|
||||
"node_modules",
|
||||
"docs"
|
||||
],
|
||||
"foregone": [
|
||||
|
|
17
elm-package.json
Normal file
17
elm-package.json
Normal file
|
@ -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"
|
||||
}
|
1
exercises/hello_world/HelloWorld.elm
Normal file
1
exercises/hello_world/HelloWorld.elm
Normal file
|
@ -0,0 +1 @@
|
|||
module HelloWorld where
|
9
exercises/hello_world/HelloWorld.example
Normal file
9
exercises/hello_world/HelloWorld.example
Normal file
|
@ -0,0 +1,9 @@
|
|||
module HelloWorld where
|
||||
|
||||
helloworld : Maybe String -> String
|
||||
helloworld name =
|
||||
case name of
|
||||
Just name ->
|
||||
"Hello, " ++ name ++ "!"
|
||||
Nothing ->
|
||||
"Hello, World!"
|
20
exercises/hello_world/HelloWorldTests.elm
Normal file
20
exercises/hello_world/HelloWorldTests.elm
Normal file
|
@ -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)
|
Loading…
Reference in a new issue