From: "Ludovic Courtès" <ludo@gnu.org>
To: Robert Vollmert <rob@vllmrt.net>
Cc: 35929@debbugs.gnu.org
Subject: [bug#35929] [PATCH] tests: hackage: avoid mock, and extract test data
Date: Fri, 31 May 2019 19:57:37 +0200 [thread overview]
Message-ID: <87pnnyqzfy.fsf@gnu.org> (raw)
In-Reply-To: <F6D6D763-DEB1-4833-9C81-62EBEC605711@vllmrt.net> (Robert Vollmert's message of "Thu, 30 May 2019 13:42:33 +0200")
Hi,
Robert Vollmert <rob@vllmrt.net> skribis:
>> On 29. May 2019, at 23:16, Ludovic Courtès <ludo@gnu.org> 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 = #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—
>
> Hmm, I can’t quite get this to work. I’d like to supply a name for
> the pattern, so I can reuse it across test cases, and I’m currently
> 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 = #t
Indeed, ‘match’ expects patterns to be literals. So you cannot do:
(define pattern …)
and then use that pattern in ‘match’ clauses.
If you wanted to do that, you would need to define a “procedural”
variant of ‘match’, which is not terribly difficult either, but it’s a
different beast.
> I did manage to get things to work using eval, will send a revised
> patch.
Please don’t use ‘eval’; there’s a saying that “eval is evil”, because
basically anything can happen when calling out to ‘eval’.
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 ‘equal?’ except that it would ignore
the sha256, synopsis, and description, is the right way to go.
HTH!
Ludo’.
next prev parent reply other threads:[~2019-05-31 17:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-27 19:45 [bug#35929] [PATCH] tests: hackage: avoid mock, and extract test data Robert Vollmert
2019-05-29 21:16 ` Ludovic Courtès
2019-05-29 21:25 ` Robert Vollmert
2019-05-30 11:42 ` Robert Vollmert
2019-05-31 17:57 ` Ludovic Courtès [this message]
2019-05-30 11:46 ` [bug#35929] [PATCH 1/2] tests: hackage: Factor out package pattern Robert Vollmert
2019-05-30 11:46 ` [bug#35929] [PATCH 2/2] tests: hackage: Don't mock hackage-fetch Robert Vollmert
2019-05-31 19:36 ` [bug#35929] [PATCH 1/2] tests: hackage: Factor out package pattern Robert Vollmert
2019-05-31 19:36 ` [bug#35929] [PATCH 2/2] tests: hackage: Don't mock hackage-fetch Robert Vollmert
2019-05-31 21:22 ` [bug#35929] [PATCH 1/3] tests: hackage: Factor out package pattern Robert Vollmert
2019-05-31 21:22 ` [bug#35929] [PATCH 2/3] tests: hackage: Don't mock hackage-fetch Robert Vollmert
2019-05-31 21:22 ` [bug#35929] [PATCH 3/3] tests: Indent hackage tests Robert Vollmert
2019-05-31 21:23 ` [bug#35929] [PATCH 1/3] tests: hackage: Factor out package pattern Robert Vollmert
2019-06-01 12:53 ` bug#35929: " Ludovic Courtès
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=87pnnyqzfy.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=35929@debbugs.gnu.org \
--cc=rob@vllmrt.net \
/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).