summaryrefslogtreecommitdiff
path: root/libraries/base/Text
diff options
context:
space:
mode:
authorOleg Grenrus <oleg.grenrus@iki.fi>2020-12-26 00:28:12 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-01-02 07:36:33 -0500
commitaa17b84dab91408090f079f85d62ef3221f4ab88 (patch)
treed018205fc9de5d52039d3f2be1041d297efc4c29 /libraries/base/Text
parent4c178374983dddb75341352aef1d15658a82463b (diff)
downloadhaskell-aa17b84dab91408090f079f85d62ef3221f4ab88.tar.gz
Correct doctests
It's simpler to assume that base is NoImplicitPrelude, otherwise running doctest on `GHC.*` modules would be tricky. OTOH, most `GHC.List` (where the most name clashes are) examples could be changed to use `import qualified Data.List as L`. (GHC.List examples won't show for Foldable methods...). With these changes majority of doctest examples are GHCi-"faithful", my WIP GHC-independent doctest runner reports nice summary: Examples: 582; Tried: 546; Skipped: 34; Success: 515; Errors: 33; Property Failures 2 Most error cases are *Hangs forever*. I have yet to figure out how to demonstrate that in GHCi. Some of divergences are actually stack overflows, i.e. caught by runtime. Few errorful cases are examples of infinite output, e.g. >>> cycle [42] [42,42,42,42,42,42,42,42,42,42... while correct, they confuse doctest. Another erroneous cases are where expected output has line comment, like >>> fmap show (Just 1) -- (a -> b) -> f a -> f b Just "1" -- (Int -> String) -> Maybe Int -> Maybe String I think I just have to teach doctest to strip comments from expected output. This is a first patch in a series. There is plenty of stuff already.
Diffstat (limited to 'libraries/base/Text')
-rw-r--r--libraries/base/Text/Printf.hs3
-rw-r--r--libraries/base/Text/Read.hs3
2 files changed, 6 insertions, 0 deletions
diff --git a/libraries/base/Text/Printf.hs b/libraries/base/Text/Printf.hs
index 216c29d9e3..4fa9fd7720 100644
--- a/libraries/base/Text/Printf.hs
+++ b/libraries/base/Text/Printf.hs
@@ -100,6 +100,9 @@ import Numeric
import Numeric.Natural
import System.IO
+-- $setup
+-- >>> import Prelude
+
-------------------
-- | Format a variable number of arguments with the C-style formatting string.
diff --git a/libraries/base/Text/Read.hs b/libraries/base/Text/Read.hs
index c79b7c15b2..1e852a090c 100644
--- a/libraries/base/Text/Read.hs
+++ b/libraries/base/Text/Read.hs
@@ -51,6 +51,9 @@ import Text.ParserCombinators.ReadP as P
import Text.ParserCombinators.ReadPrec
import qualified Text.Read.Lex as L
+-- $setup
+-- >>> import Prelude
+
------------------------------------------------------------------------
-- utility functions