From: Giorgos Keramidas <keramida@ceid.upatras.gr>
Subject: Re: assert()ing in elisp
Date: Thu, 29 Jun 2006 20:12:00 +0300 [thread overview]
Message-ID: <868xnfx4wv.fsf@gothmog.pc> (raw)
In-Reply-To: mailman.3510.1151588330.9609.help-gnu-emacs@gnu.org
On Thu, 29 Jun 2006 06:26:09 -0700, Eric Hanchrow <offby1@blarg.net> wrote:
> Here's one example:
> (defun assert= (expected actual)
> (when (not (string-equal expected actual))
> (error "expected %S; got %S" expected actual)))
Or you could use a macro, which can print the assertion
that failed too:
,----------------------------------------------------------------
| (defmacro assert (test-form)
| `(when (not ,test-form)
| (error "Assertion failed: %s" (format "%s" ',test-form))))
|
| (assert (equal t nil))
| =>
| Debugger entered--Lisp error: (error "Assertion failed: (equal t nil)")
| signal(error ("Assertion failed: (equal t nil)"))
| error("Assertion failed: %s" "(equal t nil)")
| (progn (error "Assertion failed: %s" (format "%s" ...)))
| (if (not (equal t nil)) (progn (error "Assertion failed: %s" ...)))
| (when (not (equal t nil)) (error "Assertion failed: %s" (format "%s" ...)))
| (assert (equal t nil))
| eval((assert (equal t nil)))
| eval-last-sexp-1(nil)
| eval-last-sexp(nil)
| call-interactively(eval-last-sexp)
`----------------------------------------------------------------
prev parent reply other threads:[~2006-06-29 17:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-29 10:05 assert()ing in elisp lalit mohan tripathi
2006-06-29 13:14 ` Kevin Rodgers
2006-06-29 13:26 ` Eric Hanchrow
[not found] ` <mailman.3510.1151588330.9609.help-gnu-emacs@gnu.org>
2006-06-29 17:12 ` Giorgos Keramidas [this message]
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=868xnfx4wv.fsf@gothmog.pc \
--to=keramida@ceid.upatras.gr \
/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).