From: Tomas Volf <~@wolfsden.cz>
To: 74030@debbugs.gnu.org
Cc: Tomas Volf <~@wolfsden.cz>
Subject: bug#74030: [PATCH] srfi-64: Accept symbols as test group names.
Date: Sat, 26 Oct 2024 18:06:51 +0200 [thread overview]
Message-ID: <20241026160651.20915-1-~@wolfsden.cz> (raw)
The specification mandates a string, but with rationale suggesting symbols
would be a more natural fit.
> In some ways using symbols would be preferable. However, we want
> human-readable names, and standard Scheme does not provide a way to include
> spaces or mixed-case text in literal symbols.
Add support for symbols as implementation extension.
* module/srfi/srfi-64.scm (%cmp-group-name): New procedure.
(test-end): Use it.
---
module/srfi/srfi-64.scm | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/module/srfi/srfi-64.scm b/module/srfi/srfi-64.scm
index 1f60a72e5..98fcef645 100644
--- a/module/srfi/srfi-64.scm
+++ b/module/srfi/srfi-64.scm
@@ -522,7 +522,10 @@ returning new test runner. Defaults to @code{test-runner-simple}.")
(1+ (group-executed-count group)))))))
(define* (test-begin suite-name #:optional count)
- "Enter a new test group."
+ "Enter a new test group.
+
+As implementation extension, in addition to strings, symbols are also
+supported as @var{suite-name}."
(let* ((r (test-runner-current))
(r install? (if r
(values r #f)
@@ -544,6 +547,14 @@ returning new test runner. Defaults to @code{test-runner-simple}.")
((test-runner-on-group-begin r) r suite-name count)))
+(define (%cmp-group-name a b)
+ (match (list a b)
+ (((? string?) (? string?))
+ (string=? a b))
+ (((? symbol?) (? symbol?))
+ (eq? a b))
+ (_ #f)))
+
(define* (test-end #:optional suite-name)
"Leave the current test group."
(let* ((r (test-runner-current))
@@ -551,7 +562,7 @@ returning new test runner. Defaults to @code{test-runner-simple}.")
(let ((begin-name (car (test-runner-group-stack r)))
(end-name suite-name))
- (when (and end-name (not (string=? begin-name end-name)))
+ (when (and end-name (not (%cmp-group-name begin-name end-name)))
((test-runner-on-bad-end-name r) r begin-name end-name)
(raise-exception (make-bad-end-name begin-name end-name))))
--
2.46.0
next reply other threads:[~2024-10-26 16:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-26 16:06 Tomas Volf [this message]
2024-10-26 17:20 ` bug#74030: [PATCH] srfi-64: Accept symbols as test group names 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://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='20241026160651.20915-1-~@wolfsden.cz' \
--to=~@wolfsden.cz \
--cc=74030@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.
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).