A peer-to-peer stack for code collaboration
Doctests
Julian K. Arni32d0b8598424
diff --git a/package.yaml b/package.yamlindex 9e5396a..a6d8fd0 100644--- a/package.yaml+++ b/package.yaml@@ -25,10 +25,9 @@ tests:spec:main: Main.hssource-dirs:- - test- ghc-options: -Wall+ - test/spec+ ghc-options: -Wall -threadeddependencies:- - base- radicle- QuickCheck- quickcheck-instances@@ -37,6 +36,18 @@ tests:- tasty-discover- tasty-hunit- tasty-quickcheck+ doctest:+ main: Main.hs+ source-dirs:+ - test/docs+ ghc-options: -Wall -threaded+ other-modules:+ - Paths_radicle+ dependencies:+ - radicle+ - doctest+ - Glob+ - hpackdefault-extensions:- AutoDeriveTypeablediff --git a/radicle.cabal b/radicle.cabalindex 706bc6f..c4bf5eb 100644--- a/radicle.cabal+++ b/radicle.cabal@@ -2,7 +2,7 @@---- see: https://github.com/sol/hpack----- hash: fd7a7108d97bdcf99bc499773b87517e72a468ea57d246e1cf78558c72d6922f+-- hash: 650d134dbbffbd2db37d84261d172a107bc0865d8252df4b363e7bdca4bedeb5name: radicleversion: 0.0.0@@ -45,16 +45,39 @@ libraryPaths_radicledefault-language: Haskell2010+test-suite doctest+ type: exitcode-stdio-1.0+ main-is: Main.hs+ hs-source-dirs:+ test/docs+ default-extensions: AutoDeriveTypeable DeriveDataTypeable DeriveFunctor DeriveGeneric GeneralizedNewtypeDeriving FlexibleContexts OverloadedStrings TupleSections TypeFamilies TypeOperators RankNTypes RecordWildCards+ ghc-options: -Wall -threaded+ build-depends:+ Glob+ , base >=4 && <5+ , containers+ , doctest+ , hpack+ , megaparsec+ , mmorph+ , mtl+ , prettyprinter+ , radicle+ , text+ other-modules:+ Paths_radicle+ default-language: Haskell2010+test-suite spectype: exitcode-stdio-1.0main-is: Main.hshs-source-dirs:- test+ test/specdefault-extensions: AutoDeriveTypeable DeriveDataTypeable DeriveFunctor DeriveGeneric GeneralizedNewtypeDeriving FlexibleContexts OverloadedStrings TupleSections TypeFamilies TypeOperators RankNTypes RecordWildCards- ghc-options: -Wall+ ghc-options: -Wall -threadedbuild-depends:QuickCheck- , base+ , base >=4 && <5, containers, megaparsec, mmorphdiff --git a/src/Radicle/Internal/Parse.hs b/src/Radicle/Internal/Parse.hsindex 2e738a1..7d7d936 100644--- a/src/Radicle/Internal/Parse.hs+++ b/src/Radicle/Internal/Parse.hs@@ -105,6 +105,11 @@ valueP = do-- * Utilities-- | Parse and evaluate a Text.+--+-- Examples:+--+-- >>> interpret "test" "((lambda (x) x) #t)"+-- Right (Boolean True)interpret :: String -> Text -> Either LangError Valueinterpret sourceName expr = doparsed <- first ParseError $ parse valueP sourceName exprdiff --git a/src/Radicle/Internal/Pretty.hs b/src/Radicle/Internal/Pretty.hsindex 458f26c..17fc57a 100644--- a/src/Radicle/Internal/Pretty.hs+++ b/src/Radicle/Internal/Pretty.hs@@ -31,13 +31,31 @@ instance Pretty Value whereescapeStr = T.replace "\"" "\\\"" . T.replace "\\" "\\\\"-- | A fast and compact layout. Primarily intended for testing.+--+-- Examples:+--+-- >>> renderCompactPretty (List [String "hi", String "there"])+-- "'(\"hi\"\n\"there\")"renderCompactPretty :: Value -> TextrenderCompactPretty = renderStrict . layoutCompact . pretty-- | Render prettily into text, with specified width.+--+-- Examples:+--+-- >>> renderPretty Unbounded (List [String "hi", String "there"])+-- "'(\"hi\" \"there\")"+--+-- >>> renderPretty (AvailablePerLine 6 0.5) (List [String "hi", String "there"])+-- "'(\"hi\"\n\"there\")"renderPretty :: PageWidth -> Value -> TextrenderPretty pg = renderStrict . layoutSmart (LayoutOptions pg) . pretty-- | 'renderPretty', but with default layout options (80 chars, 1.0 ribbon)+--+-- Examples:+--+-- >>> renderPrettyDef (List [String "hi", String "there"])+-- "'(\"hi\" \"there\")"renderPrettyDef :: Value -> TextrenderPrettyDef = renderStrict . layoutSmart defaultLayoutOptions . prettydiff --git a/test/docs/Main.hs b/test/docs/Main.hsnew file mode 100644index 0000000..e69131c--- /dev/null+++ b/test/docs/Main.hs@@ -0,0 +1,12 @@+module Main (main) where++import System.FilePath.Glob (glob)+import Test.DocTest+import Hpack.Config++main :: IO ()+main = do+ Right pkg <- fmap decodeResultPackage <$> readPackageConfig defaultDecodeOptions+ let Just exts = fmap sectionDefaultExtensions $ packageLibrary pkg+ srcs <- glob "src/**/*.hs"+ doctest $ srcs ++ fmap ("-X" ++) extsdiff --git a/test/Main.hs b/test/spec/Main.hssimilarity index 100%rename from test/Main.hsrename to test/spec/Main.hsdiff --git a/test/Radicle/Internal/Arbitrary.hs b/test/spec/Radicle/Internal/Arbitrary.hssimilarity index 100%rename from test/Radicle/Internal/Arbitrary.hsrename to test/spec/Radicle/Internal/Arbitrary.hsdiff --git a/test/Radicle/Tests.hs b/test/spec/Radicle/Tests.hssimilarity index 100%rename from test/Radicle/Tests.hsrename to test/spec/Radicle/Tests.hs