all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Przemysław Wojnowski" <esperanto@cumego.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: [PATCH] A few cl-lib tests
Date: Sun, 22 Feb 2015 22:22:00 +0100	[thread overview]
Message-ID: <54EA4878.9000806@cumego.com> (raw)
In-Reply-To: <54E91397.7080204@cumego.com>

[-- Attachment #1: Type: text/plain, Size: 36 bytes --]

I've added tests for cl-ldiff here.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-A-few-cl-lib-tests.patch --]
[-- Type: text/x-patch; name="0001-A-few-cl-lib-tests.patch", Size: 8403 bytes --]

From f21717bd403a076f82c3095e2504963833a3adb9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Przemys=C5=82aw=20Wojnowski?= <esperanto@cumego.com>
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 | 189 +++++++++++++++++++++++++++++++++++++++--
 2 files changed, 189 insertions(+), 5 deletions(-)

diff --git a/test/ChangeLog b/test/ChangeLog
index abc582c..c069c1f 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+2015-02-22  Przemysław Wojnowski  <esperanto@cumego.com>
+
+	* automated/cl-lib-tests.el: New tests.
+	(cl-digit-char-p): Check returned value.
+
 2015-02-22  Michael Albinus  <michael.albinus@gmx.de>
 
 	* automated/tramp-tests.el (tramp-test17-insert-directory):
diff --git a/test/automated/cl-lib-tests.el b/test/automated/cl-lib-tests.el
index c83391b..1c36e7d 100644
--- a/test/automated/cl-lib-tests.el
+++ b/test/automated/cl-lib-tests.el
@@ -223,13 +223,192 @@
     (should (= (cl-the integer (cl-incf side-effect)) 1))
     (should (= side-effect 1))))
 
+(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 (= 4 (cl-first '(4))))
+  (should (= 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 (= 2 (cl-second '(1 2))))
+  (should (= 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 (= 3 (cl-third '(1 2 3))))
+  (should (= 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 (= 4 (cl-fourth '(1 2 3 4))))
+  (should (= 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 (= 5 (cl-fifth '(1 2 3 4 5))))
+  (should (= 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 (= 5 (cl-fifth '(1 2 3 4 5))))
+  (should (= 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 (= 6 (cl-sixth '(1 2 3 4 5 6))))
+  (should (= 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 (= 7 (cl-seventh '(1 2 3 4 5 6 7))))
+  (should (= 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 (= 8 (cl-eighth '(1 2 3 4 5 6 7 8))))
+  (should (= 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 (= 9 (cl-ninth '(1 2 3 4 5 6 7 8 9))))
+  (should (= 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 (= 10 (cl-tenth '(1 2 3 4 5 6 7 8 9 10))))
+  (should (= 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 (= (cl-nth-value 0 vals) 2))
+    (should (= (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 (= (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-range)
+  (should (string= (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 (=  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 (= 2 (cl-caadr '(1 (2 3)))))
+  (should (equal '((2) (3)) (cl-caadr '((1) (((2) (3))) (4))))))
+
+(ert-deftest cl-test-ldiff ()
+  (let ((l '(1 2 3)))
+    (should (null (cl-ldiff '() '())))
+    (should (null (cl-ldiff '() l)))
+    (should (null (cl-ldiff l l)))
+    (should (equal l (cl-ldiff l '())))
+    ;; must be part of the list
+    (should (equal l (cl-ldiff l '(2 3))))
+    (should (equal '(1) (cl-ldiff l (nthcdr 1 l))))
+    ;; should return a copy
+    (should-not (eq (cl-ldiff l '()) l))))
 
 (ert-deftest cl-parse-integer ()
   (should-error (cl-parse-integer "abc"))
-- 
2.1.0


  reply	other threads:[~2015-02-22 21:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-20 23:16 [PATCH] A few cl-lib tests Przemysław Wojnowski
2015-02-21 20:18 ` Stefan Monnier
2015-02-21 21:06   ` Drew Adams
2015-02-21 23:24   ` Przemysław Wojnowski
2015-02-22 21:22     ` Przemysław Wojnowski [this message]
2015-03-10  2:30     ` Stefan Monnier
2015-03-10  3:19       ` Stefan Monnier
2015-03-10 11:44       ` Przemysław Wojnowski
2015-03-11  0:39         ` Stefan Monnier

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=54EA4878.9000806@cumego.com \
    --to=esperanto@cumego.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.