diff --git a/config.json b/config.json index 11bdb31..3b251b6 100644 --- a/config.json +++ b/config.json @@ -6,6 +6,7 @@ "test_pattern": "TODO", "problems": [ "hello_world", + "leap", "bob" ], "deprecated": [ diff --git a/elm-package.json b/elm-package.json index a77c9ef..7d7ab00 100644 --- a/elm-package.json +++ b/elm-package.json @@ -6,6 +6,7 @@ "source-directories": [ ".", "./exercises/hello_world", + "./exercises/leap", "./exercises/bob" ], "exposed-modules": [], diff --git a/exercises/leap/Leap.elm b/exercises/leap/Leap.elm new file mode 100644 index 0000000..3f41ddc --- /dev/null +++ b/exercises/leap/Leap.elm @@ -0,0 +1 @@ +module Leap (..) where diff --git a/exercises/leap/Leap.example b/exercises/leap/Leap.example new file mode 100644 index 0000000..35b4c83 --- /dev/null +++ b/exercises/leap/Leap.example @@ -0,0 +1,6 @@ +module Leap (..) where + + +isLeapYear : Int -> Bool +isLeapYear year = + year % 4 == 0 && (year % 100 /= 0 || year % 400 == 0) diff --git a/exercises/leap/LeapTests.elm b/exercises/leap/LeapTests.elm new file mode 100644 index 0000000..afbacc1 --- /dev/null +++ b/exercises/leap/LeapTests.elm @@ -0,0 +1,25 @@ +module Main (..) where + +import Task +import Console +import ElmTest exposing (..) +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)) + ] + + +port runner : Signal (Task.Task x ()) +port runner = + Console.run (consoleRunner tests)