[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: assert()ing in elisp

From: Giorgos Keramidas
Subject: Re: assert()ing in elisp
Date: Thu, 29 Jun 2006 20:12:00 +0300
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (berkeley-unix)

On Thu, 29 Jun 2006 06:26:09 -0700, Eric Hanchrow <> 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)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]