mirror of
https://github.com/correl/elm.git
synced 2024-12-18 11:06:17 +00:00
Merge pull request #111 from jehoshua02/gigasecond
Adds Gigasecond Problem
This commit is contained in:
commit
c15b300c6f
8 changed files with 87 additions and 2 deletions
|
@ -31,7 +31,8 @@
|
|||
"atbash-cipher",
|
||||
"say",
|
||||
"largest-series-product",
|
||||
"roman-numerals"
|
||||
"roman-numerals",
|
||||
"gigasecond"
|
||||
],
|
||||
"exercises": [
|
||||
{
|
||||
|
|
|
@ -32,7 +32,8 @@
|
|||
"./exercises/atbash-cipher",
|
||||
"./exercises/say",
|
||||
"./exercises/largest-series-product",
|
||||
"./exercises/roman-numerals"
|
||||
"./exercises/roman-numerals",
|
||||
"./exercises/gigasecond"
|
||||
],
|
||||
"exposed-modules": [],
|
||||
"dependencies": {
|
||||
|
|
1
exercises/gigasecond/Gigasecond.elm
Normal file
1
exercises/gigasecond/Gigasecond.elm
Normal file
|
@ -0,0 +1 @@
|
|||
module Gigasecond exposing (add)
|
14
exercises/gigasecond/Gigasecond.example
Normal file
14
exercises/gigasecond/Gigasecond.example
Normal file
|
@ -0,0 +1,14 @@
|
|||
module Gigasecond exposing (add)
|
||||
|
||||
import Date
|
||||
import Time
|
||||
|
||||
|
||||
add : Date.Date -> Date.Date
|
||||
add =
|
||||
Date.toTime >> (+) gigasecond >> Date.fromTime
|
||||
|
||||
|
||||
gigasecond : Time.Time
|
||||
gigasecond =
|
||||
10 ^ 12
|
49
exercises/gigasecond/GigasecondTests.elm
Normal file
49
exercises/gigasecond/GigasecondTests.elm
Normal file
|
@ -0,0 +1,49 @@
|
|||
port module Main exposing (..)
|
||||
|
||||
import Test.Runner.Node exposing (run)
|
||||
import Json.Encode exposing (Value)
|
||||
import Test exposing (..)
|
||||
import Expect
|
||||
import Date
|
||||
import Gigasecond exposing (add)
|
||||
|
||||
|
||||
tests : Test
|
||||
tests =
|
||||
describe "Gigasecond"
|
||||
[ describe "add"
|
||||
[ test "2011-04-25" <|
|
||||
\() ->
|
||||
Expect.equal (date "2043-01-01T01:46:40") (Gigasecond.add (date "2011-04-25"))
|
||||
, test "1977-06-13" <|
|
||||
\() ->
|
||||
Expect.equal (date "2009-02-19T01:46:40") (Gigasecond.add (date "1977-06-13"))
|
||||
, test "1959-07-19" <|
|
||||
\() ->
|
||||
Expect.equal (date "1991-03-27T01:46:40") (Gigasecond.add (date "1959-07-19"))
|
||||
, test "full time specified" <|
|
||||
\() ->
|
||||
Expect.equal (date "2046-10-02T23:46:40") (Gigasecond.add (date "2015-01-24T22:00:00"))
|
||||
, test "full time with day roll-over" <|
|
||||
\() ->
|
||||
Expect.equal (date "2046-10-03T01:46:39") (Gigasecond.add (date "2015-01-24T23:59:59"))
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
date : String -> Date.Date
|
||||
date input =
|
||||
case Date.fromString input of
|
||||
Ok date ->
|
||||
date
|
||||
|
||||
Err reason ->
|
||||
Debug.crash reason
|
||||
|
||||
|
||||
main : Program Value
|
||||
main =
|
||||
run emit tests
|
||||
|
||||
|
||||
port emit : ( String, Value ) -> Cmd msg
|
16
exercises/gigasecond/elm-package.json
Normal file
16
exercises/gigasecond/elm-package.json
Normal file
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"version": "3.0.0",
|
||||
"summary": "Exercism problems in Elm.",
|
||||
"repository": "https://github.com/exercism/xelm.git",
|
||||
"license": "BSD3",
|
||||
"source-directories": [
|
||||
"."
|
||||
],
|
||||
"exposed-modules": [],
|
||||
"dependencies": {
|
||||
"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": "2.0.0 <= v < 3.0.0"
|
||||
},
|
||||
"elm-version": "0.17.0 <= v < 0.18.0"
|
||||
}
|
1
exercises/gigasecond/runtests.bat
Normal file
1
exercises/gigasecond/runtests.bat
Normal file
|
@ -0,0 +1 @@
|
|||
ECHO We've changed how tests are run! Please review the latest install/running docs at http://exercism.io/languages/elm and report any issues at https://github.com/exercism/xelm
|
2
exercises/gigasecond/runtests.sh
Normal file
2
exercises/gigasecond/runtests.sh
Normal file
|
@ -0,0 +1,2 @@
|
|||
#!/usr/bin/env bash
|
||||
echo "We've changed how tests are run! Please review the latest install/running docs at http://exercism.io/languages/elm and report any issues at https://github.com/exercism/xelm"
|
Loading…
Reference in a new issue