unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* ERT: should-error doesn't catch failed assertions
@ 2016-07-17 22:24 Sean McAfee
  2016-07-17 22:57 ` Emanuel Berg
  2016-07-18  4:19 ` Noam Postavsky
  0 siblings, 2 replies; 5+ messages in thread
From: Sean McAfee @ 2016-07-17 22:24 UTC (permalink / raw)
  To: help-gnu-emacs

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)))
  ; ...
  )


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-07-18  4:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2016-07-18  0:42     ` Emanuel Berg
2016-07-18  4:19 ` Noam Postavsky

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).