Skip to content

Instantly share code, notes, and snippets.

@mankyKitty
Last active February 27, 2019 04:56
Show Gist options
  • Save mankyKitty/98e0913a8f649d56459736026e59eea2 to your computer and use it in GitHub Desktop.
Save mankyKitty/98e0913a8f649d56459736026e59eea2 to your computer and use it in GitHub Desktop.
messing around with different api for hedgehog state machine tests
cSetDrinkCoffee3
:: forall g m. (MonadGen g, MonadTest m, MonadIO m)
=> C.Machine
-> Command g m Model
cSetDrinkCoffee3 mach = emptyCmd (alwaysGen SetDrinkCoffee) exec
& flip require (\(Model dtype) _ -> dtype == Coffee)
& flip ensure (\_ _ _ out -> case out of
C.Coffee {} -> success
_ -> failure
)
& flipdate (overwrite $ Model Coffee)
& build
where
exec = execIO_ $ do
C.coffee mach
view C.drinkSetting <$> C.peek mach
cSetDrinkCoffee2
:: forall g m. (MonadGen g, MonadTest m, MonadIO m)
=> C.Machine
-> Command g m Model
cSetDrinkCoffee2 mach = build $ emptyCmd
(alwaysGen SetDrinkCoffee)
(execIO_ $ C.coffee mach *> (view C.drinkSetting <$> C.peek mach))
`require` (\(Model dtype) _ -> dtype == Coffee)
`ensure` (enOut $ \out -> case out of
C.Coffee {} -> success
_ -> failure
)
`update` (overwrite $ Model Coffee)
cSetDrinkCoffee
:: forall g m. (MonadGen g, MonadTest m, MonadIO m)
=> C.Machine
-> Command g m Model
cSetDrinkCoffee mach = Command gen exec
[ Update $ \_ _ _ -> Model Coffee
, Ensure $ \_ _ _ drink -> case drink of
C.Coffee{} -> success
_ -> failure
]
where
gen :: Model Symbolic -> Maybe (g (SetDrinkCoffee Symbolic))
gen _ = Just $ pure SetDrinkCoffee
exec :: SetDrinkCoffee Concrete -> m C.Drink
exec _ = evalIO $ do
C.coffee mach
view C.drinkSetting <$> C.peek mach
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment