emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/dash 25030c9 150/316: Fix test harness in Emacs 27


From: ELPA Syncer
Subject: [elpa] externals/dash 25030c9 150/316: Fix test harness in Emacs 27
Date: Mon, 15 Feb 2021 15:57:46 -0500 (EST)

branch: externals/dash
commit 25030c96d838dc1689df92f485375b64a52ab6ad
Author: Basil L. Contovounesios <contovob@tcd.ie>
Commit: Basil L. Contovounesios <contovob@tcd.ie>

    Fix test harness in Emacs 27
    
    Emacs 27 officially deprecates cl.el, which causes run-tests.sh to
    fail even when all tests pass, due to byte-compiler warnings.
    
    * dash.el: Do not unconditionally require cl.el in all Emacs
    versions.  Remove gv setter for -first-item, which is redundant
    since -first-item is an alias of car.  Also wrap calls to
    gv-define-setter in with-no-warnings to suppress warnings about
    gv--defsetter being undefined at runtime in certain Emacs versions.
    (-third-item): Do not assume caddr is defined just because cl.el was
    loaded within eval-when-compile: caddr is only defined if cl.el is
    loaded at runtime, or in Emacs 26 and above.
    
    * dev/examples.el (odd?): New helper function akin to even?.
    (-partition-after-pred, -partition-before-pred): Use it instead of
    assuming oddp from cl.el is defined.
    
    * run-tests.sh: Byte-compile all Emacs versions.  Pass -Q along with
    -batch for some older Emacs versions.  Consistently use
    short (single-hyphen) Emacs options.
    
    * README.md:
    * dash.info:
    * dash.texi: Regenerate docs.
---
 README.md       | 12 ++++++------
 dash.el         | 31 +++++++++++++++----------------
 dash.info       | 12 ++++++------
 dash.texi       | 12 ++++++------
 dev/examples.el | 25 ++++++++++++++-----------
 run-tests.sh    | 16 +++++-----------
 6 files changed, 52 insertions(+), 56 deletions(-)

diff --git a/README.md b/README.md
index 262bd2c..9c13678 100644
--- a/README.md
+++ b/README.md
@@ -1417,9 +1417,9 @@ other value (the body).
 Partition directly after each time `pred` is true on an element of `list`.
 
 ```el
-(-partition-after-pred #'oddp '()) ;; => '()
-(-partition-after-pred #'oddp '(1)) ;; => '((1))
-(-partition-after-pred #'oddp '(0 1)) ;; => '((0 1))
+(-partition-after-pred #'odd? '()) ;; => '()
+(-partition-after-pred #'odd? '(1)) ;; => '((1))
+(-partition-after-pred #'odd? '(0 1)) ;; => '((0 1))
 ```
 
 #### -partition-before-pred `(pred list)`
@@ -1427,9 +1427,9 @@ Partition directly after each time `pred` is true on an 
element of `list`.
 Partition directly before each time `pred` is true on an element of `list`.
 
 ```el
-(-partition-before-pred #'oddp '()) ;; => '()
-(-partition-before-pred #'oddp '(1)) ;; => '((1))
-(-partition-before-pred #'oddp '(0 1)) ;; => '((0) (1))
+(-partition-before-pred #'odd? '()) ;; => '()
+(-partition-before-pred #'odd? '(1)) ;; => '((1))
+(-partition-before-pred #'odd? '(0 1)) ;; => '((0) (1))
 ```
 
 #### -partition-before-item `(item list)`
diff --git a/dash.el b/dash.el
index f48c517..c86c116 100644
--- a/dash.el
+++ b/dash.el
@@ -33,6 +33,12 @@
 
 ;;; Code:
 
+;; TODO: `gv' was introduced in Emacs 24.3, so remove this and all
+;; calls to `defsetf' when support for earlier versions is dropped.
+(eval-when-compile
+  (unless (fboundp 'gv-define-setter)
+    (require 'cl)))
+
 (defgroup dash ()
   "Customize group for dash.el"
   :group 'lisp
@@ -682,7 +688,10 @@ See also: `-third-item'.
 
 \(fn LIST)")
 
-(defalias '-third-item 'caddr
+(defalias '-third-item
+  (if (fboundp 'caddr)
+      #'caddr
+    (lambda (list) (car (cddr list))))
   "Return the third item of LIST, or nil if LIST is too short.
 
 See also: `-fourth-item'.
@@ -703,28 +712,18 @@ See also: `-last-item'."
   (declare (pure t) (side-effect-free t))
   (car (cdr (cdr (cdr (cdr list))))))
 
-;; TODO: gv was introduced in 24.3, so we can remove the if statement
-;; when support for earlier versions is dropped
-(eval-when-compile
-  (require 'cl)
-  (if (fboundp 'gv-define-simple-setter)
-      (gv-define-simple-setter -first-item setcar)
-    (require 'cl)
-    (with-no-warnings
-      (defsetf -first-item (x) (val) `(setcar ,x ,val)))))
-
 (defun -last-item (list)
   "Return the last item of LIST, or nil on an empty list."
   (declare (pure t) (side-effect-free t))
   (car (last list)))
 
-;; TODO: gv was introduced in 24.3, so we can remove the if statement
-;; when support for earlier versions is dropped
-(eval-when-compile
+;; Use `with-no-warnings' to suppress unbound `-last-item' or
+;; undefined `gv--defsetter' warnings arising from both
+;; `gv-define-setter' and `defsetf' in certain Emacs versions.
+(with-no-warnings
   (if (fboundp 'gv-define-setter)
       (gv-define-setter -last-item (val x) `(setcar (last ,x) ,val))
-    (with-no-warnings
-      (defsetf -last-item (x) (val) `(setcar (last ,x) ,val)))))
+    (defsetf -last-item (x) (val) `(setcar (last ,x) ,val))))
 
 (defun -butlast (list)
   "Return a list of all items in list except for the last."
diff --git a/dash.info b/dash.info
index dad5dbb..426fa40 100644
--- a/dash.info
+++ b/dash.info
@@ -1322,22 +1322,22 @@ Functions partitioning the input list into a list of 
lists.
      Partition directly after each time PRED is true on an element of
      LIST.
 
-          (-partition-after-pred #'oddp '())
+          (-partition-after-pred #'odd? '())
               ⇒ '()
-          (-partition-after-pred #'oddp '(1))
+          (-partition-after-pred #'odd? '(1))
               ⇒ '((1))
-          (-partition-after-pred #'oddp '(0 1))
+          (-partition-after-pred #'odd? '(0 1))
               ⇒ '((0 1))
 
  -- Function: -partition-before-pred (pred list)
      Partition directly before each time PRED is true on an element of
      LIST.
 
-          (-partition-before-pred #'oddp '())
+          (-partition-before-pred #'odd? '())
               ⇒ '()
-          (-partition-before-pred #'oddp '(1))
+          (-partition-before-pred #'odd? '(1))
               ⇒ '((1))
-          (-partition-before-pred #'oddp '(0 1))
+          (-partition-before-pred #'odd? '(0 1))
               ⇒ '((0) (1))
 
  -- Function: -partition-before-item (item list)
diff --git a/dash.texi b/dash.texi
index b044ad3..24c655a 100644
--- a/dash.texi
+++ b/dash.texi
@@ -2066,15 +2066,15 @@ Partition directly after each time @var{pred} is true 
on an element of @var{list
 
 @example
 @group
-(-partition-after-pred #'oddp '())
+(-partition-after-pred #'odd? '())
     @result{} '()
 @end group
 @group
-(-partition-after-pred #'oddp '(1))
+(-partition-after-pred #'odd? '(1))
     @result{} '((1))
 @end group
 @group
-(-partition-after-pred #'oddp '(0 1))
+(-partition-after-pred #'odd? '(0 1))
     @result{} '((0 1))
 @end group
 @end example
@@ -2086,15 +2086,15 @@ Partition directly before each time @var{pred} is true 
on an element of @var{lis
 
 @example
 @group
-(-partition-before-pred #'oddp '())
+(-partition-before-pred #'odd? '())
     @result{} '()
 @end group
 @group
-(-partition-before-pred #'oddp '(1))
+(-partition-before-pred #'odd? '(1))
     @result{} '((1))
 @end group
 @group
-(-partition-before-pred #'oddp '(0 1))
+(-partition-before-pred #'odd? '(0 1))
     @result{} '((0) (1))
 @end group
 @end example
diff --git a/dev/examples.el b/dev/examples.el
index 7142370..6c11df4 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -24,6 +24,9 @@
 
 (require 'dash)
 
+;; FIXME: These definitions ought to be exported along with the
+;; examples, if they are going to be used there.
+(defun odd? (num) (= 1 (% num 2)))
 (defun even? (num) (= 0 (% num 2)))
 (defun square (num) (* num num))
 (defun three-letters () '("A" "B" "C"))
@@ -592,19 +595,19 @@ new list."
     (-partition-by-header 'even? '(2 1 1 1 4 1 3 5 6 6 1)) => '((2 1 1 1) (4 1 
3 5) (6 6 1)))
 
   (defexamples -partition-after-pred
-    (-partition-after-pred #'oddp '()) => '()
-    (-partition-after-pred #'oddp '(1)) => '((1))
-    (-partition-after-pred #'oddp '(0 1)) => '((0 1))
-    (-partition-after-pred #'oddp '(1 1)) => '((1) (1))
-    (-partition-after-pred #'oddp '(0 0 0 1 0 1 1 0 1)) => '((0 0 0 1) (0 1) 
(1) (0 1)))
+    (-partition-after-pred #'odd? '()) => '()
+    (-partition-after-pred #'odd? '(1)) => '((1))
+    (-partition-after-pred #'odd? '(0 1)) => '((0 1))
+    (-partition-after-pred #'odd? '(1 1)) => '((1) (1))
+    (-partition-after-pred #'odd? '(0 0 0 1 0 1 1 0 1)) => '((0 0 0 1) (0 1) 
(1) (0 1)))
 
   (defexamples -partition-before-pred
-    (-partition-before-pred #'oddp '()) => '()
-    (-partition-before-pred #'oddp '(1)) => '((1))
-    (-partition-before-pred #'oddp '(0 1)) => '((0) (1))
-    (-partition-before-pred #'oddp '(1 1)) => '((1) (1))
-    (-partition-before-pred #'oddp '(0 1 0)) => '((0) (1 0))
-    (-partition-before-pred #'oddp '(0 0 0 1 0 1 1 0 1)) => '((0 0 0) (1 0) 
(1) (1 0) (1)))
+    (-partition-before-pred #'odd? '()) => '()
+    (-partition-before-pred #'odd? '(1)) => '((1))
+    (-partition-before-pred #'odd? '(0 1)) => '((0) (1))
+    (-partition-before-pred #'odd? '(1 1)) => '((1) (1))
+    (-partition-before-pred #'odd? '(0 1 0)) => '((0) (1 0))
+    (-partition-before-pred #'odd? '(0 0 0 1 0 1 1 0 1)) => '((0 0 0) (1 0) 
(1) (1 0) (1)))
 
   (defexamples -partition-before-item
     (-partition-before-item 3 '()) => '()
diff --git a/run-tests.sh b/run-tests.sh
index 7e6d053..41a187f 100755
--- a/run-tests.sh
+++ b/run-tests.sh
@@ -16,19 +16,13 @@ if [ -z "$ERT_SELECTOR" ] ; then
     ERT_SELECTOR="nil"
 fi
 
-$EMACS -batch \
+$EMACS -Q -batch \
        -l dash.el \
        -l dash-functional.el \
        -l dev/examples-to-tests.el \
        -l dev/examples.el \
-       --eval "(ert-run-tests-batch-and-exit (quote ${ERT_SELECTOR}))"
+       -eval "(ert-run-tests-batch-and-exit (quote ${ERT_SELECTOR}))"
 
-VERSION=`$EMACS -version | head -1 | cut -d" " -f3`
-
-if [[ $VERSION == "24.1.1" ]] || [[ $VERSION == "24.2.1" ]] ; then
-    echo Skipping byte compile check for early Emacs version
-else
-    $EMACS -Q --batch \
-           --eval '(setq byte-compile-error-on-warn t)' \
-           -f batch-byte-compile dash.el
-fi
+$EMACS -Q -batch \
+       -eval '(setq byte-compile-error-on-warn t)' \
+       -f batch-byte-compile dash.el



reply via email to

[Prev in Thread] Current Thread [Next in Thread]