Last active
December 21, 2019 00:17
-
-
Save 3v0k4/486643c291ccd28977af3282bfb22495 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main :: Effect Unit | |
main = do | |
testDeposit | |
testWithdraw | |
testPrintStatementNoTransactions | |
testPrintStatementWithTransactions | |
testDeposit :: Effect Unit | |
testDeposit = do | |
timestamp <- nowDateTime | |
let amount = 1 | |
expected = Identity [ Deposit { amount: amount, timestamp: timestamp } ] | |
actual = execStateT (deposit (Identity timestamp) amount) [] | |
assertEqual { actual: actual, expected: expected } | |
testWithdraw :: Effect Unit | |
testWithdraw = do | |
timestamp <- nowDateTime | |
let amount = 1 | |
expected = Identity [ Withdraw { amount: amount, timestamp: timestamp } ] | |
actual = execStateT (withdraw (Identity timestamp) amount) [] | |
assertEqual { actual: actual, expected: expected } | |
testPrintStatementNoTransactions :: Effect Unit | |
testPrintStatementNoTransactions = do | |
let expected = "" | |
actual = execWriter (evalStateT (printStatement \s -> tell s) []) | |
assertEqual { actual: actual, expected: expected } | |
testPrintStatementWithTransactions :: Effect Unit | |
testPrintStatementWithTransactions = do | |
timestamp <- nowDateTime | |
let d = Deposit { amount: 500, timestamp: timestamp } | |
w = Withdraw { amount: 100, timestamp: timestamp } | |
state = [ d, w ] | |
expected = "expected string" | |
actual = execWriter (evalStateT (printStatement \s -> tell s) state) | |
assertEqual { actual: actual, expected: expected } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment