all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Sean McAfee <eefacm@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: ERT: should-error doesn't catch failed assertions
Date: Sun, 17 Jul 2016 15:24:21 -0700	[thread overview]
Message-ID: <87d1mb9a3u.fsf@gmail.com> (raw)

I've just begin trying to use ERT to write unit tests for my code.  I
got hung up almost immediately when trying to confirm that a particular
function call fails an assertion.  A simple example:

(should-error (cl-assert nil))

The assertion failure escapes the should-error form and causes a stack
trace.

Is there a way to catch assertion failures like this?

The code I'm testing implements a checksum of sorts that can only work
with strings of length exactly 5, ie:

(def my-checksum (str)
  (cl-assert (= 5 (length str)))
  ; ...
  )


             reply	other threads:[~2016-07-17 22:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-17 22:24 Sean McAfee [this message]
2016-07-17 22:57 ` ERT: should-error doesn't catch failed assertions Emanuel Berg
2016-07-17 23:29   ` Sean McAfee
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

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

  git send-email \
    --in-reply-to=87d1mb9a3u.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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.