Merge pull request #111 from jehoshua02/gigasecond

Adds Gigasecond Problem
This commit is contained in:
Erik Simmler 2016-08-30 20:11:38 -04:00 committed by GitHub
commit c15b300c6f
8 changed files with 87 additions and 2 deletions

View file

@ -31,7 +31,8 @@
"atbash-cipher",
"say",
"largest-series-product",
"roman-numerals"
"roman-numerals",
"gigasecond"
],
"exercises": [
{

View file

@ -32,7 +32,8 @@
"./exercises/atbash-cipher",
"./exercises/say",
"./exercises/largest-series-product",
"./exercises/roman-numerals"
"./exercises/roman-numerals",
"./exercises/gigasecond"
],
"exposed-modules": [],
"dependencies": {

View file

@ -0,0 +1 @@
module Gigasecond exposing (add)

View 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

View 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

View 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"
}

View 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

View 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"