From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:58032) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hWlnz-0002Kt-N4 for guix-patches@gnu.org; Fri, 31 May 2019 13:59:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hWlny-0001Uz-MB for guix-patches@gnu.org; Fri, 31 May 2019 13:59:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:50820) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hWlny-0001Uq-J2 for guix-patches@gnu.org; Fri, 31 May 2019 13:59:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hWlny-0005KX-Gk for guix-patches@gnu.org; Fri, 31 May 2019 13:59:02 -0400 Subject: [bug#35929] [PATCH] tests: hackage: avoid mock, and extract test data Resent-Message-ID: From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20190527194556.59710-1-rob@vllmrt.net> <87woi9rmft.fsf@gnu.org> Date: Fri, 31 May 2019 19:57:37 +0200 In-Reply-To: (Robert Vollmert's message of "Thu, 30 May 2019 13:42:33 +0200") Message-ID: <87pnnyqzfy.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: Robert Vollmert Cc: 35929@debbugs.gnu.org Hi, Robert Vollmert skribis: >> On 29. May 2019, at 23:16, Ludovic Court=C3=A8s wrote: >> --8<---------------cut here---------------start------------->8--- >> scheme@(guile-user)> (define-syntax-rule (match-pattern obj pattern) >> (match obj >> (pattern #t) >> (_ #f))) >> scheme@(guile-user)> (match-pattern '(1 2 3) (a b c)) >> $14 =3D #t >> scheme@(guile-user)> (match-pattern '(1 2 3) (a b)) >> $15 =3D #f >> scheme@(guile-user)> (match-pattern '(7 7) (a a)) >> $16 =3D #t >> scheme@(guile-user)> (match-pattern '(1 2) (a a)) >> $17 =3D #f >> --8<---------------cut here---------------end--------------->8=E2=80=94 > > Hmm, I can=E2=80=99t quite get this to work. I=E2=80=99d like to supply a= name for > the pattern, so I can reuse it across test cases, and I=E2=80=99m current= ly > at a loss for how to do tha: > > scheme@(ice-9 match)> (define pattern '(a b c)) > scheme@(ice-9 match)> (match-pattern '(a 2) pattern) > $30 =3D #t Indeed, =E2=80=98match=E2=80=99 expects patterns to be literals. So you ca= nnot do: (define pattern =E2=80=A6) and then use that pattern in =E2=80=98match=E2=80=99 clauses. If you wanted to do that, you would need to define a =E2=80=9Cprocedural=E2= =80=9D variant of =E2=80=98match=E2=80=99, which is not terribly difficult either,= but it=E2=80=99s a different beast. > I did manage to get things to work using eval, will send a revised > patch. Please don=E2=80=99t use =E2=80=98eval=E2=80=99; there=E2=80=99s a saying t= hat =E2=80=9Ceval is evil=E2=80=9D, because basically anything can happen when calling out to =E2=80=98eval=E2=80=99. So as it turns out, I realize that the factorization you wanted to make is not all that easy to achieve. Perhaps adding a procedural pattern matcher, which would be similar to =E2=80=98equal?=E2=80=99 except that it = would ignore the sha256, synopsis, and description, is the right way to go. HTH! Ludo=E2=80=99.