From 92e5b4881ae86bf09a0ff29d9cfb6f6152e401d8 Mon Sep 17 00:00:00 2001 From: Michael Walker Date: Wed, 2 May 2018 21:57:20 +0100 Subject: [PATCH] Add some tests around nested orElse/catchSTM Closes #208 --- dejafu-tests/lib/Integration/SingleThreaded.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dejafu-tests/lib/Integration/SingleThreaded.hs b/dejafu-tests/lib/Integration/SingleThreaded.hs index 33ab342..8533552 100644 --- a/dejafu-tests/lib/Integration/SingleThreaded.hs +++ b/dejafu-tests/lib/Integration/SingleThreaded.hs @@ -167,6 +167,18 @@ stmTests = toTestList , djfu "MonadSTM is a MonadFail" (alwaysFailsWith isUncaughtException) (atomically $ fail "hello world" :: MonadConc m => m ()) -- avoid an ambiguous type + + , djfu "'retry' is not caught by 'catch'" (gives' [True]) $ + atomically + ((retry `catchSomeException` \_ -> pure False) `orElse` pure True) + + , djfu "'throw' is not caught by 'orElse'" (gives' [True]) $ + atomically + ((throwSTM Overflow `orElse` pure False) `catchSomeException` \_ -> pure True) + + , djfu "'retry' in a nested 'orElse' only aborts the innermost" (gives' [True]) $ + atomically + ((retry `orElse` pure True) `orElse` pure False) ] --------------------------------------------------------------------------------