guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#35929] [PATCH] tests: hackage: avoid mock, and extract test data


From: Ludovic Courtès
Subject: [bug#35929] [PATCH] tests: hackage: avoid mock, and extract test data
Date: Wed, 29 May 2019 23:16:22 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux)

Hi Robert,

Robert Vollmert <address@hidden> skribis:

> +(define* (eval-test-with-cabal test-cabal package-pattern #:key 
> (cabal-environment '()))
> +  (define port (open-input-string test-cabal))
> +  (match (hackage->guix-package "foo" #:port port #:cabal-environment 
> cabal-environment)
> +    (package-pattern #t)

This pattern matches anything and binds the result to ‘package-pattern’:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> (let ((pattern '(a b)))
                       (match '(1 2 3) (pattern pattern)))
$9 = (1 2 3)
--8<---------------cut here---------------end--------------->8---

No more test failures!  :-)

The change you propose is a good idea but it needs to be implemented
using a macro:

--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 = #t
scheme@(guile-user)> (match-pattern '(1 2 3) (a b))
$15 = #f
scheme@(guile-user)> (match-pattern '(7 7) (a a))
$16 = #t
scheme@(guile-user)> (match-pattern '(1 2) (a a))
$17 = #f
--8<---------------cut here---------------end--------------->8---

HTH!

Ludo’.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]