File: AddDays.hs

package info (click to toggle)
ghc 8.0.1-17
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 55,080 kB
  • ctags: 9,332
  • sloc: haskell: 363,120; ansic: 54,900; sh: 4,782; makefile: 974; perl: 542; asm: 315; python: 306; xml: 154; lisp: 7
file content (41 lines) | stat: -rw-r--r-- 1,007 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
module Test.AddDays where

import Data.Time.Calendar
import Test.TestUtil
import Test.AddDaysRef

days ::[Day]
days =
    [
    fromGregorian 2005 2 28,
    fromGregorian 2004 2 29,
    fromGregorian 2004 1 31,
    fromGregorian 2004 12 31,
    fromGregorian 2005 7 1,
    fromGregorian 2005 4 21,
    fromGregorian 2005 6 30
    ]

increments :: [Integer]
increments = [-10,-4,-1,0,1,7,83]

adders :: [(String,Integer -> Day -> Day)]
adders =
    [
    ("day",addDays),
    ("month (clip)",addGregorianMonthsClip),
    ("month (roll over)",addGregorianMonthsRollOver),
    ("year (clip)",addGregorianYearsClip),
    ("year (roll over)",addGregorianYearsRollOver)
    ]

resultDays :: [String]
resultDays = do
    (aname,adder) <- adders
    increment <- increments
    day <- days
    return ((showGregorian day) ++ " + " ++ (show increment) ++ " * " ++ aname ++ " = " ++ showGregorian (adder increment day))

addDaysTest :: Test
addDaysTest = pureTest "addDays" $
    diff addDaysRef $ unlines resultDays