@@ -246,6 +246,36 @@ main = launchAff_ $ runSpec [ consoleReporter ] do
246246 # liftAff
247247 result `shouldEqual` 99
248248
249+ it "throwWhen throws only when its condition is true" do
250+ let
251+ run condition = do
252+ Om.throwWhen { rejected: "blocked" } condition
253+ pure "continued"
254+ handle =
255+ Om.runOm {}
256+ { exception: \_ -> pure "exception"
257+ , rejected: pure
258+ }
259+ whenTrue <- run true # handle # liftAff
260+ whenFalse <- run false # handle # liftAff
261+ whenTrue `shouldEqual` "blocked"
262+ whenFalse `shouldEqual` "continued"
263+
264+ it "throwUnless throws only when its condition is false" do
265+ let
266+ run condition = do
267+ Om.throwUnless { rejected: "blocked" } condition
268+ pure "continued"
269+ handle =
270+ Om.runOm {}
271+ { exception: \_ -> pure "exception"
272+ , rejected: pure
273+ }
274+ whenTrue <- run true # handle # liftAff
275+ whenFalse <- run false # handle # liftAff
276+ whenTrue `shouldEqual` "continued"
277+ whenFalse `shouldEqual` "blocked"
278+
249279 it "throwLeftAs converts Left to error" do
250280 result <- Left "bad" # Om.throwLeftAs (\badError -> Om.error { badError })
251281 # runExampleOm