unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Sean McAfee <eefacm@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: ERT: should-error doesn't catch failed assertions
Date: Sun, 17 Jul 2016 16:29:51 -0700	[thread overview]
Message-ID: <874m7n972o.fsf@gmail.com> (raw)
In-Reply-To: 86vb03rhy2.fsf@student.uu.se

Emanuel Berg <embe8573@student.uu.se> writes:
> Sean McAfee <eefacm@gmail.com> 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:

https://www.gnu.org/software/emacs/manual/html_node/ert/The-should-Macro.html#The-should-Macro

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	other threads:[~2016-07-17 23:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-17 22:24 ERT: should-error doesn't catch failed assertions Sean McAfee
2016-07-17 22:57 ` Emanuel Berg
2016-07-17 23:29   ` Sean McAfee [this message]
2016-07-18  0:42     ` Emanuel Berg
2016-07-18  4:19 ` Noam Postavsky

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/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874m7n972o.fsf@gmail.com \
    --to=eefacm@gmail.com \
    --cc=help-gnu-emacs@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).