Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order of arguments to test functions is awkward #123

Closed
barrucadu opened this issue Sep 29, 2017 · 1 comment
Closed

Order of arguments to test functions is awkward #123

barrucadu opened this issue Sep 29, 2017 · 1 comment

Comments

@barrucadu
Copy link
Owner

dejafu :: Show a => (forall t. ConcST t a) -> (String, Predicate a) -> IO Bool
dejafus :: Show a => (forall t. ConcST t a) -> [(String, Predicate a)] -> IO Bool
dejafuWay :: Show a => Way -> MemType -> (forall t. ConcST t a) -> (String, Predicate a) -> IO Bool
dejafusWay :: Show a => Way -> MemType -> (forall t. ConcST t a) -> [(String, Predicate a)] -> IO Bool
dejafuDiscard :: Show a => (Either Failure a -> Maybe Discard) -> Way -> MemType -> (forall t. ConcST t a) -> (String, Predicate a) -> IO Bool
-- etc

Currently, the action to test comes somewhere in the middle of the arguments to the etst functions. This pattern is followed in the hunit-dejafu and tasty-dejafu packages. But as I've found in dejafu-tests, it's kind of a pain, and I define wrapper functions so I can do this:

threadingTests :: [Test]
threadingTests = toTestList
[ djfuT "Fork reports the thread ID of the child" (gives' [True]) $ do
var <- newEmptyMVar
tid <- fork $ myThreadId >>= putMVar var
(tid ==) <$> readMVar var
, djfuT "Different threads have different thread IDs" (gives' [True]) $ do
tid <- spawn myThreadId
(/=) <$> myThreadId <*> readMVar tid
, djfuT "A thread doesn't wait for its children before terminating" (gives' [Nothing, Just ()]) $ do
x <- newCRef Nothing
_ <- fork . writeCRef x $ Just ()
readCRef x
]

The action to test should go last.

@barrucadu
Copy link
Owner Author

Implemented in next-supermajor branch.

@barrucadu barrucadu mentioned this issue Nov 22, 2017
20 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant