[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] srfi-64: fix unused variable warnings
From: |
Maxime Devos |
Subject: |
Re: [PATCH] srfi-64: fix unused variable warnings |
Date: |
Thu, 01 Apr 2021 13:37:26 +0200 |
User-agent: |
Evolution 3.34.2 |
On Wed, 2021-03-31 at 23:11 -0700, Aleix Conchillo Flaqué wrote:
> * module/srfi/srfi-64/testing.scm: remove unused name variable and use
> let instead of let*.
>
I don't think this is the correct approach with respect to side effects.
For example, in:
> (define (%test-comp2 comp x)
> (syntax-case (list x (list (syntax quote) (%test-source-line2 x)) comp)
> ()
> (((mac tname expected expr) line comp)
> (syntax
> - (let* ((r (test-runner-get))
> - (name tname))
> + (let ((r (test-runner-get)))
> (test-result-alist! r (cons (cons 'test-name tname) line))
> (%test-comp2body r comp expected expr))))
I would keep the let* (but reverse the binding order), but change 'tname'
with 'name' in the call to 'test-result-alist!', such that 'test-X' macros
behave somewhat more like procedure calls (except for installing exeption
handlers and having access to the s-expression of the code that will be run,
of course). It's largely a matter of taste, though.
In any case, it is good that 'tname' is now evaluated only once, as per
SRFI-64 (notice ***It is evaluated only once.*** (markup mine)):
(test-assert [test-name] expression)
This evaluates the expression. The test passes if the result is true;
if the result is false, a test failure is reported. The test also fails
if an exception is raised, assuming the implementation has a way to catch
exceptions. How the failure is reported depends on the test runner environment.
The test-name is a string that names the test case. (Though the test-name is
a string literal in the examples, it is an expression. ***It is evaluated only
once.***)
It is used when reporting errors, and also when skipping tests, as described
below.
It is an error to invoke test-assert if there is no current test runner.
(My suggestion would be to also evaluate 'test-name' at least once, even if
there
is no test runner, which seems a bit stricter than SRFI-64 demands, but seems
like
a nice property to have and easy to achieve.)
As this patch does not ‘merely’ fix a warnings, but fixes a bug, could you
change
the patch message accordingly? Something like
srfi-64: fix double evaluation of test-name.
perhaps?
Greetings,
Maxime.
signature.asc
Description: This is a digitally signed message part