Fix docspec for Data.Fold

This commit is contained in:
Harendra Kumar 2022-03-13 20:40:44 +05:30
parent 38e52742c4
commit f8afdaf7e2
3 changed files with 9 additions and 27 deletions

View File

@ -1534,7 +1534,7 @@ demuxDefault = demuxDefaultWith id
--
-- >>> :{
-- let input = Stream.fromList [("ONE",1),("ONE",1.1),("TWO",2), ("TWO",2.2)]
-- in Stream.fold (Fold.classifyWith fst (Fold.map snd Fold.toList)) input
-- in Stream.fold (Fold.classifyWith fst (Fold.lmap snd Fold.toList)) input
-- :}
-- fromList [("ONE",[1.0,1.1]),("TWO",[2.0,2.2])]
--

View File

@ -28,6 +28,7 @@ import Streamly.Internal.Data.Fold.Type
-- $setup
-- >>> :m
-- >>> :set -XFlexibleContexts
-- >>> import qualified Streamly.Prelude as Stream
-- >>> import qualified Streamly.Data.Fold as Fold
-- >>> import qualified Streamly.Internal.Data.Fold.Async as Fold

View File

@ -94,15 +94,12 @@ all the test suites before running `Prelude.Serial`.
## Writing doctests
* The test named `doctest` runs all the code snippets in a source module
that are written using the `>>>` markup in haddock. See `doctest.hs`.
* We use `cabal-docspec` to run all the code snippets in a source module
that are written using the `>>>` markup in haddock.
* Make sure you do not enclose your snippets in the `@ .. @` markup otherwise
they will show up verbatim in the docs and not as ghci styled snippets.
* We use `--fast` mode of doctest, which means snippets are run as if you are
typing those examples from top to bottom in that order in GHCi. Previous
snippet's state is available to the next one.
* A haddock section named `$setup` contains a snippet that is always run before
any other. When `--fast` mode is not used it is run before every snippet.
any other.
An example setup section:
@ -113,8 +110,8 @@ An example setup section:
-- >>> import Data.Function ((&))
```
Some tests that may take long can be written as follows. Just assigning
the code to a function makes it compile but not run.
Some tests that may take long can be written as follows. Just defining
the snippet as a function makes it compile but not run.
```
>>> :{
@ -128,27 +125,11 @@ main = do
## Running doctests
Run tests for all modules:
```
$ cabal run doctests --flag doctests
$ cabal build all
$ cabal-docspec --timeout 60 --check-properties --property-variables xs
```
Use verbose mode to debug:
```
$ cabal run doctests --flag doctests -- --verbose
```
Run tests only for selected modules:
```
$ cabal run doctests --flag doctests -- --modules Streamly.Prelude
```
If it fails with a message that a particular modules is not loaded specify that
module as well on the command line.
## Naming of test modules
Tests are organized by source modules. For example, for the source