Just a commit

This commit is contained in:
2016-08-15 14:08:39 -05:00
parent 0ef5df860d
commit ec4ec16ac2
50 changed files with 1972 additions and 7 deletions

19
haskell/leap/package.yaml Normal file
View 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

View File

@@ -0,0 +1,3 @@
module LeapYear (isLeapYear) where
isLeapYear = undefined

1
haskell/leap/stack.yaml Normal file
View File

@@ -0,0 +1 @@
resolver: nightly-2016-07-17

View 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 ) ]