Skip to content

Instantly share code, notes, and snippets.

@schrepfler
Last active August 16, 2016 23:15
Show Gist options
  • Save schrepfler/e75777b93f1bfc312e7fca431537048f to your computer and use it in GitHub Desktop.
Save schrepfler/e75777b93f1bfc312e7fca431537048f to your computer and use it in GitHub Desktop.
counter test
module Test.Main where
import Prelude
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, logShow)
import Data.Maybe (Maybe(Just))
import Data.Map as Map
import Data.Monoid.Additive (Additive(Additive))
import Main (GCounter(..), increment, value)
import Test.Unit (suite, test, timeout)
import Test.Unit.Main (runTest)
import Test.Unit.Assert as Assert
import Control.Monad.Eff.Class
main = runTest do
suite "GCounter test suite" do
test "GCounter increment" do
let c = Just (GCounter "a" (Map.singleton "a" (Additive 0)))
>>= increment (Additive 10)
>>= increment (Additive 20)
Assert.assert "Counter should be 30" $ (value <$> c) == Just (Additive 30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment