unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Carlo Holl <carloholl@gmail.com>
To: 44873@debbugs.gnu.org
Cc: Carlo Holl <carloholl@gmail.com>
Subject: [bug#44873] [PATCH 3/6] gnu: Add ghc-easytest.
Date: Wed, 25 Nov 2020 12:16:35 -0800	[thread overview]
Message-ID: <20201125201638.2044-3-carloholl@gmail.com> (raw)
In-Reply-To: <20201125201638.2044-1-carloholl@gmail.com>

* gnu/packages/haskell-check.scm (ghc-easytest): New variable
---
 gnu/packages/haskell-check.scm | 75 ++++++++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)

diff --git a/gnu/packages/haskell-check.scm b/gnu/packages/haskell-check.scm
index b5546f97f8..b61846f55f 100644
--- a/gnu/packages/haskell-check.scm
+++ b/gnu/packages/haskell-check.scm
@@ -12,6 +12,7 @@
 ;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
 ;;; Copyright © 2019 Timothy Sample <samplet@ngyro.com>
 ;;; Copyright © 2020 John Soo <jsoo1@asu.edu>
+;;; Copyright © 2020 Carlo Holl <carloholl@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1038,3 +1039,77 @@ regular development cycle and regressions caught early.
 See the documentation in \"Test.Inspection\" or the project webpage for more
 examples and more information.")
     (license license:expat)))
+
+(define-public ghc-easytest
+  (package
+    (name "ghc-easytest")
+    (version "0.2.1")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append
+             "https://hackage.haskell.org/package/easytest/easytest-"
+             version
+             ".tar.gz"))
+       (sha256
+        (base32
+         "0gdyawzlw6d15yz7ji599xjgfr0g7l1iq11ffr4aw3j6g3dc6m8i"))))
+    (build-system haskell-build-system)
+    (inputs
+     `(("ghc-async" ,ghc-async)
+       ("ghc-random" ,ghc-random)
+       ("ghc-call-stack" ,ghc-call-stack)))
+    (home-page "https://github.com/joelburget/easytest")
+    (synopsis "Simple, expressive testing library")
+    (description "EasyTest is a simple testing toolkit, meant to replace most
+uses of QuickCheck, SmallCheck, HUnit, and frameworks like Tasty, etc.
+Here's an example usage:
+
+@example
+
+module Main where
+
+import EasyTest
+import Control.Applicative
+import Control.Monad
+
+suite :: Test ()
+suite = tests
+  [ scope \"addition.ex1\" $ expect (1 + 1 == 2)
+  , scope \"addition.ex2\" $ expect (2 + 3 == 5)
+  , scope \"list.reversal\" . fork $ do
+      -- generate lists from size 0 to 10, of Ints in (0,43)
+      -- shorthand: listsOf [0..10] (int' 0 43)
+      ns <- [0..10] `forM` \\n -> replicateM n (int' 0 43)
+      ns `forM_` \\ns -> expect (reverse (reverse ns) == ns)
+  -- equivalent to `scope \"addition.ex3\"`
+  , scope \"addition\" . scope \"ex3\" $ expect (3 + 3 == 6)
+  , scope \"always passes\" $ do
+      note \"I'm running this test, even though it always passes!\"
+      ok -- like `pure ()`, but records a success result
+  , scope \"failing test\" $ crash \"oh noes!!\" ]
+
+-- NB: `run suite` would run all tests, but we only run
+-- tests whose scopes are prefixed by \"addition\"
+main = runOnly \"addition\" suite
+
+@end example
+
+This generates the output:
+
+@example
+
+Randomness seed for this run is 5104092164859451056
+Raw test output to follow ...
+------------------------------------------------------------
+OK addition.ex1
+OK addition.ex2
+OK addition.ex3
+------------------------------------------------------------
+3 tests passed, no failures!
+
+@end example
+
+The idea here is to write tests with ordinary Haskell code, with
+control flow explicit and under programmer control.")
+    (license license:expat)))
-- 
2.29.2





  parent reply	other threads:[~2020-11-25 20:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-25 20:10 [bug#44873] [PATCH 0/6] Fix Haskell packages incompatible with latest LTSHaskell release Carlo Holl
2020-11-25 20:16 ` [bug#44873] [PATCH 1/6] gnu: ghc-tabular: Downgrade to 0.2.2.7 Carlo Holl
2020-11-25 20:16   ` [bug#44873] [PATCH 2/6] gnu: ghc-doctest: Downgrade to 0.16.2 Carlo Holl
2020-11-25 20:16   ` Carlo Holl [this message]
2020-11-25 20:16   ` [bug#44873] [PATCH 4/6] gnu: ghc-hledger-lib: Downgrade to 0.14.1 Carlo Holl
2020-11-25 20:16   ` [bug#44873] [PATCH 5/6] gnu: hledger: Downgrade to 1.14.2 Carlo Holl
2020-11-25 20:16   ` [bug#44873] [PATCH 6/6] gnu: ghc-cassava-megaparsec: Downgrade to 2.0.1 Carlo Holl
2020-11-26  2:07 ` bug#44873: [PATCH 0/6] Fix Haskell packages incompatible with latest LTSHaskell release Leo Famulari
2020-11-26 17:51   ` [bug#44873] " Carlo Holl
2020-11-26 18:53     ` Leo Famulari

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201125201638.2044-3-carloholl@gmail.com \
    --to=carloholl@gmail.com \
    --cc=44873@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).