all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / 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

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.