From 03d20b5005786619773f4925195406a006935316 Mon Sep 17 00:00:00 2001 From: Jay Hayes Date: Wed, 5 Jul 2017 06:22:37 -0500 Subject: [PATCH 1/3] Add "watch" command to all exercises --- README.md | 2 ++ docs/EXERCISE_README_INSERT.md | 6 ++++++ docs/TESTS.md | 8 ++++++++ exercises/accumulate/package.json | 1 + exercises/allergies/package.json | 1 + exercises/anagram/package.json | 1 + exercises/atbash-cipher/package.json | 1 + exercises/bob/package.json | 1 + exercises/difference-of-squares/package.json | 1 + exercises/gigasecond/package.json | 1 + exercises/grade-school/package.json | 1 + exercises/grains/package.json | 1 + exercises/hamming/package.json | 1 + exercises/hello-world/package.json | 1 + exercises/largest-series-product/package.json | 1 + exercises/leap/package.json | 1 + exercises/list-ops/package.json | 1 + exercises/nucleotide-count/package.json | 1 + exercises/pangram/package.json | 1 + exercises/phone-number/package.json | 1 + exercises/raindrops/package.json | 1 + exercises/rna-transcription/package.json | 1 + exercises/robot-simulator/package.json | 1 + exercises/roman-numerals/package.json | 1 + exercises/run-length-encoding/package.json | 1 + exercises/say/package.json | 1 + exercises/scrabble-score/package.json | 1 + exercises/series/package.json | 1 + exercises/space-age/package.json | 1 + exercises/strain/package.json | 1 + exercises/sublist/package.json | 1 + exercises/sum-of-multiples/package.json | 1 + exercises/triangle/package.json | 1 + exercises/word-count/package.json | 1 + 34 files changed, 47 insertions(+) diff --git a/README.md b/README.md index dd947b3..3cec77b 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,8 @@ Please keep the following in mind: - The recommended workflow when working on an exercise is to first create the implementation and test files, `ExerciseModuleName.elm` and `tests/Tests.elm`. You'll likely want to copy one of the existing exercise directories as a quick start. - Test the new exercise directly by running `npm test` from the exercise directory. + - Automatically run tests again when you save changes by running `npm run watch` from the exercise directory. + - Once the implementation of the exercise is complete, rename `ExerciseModuleName.elm` to `ExerciseModuleName.example.elm` and create the template `ExerciseModuleName.elm`. - Make sure everything is good to go by running all tests with `bin/build.sh`. diff --git a/docs/EXERCISE_README_INSERT.md b/docs/EXERCISE_README_INSERT.md index 83aa8f9..7ed1d5a 100644 --- a/docs/EXERCISE_README_INSERT.md +++ b/docs/EXERCISE_README_INSERT.md @@ -17,3 +17,9 @@ Execute the tests with: ```bash $ npm test ``` + +Automatically run tests again when you save changes: + +```bash +$ npm run watch +``` diff --git a/docs/TESTS.md b/docs/TESTS.md index 137d327..fd93a46 100644 --- a/docs/TESTS.md +++ b/docs/TESTS.md @@ -8,6 +8,14 @@ $ npm test ## Hints and tips +### Watch for changes + +Automatically run tests again when you save changes: + +```bash +$ npm run watch +``` + ### Coding the exercise The README.md for each exercise gives a general description, but the Elm test program will be very specific. Open the test program and give it a quick look - if it seems like cheating, do it anyway. Look for helpful comments, test data, and just the names of the test functions. Try running the test command before you have written anything and see if the error messages give you an idea of where to start. diff --git a/exercises/accumulate/package.json b/exercises/accumulate/package.json index c469874..31d6fb3 100644 --- a/exercises/accumulate/package.json +++ b/exercises/accumulate/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/allergies/package.json b/exercises/allergies/package.json index c469874..31d6fb3 100644 --- a/exercises/allergies/package.json +++ b/exercises/allergies/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/anagram/package.json b/exercises/anagram/package.json index c469874..31d6fb3 100644 --- a/exercises/anagram/package.json +++ b/exercises/anagram/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/atbash-cipher/package.json b/exercises/atbash-cipher/package.json index c469874..31d6fb3 100644 --- a/exercises/atbash-cipher/package.json +++ b/exercises/atbash-cipher/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/bob/package.json b/exercises/bob/package.json index c469874..31d6fb3 100644 --- a/exercises/bob/package.json +++ b/exercises/bob/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/difference-of-squares/package.json b/exercises/difference-of-squares/package.json index c469874..31d6fb3 100644 --- a/exercises/difference-of-squares/package.json +++ b/exercises/difference-of-squares/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/gigasecond/package.json b/exercises/gigasecond/package.json index c469874..31d6fb3 100644 --- a/exercises/gigasecond/package.json +++ b/exercises/gigasecond/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/grade-school/package.json b/exercises/grade-school/package.json index c469874..31d6fb3 100644 --- a/exercises/grade-school/package.json +++ b/exercises/grade-school/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/grains/package.json b/exercises/grains/package.json index c469874..31d6fb3 100644 --- a/exercises/grains/package.json +++ b/exercises/grains/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/hamming/package.json b/exercises/hamming/package.json index c469874..31d6fb3 100644 --- a/exercises/hamming/package.json +++ b/exercises/hamming/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/hello-world/package.json b/exercises/hello-world/package.json index c469874..31d6fb3 100644 --- a/exercises/hello-world/package.json +++ b/exercises/hello-world/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/largest-series-product/package.json b/exercises/largest-series-product/package.json index c469874..31d6fb3 100644 --- a/exercises/largest-series-product/package.json +++ b/exercises/largest-series-product/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/leap/package.json b/exercises/leap/package.json index c469874..31d6fb3 100644 --- a/exercises/leap/package.json +++ b/exercises/leap/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/list-ops/package.json b/exercises/list-ops/package.json index c469874..31d6fb3 100644 --- a/exercises/list-ops/package.json +++ b/exercises/list-ops/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/nucleotide-count/package.json b/exercises/nucleotide-count/package.json index c469874..31d6fb3 100644 --- a/exercises/nucleotide-count/package.json +++ b/exercises/nucleotide-count/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/pangram/package.json b/exercises/pangram/package.json index c469874..31d6fb3 100644 --- a/exercises/pangram/package.json +++ b/exercises/pangram/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/phone-number/package.json b/exercises/phone-number/package.json index c469874..31d6fb3 100644 --- a/exercises/phone-number/package.json +++ b/exercises/phone-number/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/raindrops/package.json b/exercises/raindrops/package.json index c469874..31d6fb3 100644 --- a/exercises/raindrops/package.json +++ b/exercises/raindrops/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/rna-transcription/package.json b/exercises/rna-transcription/package.json index c469874..31d6fb3 100644 --- a/exercises/rna-transcription/package.json +++ b/exercises/rna-transcription/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/robot-simulator/package.json b/exercises/robot-simulator/package.json index c469874..31d6fb3 100644 --- a/exercises/robot-simulator/package.json +++ b/exercises/robot-simulator/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/roman-numerals/package.json b/exercises/roman-numerals/package.json index c469874..31d6fb3 100644 --- a/exercises/roman-numerals/package.json +++ b/exercises/roman-numerals/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/run-length-encoding/package.json b/exercises/run-length-encoding/package.json index c469874..31d6fb3 100644 --- a/exercises/run-length-encoding/package.json +++ b/exercises/run-length-encoding/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/say/package.json b/exercises/say/package.json index c469874..31d6fb3 100644 --- a/exercises/say/package.json +++ b/exercises/say/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/scrabble-score/package.json b/exercises/scrabble-score/package.json index c469874..31d6fb3 100644 --- a/exercises/scrabble-score/package.json +++ b/exercises/scrabble-score/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/series/package.json b/exercises/series/package.json index c469874..31d6fb3 100644 --- a/exercises/series/package.json +++ b/exercises/series/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/space-age/package.json b/exercises/space-age/package.json index c469874..31d6fb3 100644 --- a/exercises/space-age/package.json +++ b/exercises/space-age/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/strain/package.json b/exercises/strain/package.json index c469874..31d6fb3 100644 --- a/exercises/strain/package.json +++ b/exercises/strain/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/sublist/package.json b/exercises/sublist/package.json index c469874..31d6fb3 100644 --- a/exercises/sublist/package.json +++ b/exercises/sublist/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/sum-of-multiples/package.json b/exercises/sum-of-multiples/package.json index c469874..31d6fb3 100644 --- a/exercises/sum-of-multiples/package.json +++ b/exercises/sum-of-multiples/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/triangle/package.json b/exercises/triangle/package.json index c469874..31d6fb3 100644 --- a/exercises/triangle/package.json +++ b/exercises/triangle/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { diff --git a/exercises/word-count/package.json b/exercises/word-count/package.json index c469874..31d6fb3 100644 --- a/exercises/word-count/package.json +++ b/exercises/word-count/package.json @@ -4,6 +4,7 @@ "license": "MIT", "scripts": { "postinstall": "elm-package install -y", + "watch": "elm-test --watch", "test": "elm-test" }, "dependencies": { From 183847554f716a3a77ce1b8a802c2ec5e28fdb58 Mon Sep 17 00:00:00 2001 From: Jay Hayes Date: Thu, 6 Jul 2017 07:19:14 -0500 Subject: [PATCH 2/3] Add version test to triangle exercise This follows the pattern set by some of the other exercises. --- exercises/triangle/tests/Tests.elm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/exercises/triangle/tests/Tests.elm b/exercises/triangle/tests/Tests.elm index 861d60e..9c4842e 100644 --- a/exercises/triangle/tests/Tests.elm +++ b/exercises/triangle/tests/Tests.elm @@ -8,7 +8,9 @@ import Triangle exposing (triangleKind, Triangle(..)) tests : Test tests = describe "triangleKind" - [ test "equilateral triangles have equal sides" <| + [ test "the solution is for the correct version of the test" <| + \() -> Expect.equal 2 version + , 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) From fff2196a6df65888cf53268c379e47c7579915b2 Mon Sep 17 00:00:00 2001 From: Jay Hayes Date: Fri, 7 Jul 2017 12:24:16 -0500 Subject: [PATCH 3/3] Expose version func from Triangle module to tests --- exercises/triangle/tests/Tests.elm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/triangle/tests/Tests.elm b/exercises/triangle/tests/Tests.elm index 9c4842e..03e1ffb 100644 --- a/exercises/triangle/tests/Tests.elm +++ b/exercises/triangle/tests/Tests.elm @@ -2,7 +2,7 @@ module Tests exposing (..) import Test exposing (..) import Expect -import Triangle exposing (triangleKind, Triangle(..)) +import Triangle exposing (triangleKind, Triangle(..), version) tests : Test