From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Dynamic modules: should should-error work? Date: Mon, 23 Nov 2015 22:09:16 +0200 Message-ID: <83si3wzdeb.fsf@gnu.org> References: <838u5p3n32.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1448309405 11944 80.91.229.3 (23 Nov 2015 20:10:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 23 Nov 2015 20:10:05 +0000 (UTC) Cc: emacs-devel@gnu.org To: Philipp Stephani Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Nov 23 21:09:56 2015 Return-path: Envelope-to: ged-emacs-devel@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 1a0xQZ-00034t-2L for ged-emacs-devel@m.gmane.org; Mon, 23 Nov 2015 21:09:32 +0100 Original-Received: from localhost ([::1]:34404 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a0xQZ-0003G6-QN for ged-emacs-devel@m.gmane.org; Mon, 23 Nov 2015 15:09:31 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a0xQW-0003Dh-7N for emacs-devel@gnu.org; Mon, 23 Nov 2015 15:09:29 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a0xQR-0004aV-8Y for emacs-devel@gnu.org; Mon, 23 Nov 2015 15:09:28 -0500 Original-Received: from mtaout27.012.net.il ([80.179.55.183]:40644) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a0xQR-0004Zt-0F for emacs-devel@gnu.org; Mon, 23 Nov 2015 15:09:23 -0500 Original-Received: from conversion-daemon.mtaout27.012.net.il by mtaout27.012.net.il (HyperSendmail v2007.08) id <0NYA00N00A1WL800@mtaout27.012.net.il> for emacs-devel@gnu.org; Mon, 23 Nov 2015 22:04:14 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([84.94.185.246]) by mtaout27.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NYA00LLEAF2GM30@mtaout27.012.net.il>; Mon, 23 Nov 2015 22:04:14 +0200 (IST) In-reply-to: X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 80.179.55.183 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:195140 Archived-At: > From: Philipp Stephani > Date: Mon, 23 Nov 2015 19:28:09 +0000 > > Eli Zaretskii 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? Probably. It works for me now. Sorry for the noise. > --- 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)) Thanks. I suggest the more thorough test below. WDYT? diff --git a/modules/mod-test/test.el b/modules/mod-test/test.el index 98ce464..7924e3b 100644 --- a/modules/mod-test/test.el +++ b/modules/mod-test/test.el @@ -28,7 +28,14 @@ ;; (ert-deftest mod-test-sum-test () - (should (= (mod-test-sum 1 2) 3))) + (should (= (mod-test-sum 1 2) 3)) + (let ((descr (should-error (mod-test-sum 1 2 3)))) + (should (eq (car descr) 'wrong-number-of-arguments)) + (should (stringp (nth 1 descr))) + (should (eq 0 + (string-match "#" + (nth 1 descr)))) + (should (= (nth 2 descr) 3)))) (ert-deftest mod-test-sum-docstring () (should (string= (documentation 'mod-test-sum) "Return A + B")))