From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sean McAfee Newsgroups: gmane.emacs.help Subject: Re: ERT: should-error doesn't catch failed assertions Date: Sun, 17 Jul 2016 16:29:51 -0700 Organization: A noiseless patient Spider Message-ID: <874m7n972o.fsf@gmail.com> References: <87d1mb9a3u.fsf@gmail.com> <86vb03rhy2.fsf@student.uu.se> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1468798252 26510 80.91.229.3 (17 Jul 2016 23:30:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 17 Jul 2016 23:30:52 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jul 18 01:30:41 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bOvWC-0001VU-Os for geh-help-gnu-emacs@m.gmane.org; Mon, 18 Jul 2016 01:30:40 +0200 Original-Received: from localhost ([::1]:43401 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bOvWB-0003kP-Ua for geh-help-gnu-emacs@m.gmane.org; Sun, 17 Jul 2016 19:30:39 -0400 Original-Path: usenet.stanford.edu!news.glorb.com!feeder.erje.net!2.eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 30 Injection-Info: mx02.eternal-september.org; posting-host="bcb44ed1b062cc9c0e7688e840c91257"; logging-data="6928"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18cQemznKQRc+8ziVdtaC6Q98Wu1ZLGzwQ=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) Cancel-Lock: sha1:TQ7N4CZk/7HAvQm1NS7rCGQQ3Uk= sha1:TVDSCUZNcyvsib8/KZySl9TpYWA= Original-Xref: usenet.stanford.edu gnu.emacs.help:218566 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:110877 Archived-At: Emanuel Berg writes: > Sean McAfee 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.