From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id cM+jOtK7vl+mSAAA0tVLHw (envelope-from ) for ; Wed, 25 Nov 2020 20:17:22 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id UBKPNtK7vl8ZAwAAB5/wlQ (envelope-from ) for ; Wed, 25 Nov 2020 20:17:22 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9BD03940148 for ; Wed, 25 Nov 2020 20:17:22 +0000 (UTC) Received: from localhost ([::1]:58294 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ki1E9-0004Mu-Ii for larch@yhetil.org; Wed, 25 Nov 2020 15:17:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41480) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ki1Ds-00040w-0d for guix-patches@gnu.org; Wed, 25 Nov 2020 15:17:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:53885) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ki1Dr-00064H-Kp for guix-patches@gnu.org; Wed, 25 Nov 2020 15:17:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ki1Dr-0008Bg-Gu for guix-patches@gnu.org; Wed, 25 Nov 2020 15:17:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#44873] [PATCH 3/6] gnu: Add ghc-easytest. Resent-From: Carlo Holl Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 25 Nov 2020 20:17:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44873 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 44873@debbugs.gnu.org Cc: Carlo Holl Received: via spool by 44873-submit@debbugs.gnu.org id=B44873.160633542031426 (code B ref 44873); Wed, 25 Nov 2020 20:17:03 +0000 Received: (at 44873) by debbugs.gnu.org; 25 Nov 2020 20:17:00 +0000 Received: from localhost ([127.0.0.1]:37191 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ki1Dn-0008An-S9 for submit@debbugs.gnu.org; Wed, 25 Nov 2020 15:17:00 -0500 Received: from mail-pf1-f171.google.com ([209.85.210.171]:43502) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ki1Dh-00089g-Hv for 44873@debbugs.gnu.org; Wed, 25 Nov 2020 15:16:57 -0500 Received: by mail-pf1-f171.google.com with SMTP id w202so3378307pff.10 for <44873@debbugs.gnu.org>; Wed, 25 Nov 2020 12:16:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9C/YC2YYdfg/RGWuqQUdb6vbb5NOfJkBgVoS8DuvZjM=; b=dWkqZLhlxNyNdpIR4CjzKhRuGu8+IfphN+2vsaloTUIgC8q5wdA5O7g2VSbtknlwom 97ZqQ7xdLPx75/nQapC70F7rRG5j7PpMdkhUOCdgc/2e5DvYTvT2OcANO+DKP4uUGqDb cOY3SJSq9d2PnNrWxwO7gFmp8+4LPuKySJ3bYLW8zixDAJQ7TJoUbfAgw2tIDM3v7Bvd axKW3CA0U/szkTvf3e3IU0j6uwzUYGSDiG1tuhVqBykYWXd12ieXoDQaIBgX7z2GDK6K /d0dkaz1+agVwXMV6Zjc3a3mmspvWmmq6HxDVtSTcS7Ibt1xO92qsPakMD5P4zN6q20s gcag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9C/YC2YYdfg/RGWuqQUdb6vbb5NOfJkBgVoS8DuvZjM=; b=JC4xKyC60mBme6PRNXETKZ+5UYwLu8KZVtsqcwdVxVlQckWtNb6G4AsPQ640FbeUiM uRsf/mwmzOuTKhyWbGN1Wp+AAFOqnX7CJ1ua/rnSc4akCa2GeakT28EOzcquCJAa+DXr RtvGD+Ww4symBtYlrvfJs+k+JMvVwZgQk9vj5+c/6lJ8hGN3BERfnrGlnffTZM0Tg7HN YtdjYrwc98QyXcknCr4uHyiQQoizWkajlm+bzxOr6VQepSTW6xda7JG5CZreuKe1MAbI T5YJgES/U25ZeFQoG5OZeHzugLS2h04YXk77pZzTkPXeU0MXH//LDFbo39Sy776tE0Pf 71Xg== X-Gm-Message-State: AOAM530q8eo16JyMVZXKkEpbJQXO5xbylNtNFwurZ4HpvJiXQfpichjI wLBYC5VDEs0uLin0PxaZc2B2fnFetoU= X-Google-Smtp-Source: ABdhPJwwbG7aSuXOokQYFEtjciEnMWEJ5JI33OUl4vlh+tkifNezFTC5O76ynABtoK+71+4YUT2BIQ== X-Received: by 2002:a63:4912:: with SMTP id w18mr2963002pga.9.1606335407401; Wed, 25 Nov 2020 12:16:47 -0800 (PST) Received: from cehdev.hsd1.ca.comcast.net ([2603:3024:1704:300::8401]) by smtp.gmail.com with ESMTPSA id u24sm2931036pfm.81.2020.11.25.12.16.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 12:16:46 -0800 (PST) From: Carlo Holl Date: Wed, 25 Nov 2020 12:16:35 -0800 Message-Id: <20201125201638.2044-3-carloholl@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201125201638.2044-1-carloholl@gmail.com> References: <20201125201638.2044-1-carloholl@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.0 (-) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=fail (headers rsa verify failed) header.d=gmail.com header.s=20161025 header.b=dWkqZLhl; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: 1.09 X-TUID: pclRO4HaYW5q * 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 ;;; Copyright © 2019 Timothy Sample ;;; Copyright © 2020 John Soo +;;; Copyright © 2020 Carlo Holl ;;; ;;; 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