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: [PATCH] A few cl-lib tests Date: Sat, 21 Feb 2015 00:16:22 +0100 Message-ID: <54E7C046.2050908@cumego.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------050701080904050706030206" X-Trace: ger.gmane.org 1424474313 14761 80.91.229.3 (20 Feb 2015 23:18:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 20 Feb 2015 23:18:33 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Feb 21 00:18:27 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 1YOwq0-0001yA-GN for ged-emacs-devel@m.gmane.org; Sat, 21 Feb 2015 00:18:24 +0100 Original-Received: from localhost ([::1]:34623 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOwpz-0004mL-UW for ged-emacs-devel@m.gmane.org; Fri, 20 Feb 2015 18:18:23 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56767) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOwoA-0001iz-Da for emacs-devel@gnu.org; Fri, 20 Feb 2015 18:16:32 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YOwo5-0001ee-8m for emacs-devel@gnu.org; Fri, 20 Feb 2015 18:16:30 -0500 Original-Received: from smtp21.iq.pl ([86.111.242.226]:42206) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOwo4-0001bS-Rw for emacs-devel@gnu.org; Fri, 20 Feb 2015 18:16:25 -0500 Original-Received: (qmail 19680 invoked from network); 20 Feb 2015 23:16:22 -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 ; 20 Feb 2015 23:16:22 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 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:183338 Archived-At: This is a multi-part message in MIME format. --------------050701080904050706030206 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Hello everybody, I've written a few cl-lib tests, but have couple of questions: 1. What should be level of compatibility with Common Lisp? Should it be as strict as possible (e.g. missing keywords, functions vs macros)? 2. Is there any rule for placing tests? Usually it is a file named in the same way as the tested lib with added postfix "tests". Is it ok to move incorrectly placed tests to correct files? Thanks! --------------050701080904050706030206 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 66d2ab2e5accf2754eca9d86eea947c5b419678c 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 | 167 +++++++++++++++++++++++++++++++++++= ++++-- 2 files changed, 167 insertions(+), 5 deletions(-) diff --git a/test/ChangeLog b/test/ChangeLog index 87425a6..e21d36f 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2015-02-20 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..c506ade 100644 --- a/test/automated/cl-lib-tests.el +++ b/test/automated/cl-lib-tests.el @@ -223,13 +223,170 @@ (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 () + (should (=3D 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-argumen= t)) + +(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 --------------050701080904050706030206--