tests and benchmarks cleanup
This commit is contained in:
parent
0df0bd17e0
commit
05ad021c99
6 changed files with 46 additions and 60 deletions
51
lish.cabal
51
lish.cabal
|
@ -4,7 +4,7 @@ cabal-version: 1.12
|
||||||
--
|
--
|
||||||
-- see: https://github.com/sol/hpack
|
-- see: https://github.com/sol/hpack
|
||||||
--
|
--
|
||||||
-- hash: 3a261bc10b55766ddf87ee6ac6a456e51b1f7b79b7b6514d18b7dc4f51c4b8eb
|
-- hash: b92e83b0e38dda1f7f335624325151ef2a4f95fbe2676a6e77d7bbea14b7e930
|
||||||
|
|
||||||
name: lish
|
name: lish
|
||||||
version: 0.1.0.0
|
version: 0.1.0.0
|
||||||
|
@ -43,7 +43,6 @@ library
|
||||||
, text
|
, text
|
||||||
exposed-modules:
|
exposed-modules:
|
||||||
Data.Stack
|
Data.Stack
|
||||||
Lib
|
|
||||||
Lish.Balanced
|
Lish.Balanced
|
||||||
Lish.Core
|
Lish.Core
|
||||||
Lish.Eval
|
Lish.Eval
|
||||||
|
@ -76,30 +75,6 @@ executable lish
|
||||||
, text
|
, text
|
||||||
default-language: Haskell2010
|
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
|
test-suite lish-doctest
|
||||||
type: exitcode-stdio-1.0
|
type: exitcode-stdio-1.0
|
||||||
main-is: Main.hs
|
main-is: Main.hs
|
||||||
|
@ -152,3 +127,27 @@ test-suite lish-test
|
||||||
Lish.Test.Parser
|
Lish.Test.Parser
|
||||||
Paths_lish
|
Paths_lish
|
||||||
default-language: Haskell2010
|
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
|
||||||
|
|
|
@ -59,6 +59,7 @@ tests:
|
||||||
- doctest >=0.10
|
- doctest >=0.10
|
||||||
- Glob >= 0.7
|
- Glob >= 0.7
|
||||||
- QuickCheck >= 2.5
|
- QuickCheck >= 2.5
|
||||||
|
benchmarks:
|
||||||
lish-benchmark:
|
lish-benchmark:
|
||||||
source-dirs: src-benchmark
|
source-dirs: src-benchmark
|
||||||
main: Main.hs
|
main: Main.hs
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
|
{-# LANGUAGE NoImplicitPrelude #-}
|
||||||
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
import Protolude
|
||||||
|
|
||||||
import Criterion
|
import Criterion
|
||||||
import Criterion.Main
|
import Criterion.Main
|
||||||
|
|
||||||
import Lib (inc)
|
import Lish.Parser (parseCmd)
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = defaultMain [bench "inc 41" (whnf inc (41 :: Int))]
|
main = defaultMain [bench "parseCmd (foo \"bar\")"
|
||||||
|
(whnf parseCmd ("(foo \"bar\")" :: Text))]
|
||||||
|
|
|
@ -14,13 +14,17 @@ import Test.Tasty.SmallCheck
|
||||||
import Lish.Parser
|
import Lish.Parser
|
||||||
import Lish.Types
|
import Lish.Types
|
||||||
|
|
||||||
parseTests :: [TestTree]
|
parseTests :: TestTree
|
||||||
parseTests =
|
parseTests =
|
||||||
[ testCase "simple commands" (simpleCommand "ls")
|
testGroup "simple commands"
|
||||||
, testCase "simple commands" (simpleCommand "atom")
|
[ testCase "ls" (simpleCommand "ls")
|
||||||
, testCase "simple commands" (simpleCommand "_foo")
|
, testCase "atom" (simpleCommand "atom")
|
||||||
, testCase "multiline command"
|
, testCase "_foo" (simpleCommand "_foo")
|
||||||
(parseCmd "(fn [x] ; comment \n (+ x 1))" @?= Right incExpr)
|
, 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
|
, testProperty "simple" propAtom
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -2,17 +2,18 @@ import Test.Tasty
|
||||||
import Test.Tasty.HUnit
|
import Test.Tasty.HUnit
|
||||||
import Test.Tasty.SmallCheck
|
import Test.Tasty.SmallCheck
|
||||||
|
|
||||||
import Lib (inc)
|
|
||||||
import Lish.Test.Parser
|
import Lish.Test.Parser
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = defaultMain $ testGroup "all-tests" tests
|
main = defaultMain $ testGroup "all-tests" tests
|
||||||
|
|
||||||
|
inc = (+1)
|
||||||
|
|
||||||
tests :: [TestTree]
|
tests :: [TestTree]
|
||||||
tests =
|
tests =
|
||||||
[ testGroup "SmallCheck" scTests
|
[ testGroup "SmallCheck" scTests
|
||||||
, testGroup "Unit tests" huTests
|
, testGroup "Unit tests" huTests
|
||||||
, testGroup "Lish.Parser" parseTests
|
, parseTests
|
||||||
]
|
]
|
||||||
|
|
||||||
scTests :: [TestTree]
|
scTests :: [TestTree]
|
||||||
|
|
24
src/Lib.hs
24
src/Lib.hs
|
@ -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
|
|
Loading…
Reference in a new issue