Trying out Hspec
[?]
Mar 9, 2014, 3:34 PM
NMWWP4ZNOKHZKSJ6F5KYEREWXXR5F4UD35WOKI3EH42AZWVCTCJACDependencies
- [2]
TJEUE7TYAdded OverloadedStrings to eliminate Text fiddling. - [3]
2KZPOGRBOnce you get Haskell to compile, the tests pass! - [4]
EQXRXRZDChanged to use tasty instead of test-framework - [5]
ADMKQQGCInitial empty Snap project. - [6]
NVOCQVASInitial failing tests. - [7]
N4NDAZYTInitial implementation of payouts. - [8]
Y35QCWYWMinor improvement in WorkIndex type to eliminate duplicated information.
Change contents
- replacement in ananke.cabal at line 34
Test-Suite test-anankeTest-Suite spec - replacement in ananke.cabal at line 38
main-is: Test.hsmain-is: Spec.hs - edit in ananke.cabal at line 40
tasty >= 0.7,tasty-hunit,tasty-quickcheck, - edit in ananke.cabal at line 41
hspec >= 1.8.1, - replacement in ananke.cabal at line 45
containers == 0.5.*,containers, - file addition: Ananke[3.3647]
- file move: Test.hs → TimeLogSpec.hs
- edit in test/Ananke/TimeLogSpec.hs at line 2
module Ananke.TimeLogSpec where - replacement in test/Ananke/TimeLogSpec.hs at line 5
import Test.Tastyimport Test.Tasty.QuickCheck as QCimport Test.Tasty.HUnitimport Test.Hspecimport Anankeimport Ananke.Interval as Iimport Ananke.TimeLog as Limport Control.Arrowimport Control.Monad - edit in test/Ananke/TimeLogSpec.hs at line 13
import Data.Maybe - edit in test/Ananke/TimeLogSpec.hs at line 15
import Data.Maybe - edit in test/Ananke/TimeLogSpec.hs at line 16[3.229]→[3.3781:3802](∅→∅),[3.3781]→[3.3781:3802](∅→∅),[3.3802]→[3.230:251](∅→∅),[3.251]→[3.3802:3816](∅→∅),[3.3802]→[3.3802:3816](∅→∅),[3.3816]→[3.1944:1999](∅→∅),[3.1999]→[3.3838:3863](∅→∅),[3.3838]→[3.3838:3863](∅→∅)
import Control.Monadimport Control.Arrowimport Anankeimport Ananke.TimeLog as Limport Ananke.Interval as Iimport Data.Time.ISO8601 - replacement in test/Ananke/TimeLogSpec.hs at line 17
main = defaultMain teststests :: TestTreetests = testGroup "Intervals" [unitTests]import Data.Time.ISO8601 - edit in test/Ananke/TimeLogSpec.hs at line 19
unitTests = testGroup "Unit Tests" [testCase "deriveIntervals" deriveIntervalsTest] - replacement in test/Ananke/TimeLogSpec.hs at line 20
deriveIntervalsTest :: AssertionderiveIntervalsTest = lettestAddrs = catMaybes [ parseBtcAddr "123", parseBtcAddr "456", parseBtcAddr "789" ]spec :: Specspec = dodescribe "log reduction" $ doit "reduces a log to a work index" $ dolet testAddrs = catMaybes [ parseBtcAddr "123", parseBtcAddr "456", parseBtcAddr "789" ] - replacement in test/Ananke/TimeLogSpec.hs at line 28
starts = catMaybes [ parseISO8601 "2014-01-01T00:08:00Z", parseISO8601 "2014-02-12T00:12:00Z" ]starts = catMaybes [ parseISO8601 "2014-01-01T00:08:00Z", parseISO8601 "2014-02-12T00:12:00Z" ] - replacement in test/Ananke/TimeLogSpec.hs at line 31
ends = catMaybes [ parseISO8601 "2014-01-01T00:12:00Z", parseISO8601 "2014-02-12T00:18:00Z" ]ends = catMaybes [ parseISO8601 "2014-01-01T00:12:00Z", parseISO8601 "2014-02-12T00:18:00Z" ] - replacement in test/Ananke/TimeLogSpec.hs at line 34[3.2687]→[3.2687:2718](∅→∅),[3.2718]→[3.4380:4460](∅→∅),[3.4380]→[3.4380:4460](∅→∅),[3.4460]→[3.2719:2789](∅→∅)
testLogEntries :: [LogEntry]testLogEntries = doaddr <- testAddrs(start, end) <- zip starts ends[ LogEntry addr (StartWork start), LogEntry addr (StopWork end) ]testLogEntries :: [LogEntry]testLogEntries = doaddr <- testAddrs(start, end) <- zip starts ends[ LogEntry addr (StartWork start), LogEntry addr (StopWork end) ] - replacement in test/Ananke/TimeLogSpec.hs at line 40[3.418]→[3.2790:2823](∅→∅),[3.2823]→[3.418:439](∅→∅),[3.418]→[3.418:439](∅→∅),[3.439]→[3.4542:4600](∅→∅),[3.4542]→[3.4542:4600](∅→∅),[3.4600]→[3.440:493](∅→∅)
testIntervals :: [LogInterval]testIntervals = doaddr <- testAddrs(start, end) <- zip starts endsreturn $ LogInterval addr (I.interval start end)testIntervals :: [LogInterval]testIntervals = doaddr <- testAddrs(start, end) <- zip starts endsreturn $ LogInterval addr (I.interval start end) - replacement in test/Ananke/TimeLogSpec.hs at line 46
expected0 :: Map BtcAddr ([LogEntry], [LogInterval])expected0 = M.map (const [] &&& id) . fromListWith (++) . fmap (intervalBtcAddr &&& return) $ testIntervalsexpected0 :: Map BtcAddr ([LogEntry], [LogInterval])expected0 = M.map (const [] &&& id) . fromListWith (++) . fmap (intervalBtcAddr &&& return) $ testIntervals - replacement in test/Ananke/TimeLogSpec.hs at line 49
expected :: WorkIndexexpected = M.map (bimap (fmap event) (fmap workInterval)) expected0expected :: WorkIndexexpected = M.map (bimap (fmap event) (fmap workInterval)) expected0 - replacement in test/Ananke/TimeLogSpec.hs at line 52
in assertEqual "derive log entries" (intervals testLogEntries) expected(intervals testLogEntries) `shouldBe` expected - edit in test/Ananke/TimeLogSpec.hs at line 54
main :: IO ()main = hspec spec - file addition: Spec.hs[3.3647]
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}