Îõ³h$(“'=7      !"#$%&'()*+,-./0123456 Safe-Inferred789:;<=>$Testing in a monad transformer layer(c) John Maraist, 2022GPL3haskell-tlt@maraist.org experimentalPOSIXNone >ÀÁÂÄÎÔÙ&‘'TLT Extending ¥ operations across other monad transformers. For easiest and most flexible testing, declare the monad transformers of your application as instances of this class.TLTýLift TLT operations within a monad transformer stack. Note that with enough transformer types included in this class, the liftTLT„ function should usually be unnecessary: the commands in this module which actually configure testing, or specify a test, already liftTLTÇ their own result. So they will all act as top-level transformers in MonadTLT.TLTáMonad transformer for TLT tests. This layer stores the results from tests as they are executed.TLTÂAn assertion is a computation (typically in the monad wrapped by ª) which returns a list of zero of more reasons for the failure of the assertion. A successful computation returns an empty list: no reasons for failure, hence success.TLT!Execute the tests specified in a / monad, and report the results as text output.¨When using TLT from some other package (as opposed to using TLT itself as your test framework, and wishing to see its human-oriented output directly), consider using  instead.TLT!Execute the tests specified in a Ô monad without output side-effects, returning the final options and result reports.ÊThis function is primarily useful when calling TLT from some other package. If you are using TLT itself as your test framework, and wishing to see its human-oriented output directly, consider using  instead.TLTThis function controls whether Š will report only tests which fail, suppressing any display of tests which pass, or else report the results of all tests. The default is the former: the idea is that no news should be good news, with the programmer bothered only with problems which need fixing.TLTThis function controls whether ‹ will exit after displaying test results which include at least one failing test. By default, it will exit in this situation. The idea is that a test suite can be broken into parts when it makes sense to run the latter parts only when the former parts all pass.TLTÕReport a failure. Useful in pattern-matching cases which are entirely not expected. TLTëOrganize the tests in the given subcomputation as a separate group within the test results we will report. TLTLabel and perform a test of an .Example ¢test :: Monad m => TLT m () test = do "2 is 2 as result" ~: 2 @== return 2 -- This test passes. "2 not 3" ~: 2 @/=- 3 -- This test fails. TLT3Label and perform a test of a (pure) boolean value.Example ‚test :: Monad m => TLT m () test = do "True passes" ~::- return True -- This test passes. "2 is 2 as single Bool" ~::- return (2 == 2) -- This test passes. "2 is 3!?" ~::- myFn 4 "Hammer" -- Passes if myFn (which -- must be monadic) -- returns True. TLTÜLabel and perform a test of a boolean value returned by a computation in the wrapped monad m.Example Ûtest :: Monad m => TLT m () test = do "True passes" ~::- True -- This test passes. "2 is 2 as single Bool" ~::- 2 == 2 -- This test passes. "2 is 3!?" ~::- 2 == 2 -- This test fails. TLT÷Transform a binary function on an expected and an actual value (plus a binary generator of a failure message) into an  for a pure given actual value.Example$TLT's scalar-testing operators like @==-! are defined with this function: ¥(@==-) :: (Monad m, Eq a, Show a) => a -> a -> Assertion m (@==-) = liftAssertion2Pure (==) $ \ exp actual -> "Expected " ++ show exp ++ " but got " ++ show actualThe ? operator tests equality, and the result here allows the assertion that a value should be exactly equal to a target. The second argument formats the detail reported when the assertion fails.TLT Given an ; for two pure values (expected and actual), lift it to an ? expecting the actual value to be returned from a computation.ExamplesThe TLT assertion  lifts Û from expecting a pure actual result to expecting a computation returning a value to test. Ù(@==) :: (Monad m, Eq a, Show a) => a -> m a -> Assertion m (@==) = assertion2PtoM (@==-)TLTëTransform a binary function on expected and actual values (plus a generator of a failure message) into an Á where the actual value is to be returned from a subcomputation.TLTÓAssert that two values are equal. This assertion takes an expected and an actual value; see  to compare the result of a monadic computation to an expected value.Examples  test :: Monad m => TLT m () test = do "Make sure that 2 is still equal to itself" ~: 2 @==- 2 "Make sure that there are four lights" ~: 4 @==- length lightsTLTØAssert that a calculated value is as expected. This assertion compare the result of a monadic computation to an expected value; see  to compare an  actual value to the expected value.Examples ítest :: Monad m => TLT m () test = do "Make sure that 2 is still equal to itself" ~: 2 @== return 2 "Make sure that there are four lights" ~: 4 @== countLights -- where countLights :: m IntTLT×Assert that two values are not equal. This assertion takes an expected and an actual value; see  to compare the result of a monadic computation to an expected value.TLTçAssert that a calculated value differs from some known value. This assertion compares the result of a monadic computation to an expected value; see  to compare an  actual value to the expected value.TLTïAssert that a given boundary is strictly less than some value. This assertion takes an expected and an actual value; see  to compare the result of a monadic computation to an expected value.TLT¯Assert that a given, constant boundary is strictly less than some calculated value. This assertion compares the result of a /monadic computation/ to an expected value; see  to compare an  actual value to the expected value.TLTïAssert that a given boundary is strictly less than some value. This assertion takes an expected and an actual value; see  to compare the result of a monadic computation to an expected value.TLT¯Assert that a given, constant boundary is strictly less than some calculated value. This assertion compares the result of a /monadic computation/ to an expected value; see  to compare an  actual value to the expected value.TLTïAssert that a given boundary is strictly less than some value. This assertion takes an expected and an actual value; see  to compare the result of a monadic computation to an expected value.TLT¯Assert that a given, constant boundary is strictly less than some calculated value. This assertion compares the result of a /monadic computation/ to an expected value; see  to compare an  actual value to the expected value.TLTïAssert that a given boundary is strictly less than some value. This assertion takes an expected and an actual value; see  to compare the result of a monadic computation to an expected value.TLT¯Assert that a given, constant boundary is strictly less than some calculated value. This assertion compares the result of a /monadic computation/ to an expected value; see  to compare an  actual value to the expected value.TLT3This assertion always fails with the given message.TLTThis assertion always succeeds.TLTòTransform a unary function on a value (plus a generator of a failure message) into a unary function returning an  for a pure given actual value.ExampleThe TLT assertion ! is built from the @ predicate A ™emptyP :: (Monad m, Traversable t) => t a -> Assertion m emptyP = liftAssertionPure null (\ _ -> "Expected empty structure but got non-empty")TLT Given an + for a pure (actual) value, lift it to an 7 expecting the value to be returned from a computation.ExampleThe TLT assertion "þ on monadic computations returning lists is defined in terms of the corresponging assertion on pure list-valued expressions. Øempty :: (Monad m, Traversable t) => m (t a) -> Assertion m empty = assertionPtoM emptyP TLTßTransform a unary function on an actual value (plus a generator of a failure message) into an : where the value is to be returned from a subcomputation.!TLTÄAssert that a pure traversable structure (such as a list) is empty."TLTÛAssert that a traversable structure (such as a list) returned from a computation is empty.#TLTÇAssert that a pure traversable structure (such as a list) is nonempty.$TLTßAssert that a traversable structure (such as a list) returned from a computation is non-empty.%TLTAssert that a B value is C.&TLTAssert that a B result ofa computation is C.'  !"#$%&'  "$!#&%  0 0 0111111111111Ä      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGEHIEJKEJLÍ"TLT-0.2.0.0-6TeQhgbbES6A2yAg7JQN4zTest.TLT Paths_TLTMonadTLTliftTLTTLT AssertiontlttltCorereportAllTestResultssetExitAfterFailDisplaytltFailinGroup~:~::-~::liftAssertion2Pureassertion2PtoMliftAssertion2M@==-@==@/=-@/=@<-@<@>-@>@<=-@<=@>=-@>= assertFailed assertSuccessliftAssertionPure assertionPtoMliftAssertionMemptyPempty nonemptyPnonemptynothingPnothing$fMonadTLTWriterTn$fMonadTLTWriterTn0$fMonadTLTSTTn$fMonadTLTStateTn$fMonadTLTStateTn0$fMonadTLTResourceTn$fMonadTLTReaderTn$fMonadTLTMaybeTn$fMonadTLTIdentityTn$fMonadTLTFreeTn$fMonadTLTTLTm $fFunctorTLT$fApplicativeTLT $fMonadTLT$fMonadTransTLT $fMonadIOTLTversion getBinDir getLibDir getDynLibDir getDataDir getLibexecDir getSysconfDirgetDataFileNameghc-prim GHC.Classes==baseData.Traversable Traversable Data.Foldablenull GHC.MaybeMaybeNothing