doctest 0.10.1 → 0.11.0
raw patch · 4 files changed
+25/−21 lines, 4 filesdep +with-locationdep ~QuickCheckdep ~base-compatdep ~ghcPVP ok
version bump matches the API change (PVP)
Dependencies added: with-location
Dependency ranges changed: QuickCheck, base-compat, ghc
API changes (from Hackage documentation)
Files
- doctest.cabal +6/−4
- src/Extract.hs +6/−9
- src/Property.hs +9/−6
- src/Run.hs +4/−2
doctest.cabal view
@@ -1,5 +1,5 @@ name: doctest-version: 0.10.1+version: 0.11.0 synopsis: Test interactive Haskell examples description: The doctest program checks examples in source code comments. It is modeled after doctest for Python@@ -50,7 +50,8 @@ , Language.Haskell.GhciWrapper build-depends: base == 4.*- , ghc >= 7.0 && < 7.12+ , base-compat >= 0.4.2+ , ghc >= 7.0 && < 8.2 , syb >= 0.3 , deepseq , directory@@ -94,13 +95,14 @@ , ghc-paths , transformers - , base-compat >= 0.4.2+ , base-compat , HUnit , hspec >= 1.5.1- , QuickCheck >= 2.5+ , QuickCheck >= 2.8.2 , stringbuilder >= 0.4 , silently >= 1.2.4 , setenv+ , with-location test-suite doctests main-is:
src/Extract.hs view
@@ -27,10 +27,12 @@ import Exception (ExceptionMonad) import System.Directory import System.FilePath+ #if __GLASGOW_HASKELL__ < 710 import NameSet (NameSet)-#endif import Coercion (Coercion)+#endif+ import FastString (unpackFS) import Digraph (flattenSCCs) @@ -192,9 +194,11 @@ type Selector a = a -> ([(Maybe String, LHsDocString)], Bool) +#if __GLASGOW_HASKELL__ < 710 -- | Ignore a subtree. ignore :: Selector a ignore = const ([], True)+#endif -- | Collect given value and descend into subtree. select :: a -> ([a], Bool)@@ -208,7 +212,6 @@ #if __GLASGOW_HASKELL__ < 710 `extQ` (ignore :: Selector NameSet) `extQ` (ignore :: Selector PostTcKind)-#endif -- HsExpr never contains any documentation, but it may contain error thunks. --@@ -223,19 +226,13 @@ `extQ` (ignore :: Selector Coercion) #if __GLASGOW_HASKELL__ >= 706-#if __GLASGOW_HASKELL__ < 710 -- hswb_kvs and hswb_tvs may be error thunks `extQ` (ignore :: Selector (HsWithBndrs [LHsType RdrName])) `extQ` (ignore :: Selector (HsWithBndrs [LHsType Name])) `extQ` (ignore :: Selector (HsWithBndrs (LHsType RdrName))) `extQ` (ignore :: Selector (HsWithBndrs (LHsType Name)))-#else- -- hswb_kvs and hswb_tvs may be error thunks- `extQ` (ignore :: Selector (HsWithBndrs RdrName [LHsType RdrName]))- `extQ` (ignore :: Selector (HsWithBndrs Name [LHsType Name]))- `extQ` (ignore :: Selector (HsWithBndrs RdrName (LHsType RdrName)))- `extQ` (ignore :: Selector (HsWithBndrs Name (LHsType Name))) #endif+ #endif ) where
src/Property.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE PatternGuards #-} module Property ( runProperty , PropertyResult (..)@@ -9,6 +10,8 @@ ) where import Data.List+import Data.Maybe+import Data.Foldable import Util import Interpreter (Interpreter)@@ -53,15 +56,15 @@ -- | Parse and return all variables that are not in scope from a ghc error -- message.------ >>> parseNotInScope "<interactive>:4:1: Not in scope: `foo'"--- ["foo"] parseNotInScope :: String -> [String]-parseNotInScope = nub . map extractVariable . filter ("Not in scope: " `isInfixOf`) . lines+parseNotInScope = nub . mapMaybe extractVariable . lines where -- | Extract variable name from a "Not in scope"-error.- extractVariable :: String -> String- extractVariable = unquote . takeWhileEnd (/= ' ')+ extractVariable :: String -> Maybe String+ extractVariable x+ | "Not in scope: " `isInfixOf` x = Just . unquote . takeWhileEnd (/= ' ') $ x+ | Just y <- (asum $ map (stripPrefix "Variable not in scope: ") (tails x)) = Just (takeWhile (/= ' ') y)+ | otherwise = Nothing -- | Remove quotes from given name, if any. unquote ('`':xs) = init xs
src/Run.hs view
@@ -9,8 +9,10 @@ #endif ) where -import Data.List-import Control.Applicative ((<$>))+import Prelude ()+import Prelude.Compat++import Data.List.Compat import Control.Monad (when, unless) import System.Directory (doesFileExist, doesDirectoryExist, getDirectoryContents) import System.Environment (getEnvironment)