[Top][All Lists]

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

Re: ERT: should-error doesn't catch failed assertions

From: Sean McAfee
Subject: Re: ERT: should-error doesn't catch failed assertions
Date: Sun, 17 Jul 2016 16:29:51 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

Emanuel Berg <address@hidden> writes:
> Sean McAfee <address@hidden> writes:
>> (should-error (cl-assert nil))
> What is "should-error"?

It's part of ERT, Emacs Lisp Regression Testing, mentioned in the
subject.  should-error is documented here:

As described on that page, I see (should-error (/ 1 0)) evaluate to
(arith-error).  But assertion failures seem to not count as "errors" as
far as should-error is concerned.

>> (def my-checksum (str) (cl-assert (= 5 (length
>> str))) ; ... )
> With `defun' instead of "def", your code works:

Ah yes, I dashed that off a little too quickly.  Apologies.

> In this case you can have an ordinary `if' form
> with an `error' if the string length is
> inconsistent with the the purpose of
> the function.

I could, but I'm a little leery of letting my testing framework dictate
how I write my code.

reply via email to

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