From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?B?UHJ6ZW15c8WCYXcgV29qbm93c2tp?= Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] A few cl-lib tests Date: Sun, 22 Feb 2015 00:24:07 +0100 Message-ID: <54E91397.7080204@cumego.com> References: <54E7C046.2050908@cumego.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------010804030907050702070800" X-Trace: ger.gmane.org 1424561084 27560 80.91.229.3 (21 Feb 2015 23:24:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 21 Feb 2015 23:24:44 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Feb 22 00:24:39 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 1YPJPY-0000Vx-G8 for ged-emacs-devel@m.gmane.org; Sun, 22 Feb 2015 00:24:36 +0100 Original-Received: from localhost ([::1]:37858 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YPJPX-0001Il-QU for ged-emacs-devel@m.gmane.org; Sat, 21 Feb 2015 18:24:35 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37738) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YPJPG-0001Dd-SS for emacs-devel@gnu.org; Sat, 21 Feb 2015 18:24:20 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YPJPD-0007Xq-In for emacs-devel@gnu.org; Sat, 21 Feb 2015 18:24:18 -0500 Original-Received: from smtp21.iq.pl ([86.111.242.226]:34132) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YPJPD-0007WY-59 for emacs-devel@gnu.org; Sat, 21 Feb 2015 18:24:15 -0500 Original-Received: (qmail 22827 invoked from network); 21 Feb 2015 23:24:08 -0000 Original-Received: from unknown (HELO [192.168.1.106]) (esperanto@cumego.com@[159.205.28.44]) (envelope-sender ) by smtp20.iq.pl with AES128-SHA encrypted SMTP for ; 21 Feb 2015 23:24:08 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 86.111.242.226 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:183373 Archived-At: This is a multi-part message in MIME format. --------------010804030907050702070800 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit >> +(ert-deftest cl-lib-test-nth-value () >> + (should (= 1 (cl-nth-value 0 '(1)))) >> + (should (null (cl-nth-value 1 '(1)))) >> + (should-error (cl-nth-value 0.0 '(1)) :type 'wrong-type-argument) >> + (should-error (cl-nth-value 0 "only lists") :type 'wrong-type-argument)) > > IIUC, this tests the current broken approximation of "multiple values", > so those tests would likely fail if we were to try and improve the > implementation of multiple values. So I think these tests are wrong. > They should look more like: > > (ert-deftest cl-lib-test-nth-value () > (should (= 1 (cl-nth-value 0 (values 1)))) > (should (null (cl-nth-value 1 (values 1)))) > (should-error (cl-nth-value 0.0 (values 1)) :type 'wrong-type-argument)) > > > -- Stefan > Thanks for feedback. I've corrected the tests. Now they use cl-values when expected. I split them into two groups: working tests and those that suppose to work, but do to lack of support for multiple values they don't. If at some point multiple values will be implemented, then those tests can be moved to the first group. Is that ok? BTW I'm contributing for the first time here and I'm not really sure what is the next action after sending a patch... If it cannot be committed for some reason I would like to know why, for example: "We can't add it because of... When you fix it we will commit it to the repository." or "We won't add it no matter what." (it's still better than no feedback :-) ). Thanks, Przemysław --------------010804030907050702070800 Content-Type: text/x-patch; name="0001-A-few-cl-lib-tests.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-A-few-cl-lib-tests.patch" =46rom 83a48d304a90014b8ff196681cbf299a3c95046c Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Przemys=3DC5=3D82aw=3D20Wojnowski?=3D Date: Fri, 20 Feb 2015 23:03:43 +0100 Subject: [PATCH] A few cl-lib tests. --- test/ChangeLog | 5 ++ test/automated/cl-lib-tests.el | 177 +++++++++++++++++++++++++++++++++++= ++++-- 2 files changed, 177 insertions(+), 5 deletions(-) diff --git a/test/ChangeLog b/test/ChangeLog index 87425a6..656124e 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2015-02-22 Przemys=C5=82aw Wojnowski + + * automated/cl-lib-tests.el: New tests. + (cl-digit-char-p): Check returned value. + 2015-02-16 Stefan Monnier =20 * automated/eieio-test-methodinvoke.el (make-instance): Add methods diff --git a/test/automated/cl-lib-tests.el b/test/automated/cl-lib-tests= =2Eel index c83391b..f4aaf2e 100644 --- a/test/automated/cl-lib-tests.el +++ b/test/automated/cl-lib-tests.el @@ -223,13 +223,180 @@ (should (=3D (cl-the integer (cl-incf side-effect)) 1)) (should (=3D side-effect 1)))) =20 +(ert-deftest cl-lib-test-plusp () + (should-not (cl-plusp -1.0e+INF)) + (should-not (cl-plusp -1.5e2)) + (should-not (cl-plusp -3.14)) + (should-not (cl-plusp -1)) + (should-not (cl-plusp -0.0)) + (should-not (cl-plusp 0)) + (should-not (cl-plusp 0.0)) + (should-not (cl-plusp -0.0e+NaN)) + (should-not (cl-plusp 0.0e+NaN)) + (should (cl-plusp 1)) + (should (cl-plusp 3.14)) + (should (cl-plusp 1.5e2)) + (should (cl-plusp 1.0e+INF)) + (should-error (cl-plusp "42") :type 'wrong-type-argument)) + +(ert-deftest cl-lib-test-minusp () + (should (cl-minusp -1.0e+INF)) + (should (cl-minusp -1.5e2)) + (should (cl-minusp -3.14)) + (should (cl-minusp -1)) + (should-not (cl-minusp -0.0)) + (should-not (cl-minusp 0)) + (should-not (cl-minusp 0.0)) + (should-not (cl-minusp -0.0e+NaN)) + (should-not (cl-minusp 0.0e+NaN)) + (should-not (cl-minusp 1)) + (should-not (cl-minusp 3.14)) + (should-not (cl-minusp 1.5e2)) + (should-not (cl-minusp 1.0e+INF)) + (should-error (cl-minusp "-42") :type 'wrong-type-argument)) + +(ert-deftest cl-lib-test-oddp () + (should (cl-oddp -3)) + (should (cl-oddp 3)) + (should-not (cl-oddp -2)) + (should-not (cl-oddp 0)) + (should-not (cl-oddp 2)) + (should-error (cl-oddp 3.0e+NaN) :type 'wrong-type-argument) + (should-error (cl-oddp 3.0) :type 'wrong-type-argument) + (should-error (cl-oddp "3") :type 'wrong-type-argument)) + +(ert-deftest cl-lib-test-evenp () + (should (cl-evenp -2)) + (should (cl-evenp 0)) + (should (cl-evenp 2)) + (should-not (cl-evenp -3)) + (should-not (cl-evenp 3)) + (should-error (cl-evenp 2.0e+NaN) :type 'wrong-type-argument) + (should-error (cl-evenp 2.0) :type 'wrong-type-argument) + (should-error (cl-evenp "2") :type 'wrong-type-argument)) + (ert-deftest cl-digit-char-p () - (should (cl-digit-char-p ?3)) - (should (cl-digit-char-p ?a 11)) + (should (eql 3 (cl-digit-char-p ?3))) + (should (eql 10 (cl-digit-char-p ?a 11))) + (should (eql 10 (cl-digit-char-p ?A 11))) (should-not (cl-digit-char-p ?a)) - (should (cl-digit-char-p ?w 36)) - (should-error (cl-digit-char-p ?a 37)) - (should-error (cl-digit-char-p ?a 1))) + (should (eql 32 (cl-digit-char-p ?w 36))) + (should-error (cl-digit-char-p ?a 37) :type 'args-out-of-range) + (should-error (cl-digit-char-p ?a 1) :type 'args-out-of-range)) + +(ert-deftest cl-lib-test-first () + (should (null (cl-first '()))) + (should (=3D 4 (cl-first '(4)))) + (should (=3D 4 (cl-first '(4 2)))) + (should-error (cl-first "42") :type 'wrong-type-argument)) + +(ert-deftest cl-lib-test-second () + (should (null (cl-second '()))) + (should (null (cl-second '(4)))) + (should (=3D 2 (cl-second '(1 2)))) + (should (=3D 2 (cl-second '(1 2 3)))) + (should-error (cl-second "1 2 3") :type 'wrong-type-argument)) + +(ert-deftest cl-lib-test-third () + (should (null (cl-third '()))) + (should (null (cl-third '(1 2)))) + (should (=3D 3 (cl-third '(1 2 3)))) + (should (=3D 3 (cl-third '(1 2 3 4)))) + (should-error (cl-third "123") :type 'wrong-type-argument)) + +(ert-deftest cl-lib-test-fourth () + (should (null (cl-fourth '()))) + (should (null (cl-fourth '(1 2 3)))) + (should (=3D 4 (cl-fourth '(1 2 3 4)))) + (should (=3D 4 (cl-fourth '(1 2 3 4 5)))) + (should-error (cl-fourth "1234") :type 'wrong-type-argument)) + +(ert-deftest cl-lib-test-fifth () + (should (null (cl-fifth '()))) + (should (null (cl-fifth '(1 2 3 4)))) + (should (=3D 5 (cl-fifth '(1 2 3 4 5)))) + (should (=3D 5 (cl-fifth '(1 2 3 4 5 6)))) + (should-error (cl-fifth "12345") :type 'wrong-type-argument)) + +(ert-deftest cl-lib-test-fifth () + (should (null (cl-fifth '()))) + (should (null (cl-fifth '(1 2 3 4)))) + (should (=3D 5 (cl-fifth '(1 2 3 4 5)))) + (should (=3D 5 (cl-fifth '(1 2 3 4 5 6)))) + (should-error (cl-fifth "12345") :type 'wrong-type-argument)) + +(ert-deftest cl-lib-test-sixth () + (should (null (cl-sixth '()))) + (should (null (cl-sixth '(1 2 3 4 5)))) + (should (=3D 6 (cl-sixth '(1 2 3 4 5 6)))) + (should (=3D 6 (cl-sixth '(1 2 3 4 5 6 7)))) + (should-error (cl-sixth "123456") :type 'wrong-type-argument)) + +(ert-deftest cl-lib-test-seventh () + (should (null (cl-seventh '()))) + (should (null (cl-seventh '(1 2 3 4 5 6)))) + (should (=3D 7 (cl-seventh '(1 2 3 4 5 6 7)))) + (should (=3D 7 (cl-seventh '(1 2 3 4 5 6 7 8)))) + (should-error (cl-seventh "1234567") :type 'wrong-type-argument)) + +(ert-deftest cl-lib-test-eighth () + (should (null (cl-eighth '()))) + (should (null (cl-eighth '(1 2 3 4 5 6 7)))) + (should (=3D 8 (cl-eighth '(1 2 3 4 5 6 7 8)))) + (should (=3D 8 (cl-eighth '(1 2 3 4 5 6 7 8 9)))) + (should-error (cl-eighth "12345678") :type 'wrong-type-argument)) + +(ert-deftest cl-lib-test-ninth () + (should (null (cl-ninth '()))) + (should (null (cl-ninth '(1 2 3 4 5 6 7 8)))) + (should (=3D 9 (cl-ninth '(1 2 3 4 5 6 7 8 9)))) + (should (=3D 9 (cl-ninth '(1 2 3 4 5 6 7 8 9 10)))) + (should-error (cl-ninth "123456789") :type 'wrong-type-argument)) + +(ert-deftest cl-lib-test-tenth () + (should (null (cl-tenth '()))) + (should (null (cl-tenth '(1 2 3 4 5 6 7 8 9)))) + (should (=3D 10 (cl-tenth '(1 2 3 4 5 6 7 8 9 10)))) + (should (=3D 10 (cl-tenth '(1 2 3 4 5 6 7 8 9 10 11)))) + (should-error (cl-tenth "1234567890") :type 'wrong-type-argument)) + +(ert-deftest cl-lib-test-endp () + (should (cl-endp '())) + (should-not (cl-endp '(1))) + (should-error (cl-endp 1) :type 'wrong-type-argument) + (should-error (cl-endp [1]) :type 'wrong-type-argument)) + +(ert-deftest cl-lib-test-nth-value () + (let ((vals (cl-values 2 3))) + (should (=3D (cl-nth-value 0 vals) 2)) + (should (=3D (cl-nth-value 1 vals) 3)) + (should (null (cl-nth-value 2 vals))) + (should-error (cl-nth-value 0.0 vals) :type 'wrong-type-argument))) + +(ert-deftest cl-lib-nth-value-test-multiple-values () + "While CL multiple values are an alias to list, these won't work." + :expected-result :failed + (should (eq (cl-nth-value 0 '(2 3)) '(2 3))) + (should (=3D (cl-nth-value 0 1) 1)) + (should (null (cl-nth-value 1 1))) + (should-error (cl-nth-value -1 (cl-values 2 3)) :type 'args-out-of-ran= ge) + (should (string=3D (cl-nth-value 0 "only lists") "only lists"))) + +(ert-deftest cl-test-caaar () + (should (null (cl-caaar '()))) + (should (null (cl-caaar '(() (2))))) + (should (null (cl-caaar '((() (2)) (a b))))) + (should-error (cl-caaar '(1 2)) :type 'wrong-type-argument) + (should-error (cl-caaar '((1 2))) :type 'wrong-type-argument) + (should (=3D 1 (cl-caaar '(((1 2) (3 4)))))) + (should (null (cl-caaar '((() (3 4))))))) + +(ert-deftest cl-test-caadr () + (should (null (cl-caadr '()))) + (should (null (cl-caadr '(1)))) + (should-error (cl-caadr '(1 2)) :type 'wrong-type-argument) + (should (=3D 2 (cl-caadr '(1 (2 3))))) + (should (equal '((2) (3)) (cl-caadr '((1) (((2) (3))) (4)))))) =20 (ert-deftest cl-parse-integer () (should-error (cl-parse-integer "abc")) --=20 2.1.0 --------------010804030907050702070800--