Just a commit
This commit is contained in:
19
haskell/leap/package.yaml
Normal file
19
haskell/leap/package.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
name: leap
|
||||
|
||||
dependencies:
|
||||
- base
|
||||
|
||||
library:
|
||||
exposed-modules: LeapYear
|
||||
source-dirs: src
|
||||
dependencies:
|
||||
# - foo # List here the packages you
|
||||
# - bar # want to use in your solution.
|
||||
|
||||
tests:
|
||||
test:
|
||||
main: Tests.hs
|
||||
source-dirs: test
|
||||
dependencies:
|
||||
- leap
|
||||
- HUnit
|
3
haskell/leap/src/LeapYear.hs
Normal file
3
haskell/leap/src/LeapYear.hs
Normal file
@@ -0,0 +1,3 @@
|
||||
module LeapYear (isLeapYear) where
|
||||
|
||||
isLeapYear = undefined
|
1
haskell/leap/stack.yaml
Normal file
1
haskell/leap/stack.yaml
Normal file
@@ -0,0 +1 @@
|
||||
resolver: nightly-2016-07-17
|
31
haskell/leap/test/Tests.hs
Normal file
31
haskell/leap/test/Tests.hs
Normal file
@@ -0,0 +1,31 @@
|
||||
{-# OPTIONS_GHC -fno-warn-type-defaults #-}
|
||||
|
||||
import Control.Monad (unless)
|
||||
import System.Exit (exitFailure)
|
||||
|
||||
import Test.HUnit
|
||||
( (~:)
|
||||
, (~=?)
|
||||
, Counts (failures, errors)
|
||||
, Test (TestList)
|
||||
, runTestTT
|
||||
)
|
||||
|
||||
import LeapYear (isLeapYear)
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
counts <- runTestTT isLeapYearTests
|
||||
unless (failures counts == 0 && errors counts == 0) exitFailure
|
||||
|
||||
isLeapYearTests :: Test
|
||||
isLeapYearTests = TestList $ map test cases
|
||||
where
|
||||
test (label, year, expected) = label ~: isLeapYear year ~=? expected
|
||||
cases = [ ("leap year" , 1996, True )
|
||||
, ("standard and odd year" , 1997, False)
|
||||
, ("standard even year" , 1998, False)
|
||||
, ("standard nineteenth century", 1900, False)
|
||||
, ("standard eighteenth century", 1800, False)
|
||||
, ("leap twenty fourth century" , 2400, True )
|
||||
, ("leap y2k" , 2000, True ) ]
|
Reference in New Issue
Block a user