fix tests + generative tests
This commit is contained in:
parent
f0301d3c4e
commit
e6207fd301
3 changed files with 23 additions and 7 deletions
|
@ -56,13 +56,14 @@ test-suite lish-test
|
|||
default-language: Haskell2010
|
||||
ghc-options: -Wall -Werror -O2 -threaded -rtsopts -with-rtsopts=-N
|
||||
hs-source-dirs: src-test
|
||||
exposed-modules: Lish.Test.Parser
|
||||
main-is: Main.hs
|
||||
other-modules: Lish.Test.Parser
|
||||
build-depends: base >= 4.8 && < 5
|
||||
, tasty >= 0.11
|
||||
, tasty-hunit >= 0.9
|
||||
, tasty-smallcheck >= 0.8
|
||||
, lish
|
||||
, protolude
|
||||
|
||||
test-suite lish-doctest
|
||||
type: exitcode-stdio-1.0
|
||||
|
|
|
@ -8,12 +8,26 @@ import Test.Tasty
|
|||
import Test.Tasty.HUnit
|
||||
import Test.Tasty.SmallCheck
|
||||
|
||||
|
||||
import Lish.Parser
|
||||
import Lish.Types
|
||||
|
||||
parseTests :: [TestTree]
|
||||
parseTests =
|
||||
[ testCase "simple commands" simpleCommand ]
|
||||
[ testCase "simple commands" (simpleCommand "ls")
|
||||
, testCase "simple commands" (simpleCommand "atom")
|
||||
, testCase "simple commands" (simpleCommand "_foo")
|
||||
, testProperty "simple" propAtom
|
||||
]
|
||||
|
||||
simpleCommand :: Assertion
|
||||
simpleCommand = parseCmd "ls" @?= Right (Atom "ls")
|
||||
simpleCommand :: Text -> Assertion
|
||||
simpleCommand t = parseCmd t @?= Right (Atom t)
|
||||
|
||||
propAtom :: [Char] -> Bool
|
||||
propAtom s = s == "" ||
|
||||
fromMaybe '0' (head s) `elem` ("0123456789([])" :: [Char]) ||
|
||||
case s of
|
||||
"true" -> parseCmd t == Right (Bool True)
|
||||
"false" -> parseCmd t == Right (Bool False)
|
||||
_ -> parseCmd t == Right (Atom t)
|
||||
where t = toS s
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
module Lish.Types
|
||||
( SExp(..)
|
||||
, show
|
||||
, repr
|
||||
, Env
|
||||
, CmdStream
|
||||
, Command
|
||||
|
@ -31,10 +32,10 @@ data SExp = Atom Text
|
|||
}
|
||||
| Stream CmdStream
|
||||
| WaitingStream CmdStream
|
||||
deriving (Eq)
|
||||
deriving (Eq,Show)
|
||||
|
||||
instance Show SExp where
|
||||
show = toS . repr
|
||||
-- instance Show SExp where
|
||||
-- show = toS . repr
|
||||
|
||||
repr :: SExp -> Text
|
||||
repr (Atom s) = s
|
||||
|
|
Loading…
Reference in a new issue