Closed peschkaj closed 6 years ago
@peschkaj I have the functions written out and everything is compiling, however I wasn't sure how to go about testing it. I just walked through the logic on paper and it seems to make sense, I'll get back to testing it out probably sometime tomorrow when I start working on displaying the events
I embedded my tests as a comment in Deadline.hs, but they look like this:
import Data.Time
:set -XOverloadedStrings
t <- getCurrentTime
tz <- getCurrentTimeZone
d1 = Deadline "First deadline" "It's the first deadline ever" (addMinutes 60 t)
d2 = Deadline "Second deadline" "It's the second deadline ever" (addMinutes 180 t)
d3 = Deadline "Third deadline" "Why so many deadlines?" (addMinutes 600 t)
l1 <- addDeadline d1 ([] :: [Deadline])
l2 <- addDeadline d2 l1
l3 <- addDeadline d3 l2
-- What are all of my upcoming tasks?
putStrLn (deadlinesToLines tz l3)
-- What do I need to do next?
upcomingDeadlines l3 >>= putStrLn . deadlinesToLines tz
-- Testing JSON encode/decode
e1 = Data.Aeson.encode d1
(Just d1') = (Data.Aeson.decode e1 :: Maybe Deadline)
d1 == d1'
-- Now we test reading from a file
(Just l') <- getCurrentDeadlines
-- I should be true!
l' == l3
Testing instructions for events were added in https://github.com/peschkaj/todo.hs/commit/2afb55ec1b462fecbfc29071526c091ee7ead536
import Data.Time
:set -XOverloadedStrings
t <- getCurrentTime
tz <- getCurrentTimeZone
e1 = Event "First Event" "Some details" (addMinutes 2000 t) (addMinutes 2030 t)
e2 = Event "Second Event" "Some other details" (addMinutes 30 t) (addMinutes 180 t)
es <- addEvent e1 ([] :: [Event])
es' <- addEvent e2 es
es'' <- getCurrentEvents
-- Are the lists the same?
es'' == es'