unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] A few cl-lib tests
@ 2015-02-20 23:16 Przemysław Wojnowski
  2015-02-21 20:18 ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Przemysław Wojnowski @ 2015-02-20 23:16 UTC (permalink / raw)
  To: emacs-devel

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

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!

[-- 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: 7777 bytes --]

From 66d2ab2e5accf2754eca9d86eea947c5b419678c 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 | 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ław Wojnowski  <esperanto@cumego.com>
+
+	* automated/cl-lib-tests.el: New tests.
+	(cl-digit-char-p): Check returned value.
+
 2015-02-16  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* automated/eieio-test-methodinvoke.el (make-instance): Add methods
diff --git a/test/automated/cl-lib-tests.el b/test/automated/cl-lib-tests.el
index c83391b..c506ade 100644
--- a/test/automated/cl-lib-tests.el
+++ b/test/automated/cl-lib-tests.el
@@ -223,13 +223,170 @@
     (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 ()
+  (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))
+
+(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-parse-integer ()
   (should-error (cl-parse-integer "abc"))
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] A few cl-lib tests
  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
  0 siblings, 2 replies; 9+ messages in thread
From: Stefan Monnier @ 2015-02-21 20:18 UTC (permalink / raw)
  To: Przemysław Wojnowski; +Cc: emacs-devel

> 1. What should be level of compatibility with Common Lisp?
>    Should it be as strict as possible (e.g. missing keywords,
>    functions vs macros)?

We mostly try to be faithful to the Common Lisp spec, but we don't try
super hard, because the purpose of cl-lib is not to let you run
Common-Lisp code, but to provide CL-style functionality to Elisp.

So, if there's no good reason to be incompatible, we try to be.  But if
performance would unduly suffer, or if it's "too much work" we sometimes
stick to something "close enough".

To take a recent example: in the new cl-generic.el code, I provided
a way to change the method-combination, but in an incompatible way,
because I consider that define-method-combination sucks.

>    Usually it is a file named in the same way as the tested
>    lib with added postfix "tests".

That's right.

>    Is it ok to move incorrectly placed tests to correct files?

Yes, of course.  There might be disagreement about what is the correct
place, tho ;-)

> +(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



^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [PATCH] A few cl-lib tests
  2015-02-21 20:18 ` Stefan Monnier
@ 2015-02-21 21:06   ` Drew Adams
  2015-02-21 23:24   ` Przemysław Wojnowski
  1 sibling, 0 replies; 9+ messages in thread
From: Drew Adams @ 2015-02-21 21:06 UTC (permalink / raw)
  To: Stefan Monnier, Przemys?aw Wojnowski; +Cc: emacs-devel

> So, if there's no good reason to be incompatible, we try to be.

;-)

I hope you meant "we try not to be".



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] A few cl-lib tests
  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
  2015-03-10  2:30     ` Stefan Monnier
  1 sibling, 2 replies; 9+ messages in thread
From: Przemysław Wojnowski @ 2015-02-21 23:24 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

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

>> +(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

[-- 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: 8214 bytes --]

From 83a48d304a90014b8ff196681cbf299a3c95046c 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 | 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ław Wojnowski  <esperanto@cumego.com>
+
+	* automated/cl-lib-tests.el: New tests.
+	(cl-digit-char-p): Check returned value.
+
 2015-02-16  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* automated/eieio-test-methodinvoke.el (make-instance): Add methods
diff --git a/test/automated/cl-lib-tests.el b/test/automated/cl-lib-tests.el
index c83391b..f4aaf2e 100644
--- a/test/automated/cl-lib-tests.el
+++ b/test/automated/cl-lib-tests.el
@@ -223,13 +223,180 @@
     (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-parse-integer ()
   (should-error (cl-parse-integer "abc"))
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] A few cl-lib tests
  2015-02-21 23:24   ` Przemysław Wojnowski
@ 2015-02-22 21:22     ` Przemysław Wojnowski
  2015-03-10  2:30     ` Stefan Monnier
  1 sibling, 0 replies; 9+ messages in thread
From: Przemysław Wojnowski @ 2015-02-22 21:22 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

[-- 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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] A few cl-lib tests
  2015-02-21 23:24   ` Przemysław Wojnowski
  2015-02-22 21:22     ` Przemysław Wojnowski
@ 2015-03-10  2:30     ` Stefan Monnier
  2015-03-10  3:19       ` Stefan Monnier
  2015-03-10 11:44       ` Przemysław Wojnowski
  1 sibling, 2 replies; 9+ messages in thread
From: Stefan Monnier @ 2015-03-10  2:30 UTC (permalink / raw)
  To: Przemysław Wojnowski; +Cc: emacs-devel

[ Sorry for the delay.  ]

> 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?

Looks good, thank you.

> 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 :-) ).

I just looked at it and it looks fine.
But before we can accept your contribution we'd need you to sign some
copyright paperwork.  If you're OK with it, then please fill the form
below and email it to the FSF so they can send you the relevant
paperwork to sign,


        Stefan


Please email the following information to assign@gnu.org, and we
will send you the assignment form for your past and future changes.

Please use your full legal name (in ASCII characters) as the subject
line of the message.
----------------------------------------------------------------------
REQUEST: SEND FORM FOR PAST AND FUTURE CHANGES

[What is the name of the program or package you're contributing to?]
Emacs

[Did you copy any files or text written by someone else in these changes?
Even if that material is free software, we need to know about it.]


[Do you have an employer who might have a basis to claim to own
your changes?  Do you attend a school which might make such a claim?]


[For the copyright registration, what country are you a citizen of?]


[What year were you born?]


[Please write your email address here.]


[Please write your postal address here.]





[Which files have you changed so far, and which new files have you written
so far?]



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] A few cl-lib tests
  2015-03-10  2:30     ` Stefan Monnier
@ 2015-03-10  3:19       ` Stefan Monnier
  2015-03-10 11:44       ` Przemysław Wojnowski
  1 sibling, 0 replies; 9+ messages in thread
From: Stefan Monnier @ 2015-03-10  3:19 UTC (permalink / raw)
  To: Przemysław Wojnowski; +Cc: emacs-devel

> But before we can accept your contribution we'd need you to sign some
> copyright paperwork.  If you're OK with it, then please fill the form
> below and email it to the FSF so they can send you the relevant
> paperwork to sign,

Duh, OK, now that I actually woke up, I just refreshed my copyright.list
file, saw that you've already signed this and so I installed your patch
into master.

Thank you very much, and sorry 'bout the confusion,


        Stefan



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] A few cl-lib tests
  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
  1 sibling, 1 reply; 9+ messages in thread
From: Przemysław Wojnowski @ 2015-03-10 11:44 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Just a few quick questions:
1. Patches should be send here or added to debbugs? If to debbugs, then 
patches which add only tests, should be reported as bugs too?

2. Why the assignment form is not in CONTRIBUTE? IMHO it would make 
signing the papers a bit easier for potential contributors.

3. Is there any roadmap? For example, are there any plans for nxml-mode?

Thanks and regards,
Przemysław



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] A few cl-lib tests
  2015-03-10 11:44       ` Przemysław Wojnowski
@ 2015-03-11  0:39         ` Stefan Monnier
  0 siblings, 0 replies; 9+ messages in thread
From: Stefan Monnier @ 2015-03-11  0:39 UTC (permalink / raw)
  To: Przemysław Wojnowski; +Cc: emacs-devel

> 1. Patches should be send here or added to debbugs? If to debbugs, then
> patches which add only tests, should be reported as bugs too?

Better send them to debbugs, tho here works as well.

> 3. Is there any roadmap?

Not really, nowadays.  For Emacs-25, the only significant intentions are:
- include some GNU ELPA packages.
- include some kind of plugin system.
Earlier, concurrency was included in the plan, but it seems unlikely
that work will progress fast enough at this point.
Maybe none of those two elements will actually make it to Emacs-25.

>    For example, are there any plans for nxml-mode?

Nobody has worked on nxml for a while, so there are no special plans on
this front AFAIK.  I think it's orphaned, so if you're interested to
take on its maintainership, the door is wide open.


        Stefan



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-03-11  0:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).