testCom: Write your tests in comments

[ deprecated, library, test ] [ Propose Tags ] [ Report a vulnerability ]
Deprecated in favor of doctest

With some TemplateHaskell magic, you can write your tests in your comments directly above a function declaration with a minimalistic syntax.


[Skip to Readme]

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0, 0.1.1, 0.2.0, 0.3.0
Change log ChangeLog.md
Dependencies base (>=4.9 && <4.11), haskell-src-meta (>=0.8.0.1), random (>=1.1), template-haskell (>=2.11.1.0) [details]
License LicenseRef-GPL
Author Alexandre Moine
Maintainer nobrakal@cthugha.org
Category Test
Bug tracker https://github.com/nobrakal/testCom/issues
Source repo head: git clone git://github.com/nobrakal/testCom.git
Uploaded by nobrakal at 2017-10-31T09:39:48Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 2540 total (12 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-10-31 [all 1 reports]

Readme for testCom-0.3.0

[back to package description]

testCom

How to use it

Write your tests

Above a function to test, write your tests like this:

--[1 2] [3]
--O[add 1 2] [3]
--S[x@Int y@Int] [x@ + y@] [10]
add :: Int -> Int -> Int
add x y = x+y

Syntax

  • Without any prefix: [args For The Function] [ExpectedResult]
  • With a O (Override) prefix: [custom Function To Test] [ExpectedResult]
  • With a S (Specification) prefix: [args Involving variable@Type] [ExpectedResult Maybe Involving variable@] [numberOfTestToDo] (for now only basic types are supported: Int Char and Bool). variable@Type MUST be surrounded by spaces.

Run them

For example

{-# LANGUAGE TemplateHaskell #-}

import Language.Haskell.TH
import Language.Haskell.TH.Syntax
import System.Exit

$(makeAllTestsHere)
$(makeAllTests "some/Path/File.hs")

-- Tests
main :: IO ()
main = do
  let (str,res) = _TEST_path -- Here, path=directory_actualfile. If your file is put in tests/Main.hs, then path=tests_Main (without the ".hs")
  let (str',res') = _TEST_some_Path_File
  putStrLn str
  putStrLn str'
  if res && res' then exitSuccess else exitFailure