From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39420) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4ejD-0001EC-Ca for guix-patches@gnu.org; Tue, 17 Oct 2017 23:09:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4ejB-0004OP-Un for guix-patches@gnu.org; Tue, 17 Oct 2017 23:09:07 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:38328) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e4ejB-0004OG-R8 for guix-patches@gnu.org; Tue, 17 Oct 2017 23:09:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1e4ejB-0004iI-LQ for guix-patches@gnu.org; Tue, 17 Oct 2017 23:09:05 -0400 Subject: [bug#28884] [PATCH 08/38] gnu: Add ghc-test-framework-th. Resent-Message-ID: From: rsiddharth Date: Wed, 18 Oct 2017 03:07:28 +0000 Message-Id: <20171018030758.1211-8-s@ricketyspace.net> In-Reply-To: <20171018030758.1211-1-s@ricketyspace.net> References: <20171018030217.1001-1-s@ricketyspace.net> <20171018030758.1211-1-s@ricketyspace.net> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 28884@debbugs.gnu.org Cc: s@ricketyspace.net * gnu/packages/haskell.scm (ghc-test-framework-th): New variable. --- gnu/packages/haskell.scm | 75 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/gnu/packages/haskell.scm b/gnu/packages/haskell.scm index 2f064e2b2..d4078a307 100644 --- a/gnu/packages/haskell.scm +++ b/gnu/packages/haskell.scm @@ -9237,4 +9237,79 @@ Example: ") (license license:bsd-3))) +(define-public ghc-test-framework-th + (package + (name "ghc-test-framework-th") + (version "0.2.4") + (source + (origin + (method url-fetch) + (uri (string-append "https://hackage.haskell.org/package/" + "test-framework-th-" version "/" + "test-framework-th-" version ".tar.gz")) + (sha256 + (base32 + "12lw7yj02jb9s0i7rb98jjam43j2h0gzmnbj9zi933fx7sg0sy4b")))) + (build-system haskell-build-system) + (inputs + `(("ghc-test-framework" ,ghc-test-framework) + ("ghc-language-haskell-extract" ,ghc-language-haskell-extract) + ("ghc-haskell-src-exts" ,ghc-haskell-src-exts) + ("ghc-regex-posix" ,ghc-regex-posix))) + (home-page "https://github.com/finnsson/test-generator") + (synopsis "Auto generate the HUnit- and Quickcheck-bulk-code +using Template Haskell") + (description "This library contains two functions: +@code{defaultMainGenerator} and @code{testGroupGenerator}. + +@code{defaultMainGenerator} will extract all functions beginning with +case_, prop_ or test_in the module and put them in a testGroup. + +@verbatim + -- file SomeModule.hs + \( -# LANGUAGE TemplateHaskell #- ) + module SomeModule where + import Test.Framework.TH + import Test.Framework + import Test.HUnit + import Test.Framework.Providers.HUnit + import Test.Framework.Providers.QuickCheck2 + + -- observe this line! + main = $\(defaultMainGenerator) + case_1 = do 1 @=? 1 + case_2 = do 2 @=? 2 + prop_reverse xs = reverse \(reverse xs) == xs + where types = xs::[Int] +@end verbatim + + is the same as + +@verbatim + -- file SomeModule.hs + \( -# LANGUAGE TemplateHaskell #- ) + module SomeModule where + import Test.Framework.TH + import Test.Framework + import Test.HUnit + import Test.Framework.Providers.HUnit + import Test.Framework.Providers.QuickCheck2 + + -- observe this line! + main = + defaultMain [ + testGroup \"SomeModule\" [ testCase \"1\" case_1, testCase \"2\" \ +case_2, testProperty \"reverse\" prop_reverse] + ] + case_1 = do 1 @=? 1 + case_2 = do 2 @=? 2 + prop_reverse xs = reverse \(reverse xs) == xs + where types = xs::[Int] +@end verbatim + +@code{testGroupGenerator} is like @code{defaultMainGenerator} but without +@code{defaultMain}. It is useful if you need a function for the testgroup +\(e.g. if you want to be able to call the testgroup from another module).") + (license license:bsd-3))) + ;;; haskell.scm ends here -- 2.15.0.rc0