Create a tasty TestTree from an Obligation:
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -O -dsuppress-all -dno-suppress-type-signatures -fplugin=Test.Tasty.Inspection.Plugin #-}
import Test.Tasty
import Test.Tasty.Inspection
lhs :: (a -> b) -> Maybe a -> Bool
lhs f x = case fmap f x of
Nothing -> True
Just{} -> False
rhs :: (a -> b) -> Maybe a -> Bool
rhs _ Nothing = True
rhs _ Just{} = False
main :: IO ()
main = defaultMain $(inspectTest $ 'lhs === 'rhs)This is not the same function as Test.Inspection.inspectTest:
both return Q Exp, but this one represents TestTree
instead of Result.
If you are unhappy with an autogenerated test name, amend it using testName:
inspectTest (obl { testName = Just "foo" })To invert an obligation apply Test.Tasty.ExpectedFailure.expectFail.