all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philipp Stephani <p.stephani2@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
Subject: Re: Dynamic modules: should should-error work?
Date: Mon, 23 Nov 2015 19:28:09 +0000	[thread overview]
Message-ID: <CAArVCkS_5WfW2jusjH5jxV8c2nvK-4cx=2hGmnM82Lqg4ht_8A@mail.gmail.com> (raw)
In-Reply-To: <838u5p3n32.fsf@gnu.org>


[-- Attachment #1.1: Type: text/plain, Size: 605 bytes --]

Eli Zaretskii <eliz@gnu.org> schrieb am So., 22. Nov. 2015 um 19:29 Uhr:

> It looks like should-error doesn't work with functions implemented in
> modules.  For example, try this in modules/mod-test/test.el:
>
>   (ert-deftest mod-test-sum-test ()
>     (should-error (mod-test-sum 1 2 3)))
>
> I cannot get this test to succeed, although the error message about
> wrong number of arguments is emitted.  What am I missing?
>
>
This works for me. Maybe there was some intermittent bug that has since
been fixed?
Anyway, this is a useful thing to test. I've attached a patch to add this
to the test suite.

[-- Attachment #1.2: Type: text/html, Size: 922 bytes --]

[-- Attachment #2: 0001-Add-test-for-argument-count-check.patch --]
[-- Type: application/octet-stream, Size: 1268 bytes --]

From 667fa4cff525604adbee7f5b920536b63987e72d Mon Sep 17 00:00:00 2001
From: Philipp Stephani <phst@google.com>
Date: Mon, 23 Nov 2015 20:27:07 +0100
Subject: [PATCH] Add test for argument count check

---
 modules/mod-test/mod-test.c | 2 ++
 modules/mod-test/test.el    | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/modules/mod-test/mod-test.c b/modules/mod-test/mod-test.c
index 44a14dc..b0c535c 100644
--- a/modules/mod-test/mod-test.c
+++ b/modules/mod-test/mod-test.c
@@ -42,6 +42,8 @@ sum (intmax_t a, intmax_t b)
 static emacs_value
 Fmod_test_sum (emacs_env *env, ptrdiff_t nargs, emacs_value args[], void *data)
 {
+  assert (nargs == 2);
+
   intmax_t a = env->extract_integer (env, args[0]);
   intmax_t b = env->extract_integer (env, args[1]);
 
diff --git a/modules/mod-test/test.el b/modules/mod-test/test.el
index 98ce464..d949fa4 100644
--- a/modules/mod-test/test.el
+++ b/modules/mod-test/test.el
@@ -28,7 +28,8 @@
 ;;
 
 (ert-deftest mod-test-sum-test ()
-  (should (= (mod-test-sum 1 2) 3)))
+  (should (= (mod-test-sum 1 2) 3))
+  (should-error (mod-test-sum 1 2 3) :type 'wrong-number-of-arguments))
 
 (ert-deftest mod-test-sum-docstring ()
   (should (string= (documentation 'mod-test-sum) "Return A + B")))
-- 
2.6.3


  reply	other threads:[~2015-11-23 19:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-22 18:28 Dynamic modules: should should-error work? Eli Zaretskii
2015-11-23 19:28 ` Philipp Stephani [this message]
2015-11-23 20:09   ` Eli Zaretskii
2015-11-24 19:27     ` Philipp Stephani
2015-11-24 19:32       ` Eli Zaretskii
2015-12-07 20:09         ` Philipp Stephani
2015-12-07 20:18           ` Eli Zaretskii
2015-11-24 19:15   ` Eli Zaretskii

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAArVCkS_5WfW2jusjH5jxV8c2nvK-4cx=2hGmnM82Lqg4ht_8A@mail.gmail.com' \
    --to=p.stephani2@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /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.
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.