tests and benchmarks cleanup

This commit is contained in:
Yann Esposito (Yogsototh) 2019-09-07 14:13:04 +02:00
parent 0df0bd17e0
commit 05ad021c99
Signed by untrusted user who does not match committer: yogsototh
GPG key ID: 7B19A4C650D59646
6 changed files with 46 additions and 60 deletions

View file

@ -4,7 +4,7 @@ cabal-version: 1.12
--
-- see: https://github.com/sol/hpack
--
-- hash: 3a261bc10b55766ddf87ee6ac6a456e51b1f7b79b7b6514d18b7dc4f51c4b8eb
-- hash: b92e83b0e38dda1f7f335624325151ef2a4f95fbe2676a6e77d7bbea14b7e930
name: lish
version: 0.1.0.0
@ -43,7 +43,6 @@ library
, text
exposed-modules:
Data.Stack
Lib
Lish.Balanced
Lish.Core
Lish.Eval
@ -76,30 +75,6 @@ executable lish
, text
default-language: Haskell2010
test-suite lish-benchmark
type: exitcode-stdio-1.0
main-is: Main.hs
other-modules:
Paths_lish
hs-source-dirs:
src-benchmark
ghc-options: -Wall -O2 -threaded -rtsopts -with-rtsopts=-N
build-depends:
base >=4.8 && <5
, containers
, criterion >=1.1
, data-fix
, haskeline
, lish
, parsec >=3 && <4
, pipes
, pretty
, pretty-show
, process
, protolude
, text
default-language: Haskell2010
test-suite lish-doctest
type: exitcode-stdio-1.0
main-is: Main.hs
@ -152,3 +127,27 @@ test-suite lish-test
Lish.Test.Parser
Paths_lish
default-language: Haskell2010
benchmark lish-benchmark
type: exitcode-stdio-1.0
main-is: Main.hs
other-modules:
Paths_lish
hs-source-dirs:
src-benchmark
ghc-options: -Wall -O2 -threaded -rtsopts -with-rtsopts=-N
build-depends:
base >=4.8 && <5
, containers
, criterion >=1.1
, data-fix
, haskeline
, lish
, parsec >=3 && <4
, pipes
, pretty
, pretty-show
, process
, protolude
, text
default-language: Haskell2010

View file

@ -59,6 +59,7 @@ tests:
- doctest >=0.10
- Glob >= 0.7
- QuickCheck >= 2.5
benchmarks:
lish-benchmark:
source-dirs: src-benchmark
main: Main.hs

View file

@ -1,7 +1,12 @@
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
import Protolude
import Criterion
import Criterion.Main
import Lib (inc)
import Lish.Parser (parseCmd)
main :: IO ()
main = defaultMain [bench "inc 41" (whnf inc (41 :: Int))]
main = defaultMain [bench "parseCmd (foo \"bar\")"
(whnf parseCmd ("(foo \"bar\")" :: Text))]

View file

@ -14,13 +14,17 @@ import Test.Tasty.SmallCheck
import Lish.Parser
import Lish.Types
parseTests :: [TestTree]
parseTests :: TestTree
parseTests =
[ testCase "simple commands" (simpleCommand "ls")
, testCase "simple commands" (simpleCommand "atom")
, testCase "simple commands" (simpleCommand "_foo")
, testCase "multiline command"
(parseCmd "(fn [x] ; comment \n (+ x 1))" @?= Right incExpr)
testGroup "simple commands"
[ testCase "ls" (simpleCommand "ls")
, testCase "atom" (simpleCommand "atom")
, testCase "_foo" (simpleCommand "_foo")
, testCase "multiline"
(parseCmd "(fn [x]\n (+ x 1))" @?= Right incExpr)
-- TODO: or not? support line comment
-- , testCase "multiline command with comment"
-- (parseCmd "(fn [x] ; comment \n (+ x 1))" @?= Right incExpr)
, testProperty "simple" propAtom
]

View file

@ -2,17 +2,18 @@ import Test.Tasty
import Test.Tasty.HUnit
import Test.Tasty.SmallCheck
import Lib (inc)
import Lish.Test.Parser
main :: IO ()
main = defaultMain $ testGroup "all-tests" tests
inc = (+1)
tests :: [TestTree]
tests =
[ testGroup "SmallCheck" scTests
, testGroup "Unit tests" huTests
, testGroup "Lish.Parser" parseTests
, parseTests
]
scTests :: [TestTree]

View file

@ -1,24 +0,0 @@
-- | Example of a library file. It is also used for testing the test suites.
module Lib
(
-- * Exported functions
inc
) where
-- | Increment one 'Num' value.
--
-- >>> let answer = 42 :: Int
-- >>> let prev = answer - 1
-- >>> inc prev
-- 42
-- >>> succ . Prelude.last . Prelude.take prev . iterate inc $ 1
-- 42
--
-- Properties:
--
-- prop> succ x == inc x
-- prop> inc (negate x) == negate (pred x)
--
inc :: Num a => a -- ^ value to increment
-> a -- ^ result
inc x = x + 1