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

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

[elpa] externals/compat ac00450848 3/4: Transform most advised functions


From: ELPA Syncer
Subject: [elpa] externals/compat ac00450848 3/4: Transform most advised functions into prefixed functions
Date: Thu, 10 Feb 2022 11:57:30 -0500 (EST)

branch: externals/compat
commit ac00450848a2c4a287677fc0e186e7940f3e9035
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>

    Transform most advised functions into prefixed functions
---
 compat-24.4.el  |  40 +++---
 compat-25.1.el  |  10 +-
 compat-26.1.el  |  26 ++--
 compat-27.1.el  |  29 ++--
 compat-28.1.el  |  26 ++--
 compat-tests.el | 430 ++++++++++++++++++++++++++++----------------------------
 6 files changed, 282 insertions(+), 279 deletions(-)

diff --git a/compat-24.4.el b/compat-24.4.el
index 2d67ce6182..304e0b5e6e 100644
--- a/compat-24.4.el
+++ b/compat-24.4.el
@@ -32,52 +32,52 @@
 
 ;;;; Defined in data.c
 
-(compat-advise = (number-or-marker &rest numbers-or-markers)
+(compat-defun = (number-or-marker &rest numbers-or-markers)
   "Handle multiple arguments."
-  :cond (compat-maxargs-/= #'= 'many)
+  :prefix t
   (catch 'fail
     (while numbers-or-markers
-      (unless (funcall oldfun number-or-marker (car numbers-or-markers))
+      (unless (= number-or-marker (car numbers-or-markers))
         (throw 'fail nil))
       (setq number-or-marker (pop numbers-or-markers)))
     t))
 
-(compat-advise < (number-or-marker &rest numbers-or-markers)
+(compat-defun < (number-or-marker &rest numbers-or-markers)
   "Handle multiple arguments."
-  :cond (compat-maxargs-/= #'= 'many)
+  :prefix t
   (catch 'fail
     (while numbers-or-markers
-      (unless (funcall oldfun number-or-marker (car numbers-or-markers))
+      (unless (< number-or-marker (car numbers-or-markers))
         (throw 'fail nil))
       (setq number-or-marker (pop numbers-or-markers)))
     t))
 
-(compat-advise > (number-or-marker &rest numbers-or-markers)
+(compat-defun > (number-or-marker &rest numbers-or-markers)
   "Handle multiple arguments."
-  :cond (compat-maxargs-/= #'= 'many)
+  :prefix t
   (catch 'fail
     (while numbers-or-markers
-      (unless (funcall oldfun number-or-marker (car numbers-or-markers))
+      (unless (> number-or-marker (car numbers-or-markers))
         (throw 'fail nil))
       (setq number-or-marker (pop numbers-or-markers)))
     t))
 
-(compat-advise <= (number-or-marker &rest numbers-or-markers)
+(compat-defun <= (number-or-marker &rest numbers-or-markers)
   "Handle multiple arguments."
-  :cond (compat-maxargs-/= #'= 'many)
+  :prefix t
   (catch 'fail
     (while numbers-or-markers
-      (unless (funcall oldfun number-or-marker (car numbers-or-markers))
+      (unless (<= number-or-marker (car numbers-or-markers))
         (throw 'fail nil))
       (setq number-or-marker (pop numbers-or-markers)))
     t))
 
-(compat-advise >= (number-or-marker &rest numbers-or-markers)
+(compat-defun >= (number-or-marker &rest numbers-or-markers)
   "Handle multiple arguments."
-  :cond (compat-maxargs-/= #'= 'many)
+  :prefix t
   (catch 'fail
     (while numbers-or-markers
-      (unless (funcall oldfun number-or-marker (pop numbers-or-markers))
+      (unless (>= number-or-marker (pop numbers-or-markers))
         (throw 'fail nil)))
     t))
 
@@ -119,10 +119,12 @@ attention to case differences."
          (eq t (compare-strings suffix nil nil
                                 string start-pos nil ignore-case)))))
 
-(compat-advise split-string (string &optional separators omit-nulls trim)
-  "Handle optional argument TRIM."
-  :cond (compat-maxargs-/= #'split-string 4)
-  (let* ((token (funcall oldfun string separators omit-nulls))
+(compat-defun split-string (string &optional separators omit-nulls trim)
+  "Extend `split-string' by a TRIM argument.
+The remaining arguments STRING, SEPARATORS and OMIT-NULLS are
+handled just as with `split-string'."
+  :prefix t
+  (let* ((token (split-string string separators omit-nulls))
          (trimmed (if trim
                       (mapcar
                        (lambda (token)
diff --git a/compat-25.1.el b/compat-25.1.el
index fbabae8997..8bf2c87ef9 100644
--- a/compat-25.1.el
+++ b/compat-25.1.el
@@ -32,14 +32,12 @@
 
 ;;;; Defined in fns.c
 
-(compat-advise sort (seq predicate)
-  "Handle SEQ of type vector."
-  :cond (condition-case nil
-            (ignore (sort [] #'ignore))
-          (wrong-type-argument t))
+(compat-defun sort (seq predicate)
+  "Extend `sort' to sort SEQ as a vector."
+  :prefix t
   (cond
    ((listp seq)
-    (funcall oldfun seq predicate))
+    (sort seq predicate))
    ((vectorp seq)
     (let ((cseq (sort (append seq nil) predicate)))
       (dotimes (i (length cseq))
diff --git a/compat-26.1.el b/compat-26.1.el
index fd62072ea3..e4cb918789 100644
--- a/compat-26.1.el
+++ b/compat-26.1.el
@@ -43,15 +43,19 @@ function with ‘&rest’ args, or ‘unevalled’ for a special 
form."
 
 ;;;; Defined in fns.c
 
-(compat-advise assoc (key alist &optional testfn)
-  "Handle TESTFN manually."
-  :cond (compat-maxargs-/= #'assoc 3)
+(compat-defun assoc (key alist &optional testfn)
+  "Handle the optional argument TESTFN.
+Equality is defined by the function TESTFN, defaulting to
+‘equal’.  TESTFN is called with 2 arguments: a car of an alist
+element and KEY.  With no optional argument, the function behaves
+just like `assoc'."
+  :prefix t
   (if testfn
       (catch 'found
         (dolist (ent alist)
           (when (funcall testfn (car ent) key)
             (throw 'found ent))))
-    (funcall oldfun key alist)))
+    (assoc key alist)))
 
 (compat-defun mapcan (func sequence)
   "Apply FUNC to each element of SEQUENCE.
@@ -59,33 +63,33 @@ Concatenate the results by altering them (using `nconc').
 SEQUENCE may be a list, a vector, a boolean vector, or a string."
   (apply #'nconc (mapcar func sequence)))
 
-(compat-advise line-number-at-pos (&optional position absolute)
+(compat-defun line-number-at-pos (&optional position absolute)
   "Handle optional argument ABSOLUTE:
 
 If the buffer is narrowed, the return value by default counts the lines
 from the beginning of the accessible portion of the buffer.  But if the
 second optional argument ABSOLUTE is non-nil, the value counts the lines
 from the absolute start of the buffer, disregarding the narrowing."
-  :cond (compat-maxargs-/= #'line-number-at-pos 2)
+  :prefix t
   (if absolute
       (save-restriction
         (widen)
-        (funcall oldfun position))
-    (funcall oldfun position)))
+        (line-number-at-pos position))
+    (line-number-at-pos position)))
 
 ;;;; Defined in subr.el
 
 (declare-function compat--alist-get-full-elisp "compat-25.1"
                   (key alist &optional default remove testfn))
-(compat-advise alist-get (key alist &optional default remove testfn)
+(compat-defun alist-get (key alist &optional default remove testfn)
   "Handle TESTFN manually."
   :min-version "25.1"                  ;first defined in 25.1
   :max-version "25.3"                  ;last version without testfn
   :realname compat--alist-get-handle-testfn
-  :cond (compat-maxargs-/= #'alist-get 5)
+  :prefix t
   (if testfn
       (compat--alist-get-full-elisp key alist default remove testfn)
-    (funcall oldfun key alist default remove)))
+    (alist-get key alist default remove)))
 
 (compat-defun string-trim-left (string &optional regexp)
   "Trim STRING of leading string matching REGEXP.
diff --git a/compat-27.1.el b/compat-27.1.el
index 3fb14279aa..5b31428bc3 100644
--- a/compat-27.1.el
+++ b/compat-27.1.el
@@ -99,26 +99,25 @@ Letter-case is significant, but text properties are 
ignored."
 
 ;;;; Defined in window.c
 
-(compat-advise recenter (&optional arg redisplay)
+(compat-defun recenter (&optional arg redisplay)
   "Handle optional argument REDISPLAY."
-  (funcall oldfun arg)
+  :prefix t
+  (recenter arg)
   (when (and redisplay recenter-redisplay)
     (redisplay)))
 
 ;;;; Defined in keymap.c
 
-(compat-advise lookup-key (keymap key &optional accept-default)
+(compat-defun lookup-key (keymap key &optional accept-default)
   "Allow for KEYMAP to be a list of keymaps."
-  :cond (condition-case err
-            (lookup-key '(x) nil)
-          (wrong-type-argument (equal err '(keymapp (x)))))
+  :prefix t
   (cond
    ((keymapp keymap)
-    (funcall oldfun keymap key accept-default))
+    (lookup-key keymap key accept-default))
    ((listp keymap)
     (catch 'found
       (dolist (map keymap)
-        (let ((fn (funcall oldfun map key accept-default)))
+        (let ((fn (lookup-key map key accept-default)))
           (when fn (throw 'found fn))))))
    ((signal 'wrong-type-argument (list 'keymapp keymap)))))
 
@@ -262,10 +261,9 @@ represent a JSON false value.  It defaults to `:false'."
 
 ;;;; Defined in subr.el
 
-(compat-advise setq-local (&rest pairs)
+(compat-defun setq-local (&rest pairs)
   "Handle multiple assignments."
-  :cond (compat-maxargs-/= #'setq-local 'many)
-  (declare (debug setq))
+  :prefix t
   (unless (zerop (mod (length pairs) 2))
     (error "PAIRS must have an even number of variable/value members"))
   (let (body)
@@ -397,7 +395,7 @@ the number of seconds east of Greenwich."
 
 ;;;; Defined in files.el
 
-(compat-advise file-size-human-readable (file-size &optional flavor space unit)
+(compat-defun file-size-human-readable (file-size &optional flavor space unit)
   "Handle the optional third and forth argument:
 
 Optional third argument SPACE is a string put between the number and unit.
@@ -408,6 +406,7 @@ position.
 Optional fourth argument UNIT is the unit to use.  It defaults to \"B\"
 when FLAVOR is `iec' and the empty string otherwise.  We recommend \"B\"
 in all cases, since that is the standard symbol for byte."
+  :prefix t
   (let ((power (if (or (null flavor) (eq flavor 'iec))
                    1024.0
                  1000.0))
@@ -438,9 +437,9 @@ in all cases, since that is the standard symbol for byte."
 
 ;;;; Defined in regexp-opt.el
 
-(compat-advise regexp-opt (strings &optional paren)
+(compat-defun regexp-opt (strings &optional paren)
   "Handle an empty list of strings."
-  :feature regexp-opt
+  :prefix t
   (if (null strings)
       (let ((re "\\`a\\`"))
         (cond ((null paren)
@@ -452,7 +451,7 @@ in all cases, since that is the standard symbol for byte."
               ((eq paren 'symbols)
                (concat "\\_\\(<" re "\\)\\_>"))
               ((concat "\\(" re "\\)"))))
-    (funcall oldfun strings paren)))
+    (regexp-opt strings paren)))
 
 ;;;; Defined in package.el
 
diff --git a/compat-28.1.el b/compat-28.1.el
index 032bb8bc3e..8954703880 100644
--- a/compat-28.1.el
+++ b/compat-28.1.el
@@ -119,13 +119,14 @@ Returns non-nil if GC happened, and nil otherwise."
 
 ;;;; Defined in filelock.c
 
-(compat-advise unlock-buffer ()
+(compat-defun unlock-buffer ()
   "Handle `file-error' conditions:
 
 Handles file system errors by calling ‘display-warning’ and
 continuing as if the error did not occur."
+  :prefix t
   (condition-case error
-      (funcall oldfun)
+      (unlock-buffer)
     (file-error
      (display-warning
       '(unlock-file)
@@ -134,23 +135,23 @@ continuing as if the error did not occur."
 
 ;;;; Defined in characters.c
 
-(compat-advise string-width (string &optional from to)
+(compat-defun string-width (string &optional from to)
   "Handle optional arguments FROM and TO:
 
 Optional arguments FROM and TO specify the substring of STRING to
 consider, and are interpreted as in `substring'."
-  :cond (compat-maxargs-/= #'string-width 3)
-  (funcall oldfun (substring string (or from 0) to)))
+  :prefix t
+  (string-width (substring string (or from 0) to)))
 
 ;;;; Defined in dired.c
 
-(compat-advise directory-files (directory &optional full match nosort count)
+(compat-defun directory-files (directory &optional full match nosort count)
   "Handle additional optional argument COUNT:
 
 If COUNT is non-nil and a natural number, the function will
  return COUNT number of file names (if so many are present)."
-  :cond (compat-maxargs-/= #'directory-files 5)
-  (let ((files (funcall oldfun directory full match nosort)))
+  :prefix t
+  (let ((files (directory-files directory full match nosort)))
     (when (natnump count)
       (setf (nthcdr count files) nil))
     files))
@@ -565,20 +566,19 @@ is included in the return value."
 
 ;;;; Defined in windows.el
 
-(compat-advise count-windows (&optional minibuf all-frames)
+(compat-defun count-windows (&optional minibuf all-frames)
   "Handle optional argument ALL-FRAMES:
 
 If ALL-FRAMES is non-nil, count the windows in all frames instead
 just the selected frame."
-  :cond (compat-maxargs-/= #'count-windows 2)
+  :prefix t
   (if all-frames
       (let ((sum 0))
         (dolist (frame (frame-list))
           (with-selected-frame frame
-            (setq sum (+ (funcall oldfun minibuf)
-                         sum))))
+            (setq sum (+ (count-windows minibuf) sum))))
         sum)
-    (funcall oldfun minibuf)))
+    (count-windows minibuf)))
 
 ;;;; Defined in thingatpt.el
 
diff --git a/compat-tests.el b/compat-tests.el
index dd5f462f17..1acd9631f8 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -408,20 +408,20 @@ the compatibility function."
 
 (ert-deftest compat-string-width ()
   "Check if `compat--string-width' was implemented correctly."
-  (compat-test string-width
-    (compat--should* 0 "")
-    (compat--should* 3 "abc")                  ;no argument
-    (compat--should* 5 "abcあ")
-    (compat--should* (1+ tab-width) "a ")
-    (compat--should* 2 "abc" 1)               ;with from
-    (compat--should* 4 "abcあ" 1)
-    (compat--should* tab-width "a      " 1)
-    (compat--should* 2 "abc" 0 2)             ;with to
-    (compat--should* 3 "abcあ" 0 3)
-    (compat--should* 1 "a      " 0 1)
-    (compat--should* 1 "abc" 1 2)             ;with from and to
-    (compat--should* 2 "abcあ" 3 4)
-    (compat--should* 0 "a      " 1 1)))
+  (compat-test compat-string-width
+    (compat--should 0 "")
+    (compat--should 3 "abc")                   ;no argument
+    (compat--should 5 "abcあ")
+    (compat--should (1+ tab-width) "a  ")
+    (compat--should 2 "abc" 1)               ;with from
+    (compat--should 4 "abcあ" 1)
+    (compat--should tab-width "a       " 1)
+    (compat--should 2 "abc" 0 2)             ;with to
+    (compat--should 3 "abcあ" 0 3)
+    (compat--should 1 "a       " 0 1)
+    (compat--should 1 "abc" 1 2)             ;with from and to
+    (compat--should 2 "abcあ" 3 4)
+    (compat--should 0 "a       " 1 1)))
 
 (ert-deftest compat-ensure-list ()
   "Check if `compat--ensure-list' was implemented correctly."
@@ -530,16 +530,16 @@ the compatibility function."
 
 (ert-deftest compat-regexp-opt ()
   "Check if `compat--regexp-opt' advice was defined correctly."
-  (compat-test regexp-opt
-    ;; Ensure `compat--regexp-opt' doesn't change the existing
-    ;; behaviour:
-    (compat--should* (regexp-opt '("a" "b" "c")) '("a" "b" "c"))
-    (compat--should* (regexp-opt '("abc" "def" "ghe")) '("abc" "def" "ghe"))
-    (compat--should* (regexp-opt '("a" "b" "c") 'words) '("a" "b" "c") 'words)
-    ;; Test empty list:
-    (compat--should* "\\(?:\\`a\\`\\)" '())
-    (compat--should* "\\<\\(\\`a\\`\\)\\>" '() 'words))
-  (let ((unmatchable (compat--regexp-opt #'regexp-opt '())))
+  (compat-test compat-regexp-opt
+               ;; Ensure `compat--regexp-opt' doesn't change the existing
+               ;; behaviour:
+               (compat--should (regexp-opt '("a" "b" "c")) '("a" "b" "c"))
+               (compat--should (regexp-opt '("abc" "def" "ghe")) '("abc" "def" 
"ghe"))
+               (compat--should (regexp-opt '("a" "b" "c") 'words) '("a" "b" 
"c") 'words)
+               ;; Test empty list:
+               (compat--should "\\(?:\\`a\\`\\)" '())
+               (compat--should "\\<\\(\\`a\\`\\)\\>" '() 'words))
+  (let ((unmatchable (compat--compat-regexp-opt '())))
     (dolist (str '(""                   ;empty string
                    "a"                  ;simple string
                    "aaa"                ;longer string
@@ -548,24 +548,24 @@ the compatibility function."
 
 (ert-deftest compat-assoc ()
   "Check if `compat--assoc' advice was advised correctly."
-  (compat-test assoc
+  (compat-test compat-assoc
     ;; Fallback behaviour:
-    (compat--should* nil 1 nil)               ;empty list
-    (compat--should* '(1) 1 '((1)))            ;single element list
-    (compat--should* nil 1 '(1))
-    (compat--should* '(2) 2 '((1) (2) (3)))    ;multiple element list
-    (compat--should* nil 2 '(1 2 3))
-    (compat--should* '(2) 2 '(1 (2) 3))
-    (compat--should* nil 2 '((1) 2 (3)))
-    (compat--should* '(1) 1 '((3) (2) (1)))
-    (compat--should* '("a") "a" '(("a") ("b") ("c")))  ;non-primitive elements
-    (compat--should* '("a" 0) "a" '(("c" . "a") "b" ("a" 0)))
+    (compat--should nil 1 nil)               ;empty list
+    (compat--should '(1) 1 '((1)))            ;single element list
+    (compat--should nil 1 '(1))
+    (compat--should '(2) 2 '((1) (2) (3)))    ;multiple element list
+    (compat--should nil 2 '(1 2 3))
+    (compat--should '(2) 2 '(1 (2) 3))
+    (compat--should nil 2 '((1) 2 (3)))
+    (compat--should '(1) 1 '((3) (2) (1)))
+    (compat--should '("a") "a" '(("a") ("b") ("c")))  ;non-primitive elements
+    (compat--should '("a" 0) "a" '(("c" . "a") "b" ("a" 0)))
     ;; With testfn (advised behaviour):
-    (compat--should* '(1) 3 '((10) (4) (1) (9)) #'<)
-    (compat--should* '("a") "b" '(("c") ("a") ("b")) #'string-lessp)
-    (compat--should* '("b") "a" '(("a") ("a") ("b"))
+    (compat--should '(1) 3 '((10) (4) (1) (9)) #'<)
+    (compat--should '("a") "b" '(("c") ("a") ("b")) #'string-lessp)
+    (compat--should '("b") "a" '(("a") ("a") ("b"))
                      (lambda (s1 s2) (not (string= s1 s2))))
-    (compat--should*
+    (compat--should
      '("\\.el\\'" . emacs-lisp-mode)
      "file.el"
      '(("\\.c\\'" . c-mode)
@@ -574,36 +574,36 @@ the compatibility function."
        ("\\.awk\\'" . awk-mode))
      #'string-match-p)))
 
-(when (fboundp 'alist-get)
-  (ert-deftest compat-alist-get-1 ()
-    "Check if `compat--alist-get' was advised correctly."
-    (compat-test (alist-get compat--alist-get-handle-testfn)
-      ;; Fallback behaviour:
-      (compat--should* nil 1 nil)                      ;empty list
-      (compat--should* 'a 1 '((1 . a)))                  ;single element list
-      (compat--should* nil 1 '(1))
-      (compat--should* 'b 2 '((1 . a) (2 . b) (3 . c)))  ;multiple element list
-      (compat--should* nil 2 '(1 2 3))
-      (compat--should* 'b 2 '(1 (2 . b) 3))
-      (compat--should* nil 2 '((1 . a) 2 (3 . c)))
-      (compat--should* 'a 1 '((3 . c) (2 . b) (1 . a)))
-      (compat--should* nil "a" '(("a" . 1) ("b" . 2) ("c" . 3)))  
;non-primitive elements
-
-      ;; With testfn (advised behaviour):
-      (compat--should* 1 "a" '(("a" . 1) ("b" . 2) ("c" . 3)) nil nil #'equal)
-      (compat--should* 1 3 '((10 . 10) (4 . 4) (1 . 1) (9 . 9)) nil nil #'<)
-      (compat--should* '(a) "b" '(("c" c) ("a" a) ("b" b)) nil nil 
#'string-lessp)
-      (compat--should* 'c "a" '(("a" . a) ("a" . b) ("b" . c)) nil nil
-                       (lambda (s1 s2) (not (string= s1 s2))))
-      (compat--should* 'emacs-lisp-mode
-                       "file.el"
-                       '(("\\.c\\'" . c-mode)
-                         ("\\.p\\'" . pascal-mode)
-                         ("\\.el\\'" . emacs-lisp-mode)
-                         ("\\.awk\\'" . awk-mode))
-                       nil nil #'string-match-p)
-      (compat--should* 'd 0 '((1 . a) (2 . b) (3 . c)) 'd) ;default value
-      (compat--should* 'd 2 '((1 . a) (2 . b) (3 . c)) 'd nil #'ignore))))
+;; (when (fboundp 'alist-get)
+;;   (ert-deftest compat-alist-get-1 ()
+;;     "Check if `compat--alist-get' was advised correctly."
+;;     (compat-test compat-alist-get
+;;       ;; Fallback behaviour:
+;;       (compat--should nil 1 nil)                      ;empty list
+;;       (compat--should 'a 1 '((1 . a)))                  ;single element list
+;;       (compat--should nil 1 '(1))
+;;       (compat--should 'b 2 '((1 . a) (2 . b) (3 . c)))  ;multiple element 
list
+;;       (compat--should nil 2 '(1 2 3))
+;;       (compat--should 'b 2 '(1 (2 . b) 3))
+;;       (compat--should nil 2 '((1 . a) 2 (3 . c)))
+;;       (compat--should 'a 1 '((3 . c) (2 . b) (1 . a)))
+;;       (compat--should nil "a" '(("a" . 1) ("b" . 2) ("c" . 3)))  
;non-primitive elements
+
+;;       ;; With testfn (advised behaviour):
+;;       (compat--should 1 "a" '(("a" . 1) ("b" . 2) ("c" . 3)) nil nil 
#'equal)
+;;       (compat--should 1 3 '((10 . 10) (4 . 4) (1 . 1) (9 . 9)) nil nil #'<)
+;;       (compat--should '(a) "b" '(("c" c) ("a" a) ("b" b)) nil nil 
#'string-lessp)
+;;       (compat--should 'c "a" '(("a" . a) ("a" . b) ("b" . c)) nil nil
+;;                        (lambda (s1 s2) (not (string= s1 s2))))
+;;       (compat--should 'emacs-lisp-mode
+;;                        "file.el"
+;;                        '(("\\.c\\'" . c-mode)
+;;                          ("\\.p\\'" . pascal-mode)
+;;                          ("\\.el\\'" . emacs-lisp-mode)
+;;                          ("\\.awk\\'" . awk-mode))
+;;                        nil nil #'string-match-p)
+;;       (compat--should 'd 0 '((1 . a) (2 . b) (3 . c)) 'd) ;default value
+;;       (compat--should 'd 2 '((1 . a) (2 . b) (3 . c)) 'd nil #'ignore))))
 
 (ert-deftest compat-alist-get-2 ()
   "Check if `compat--alist-get' was implemented correctly."
@@ -889,143 +889,143 @@ the compatibility function."
 
 (ert-deftest compat-sort ()
   "Check if `compat--sort' was advised correctly."
-  (compat-test sort
-    (compat--should* (list 1 2 3) (list 1 2 3) #'<)
-    (compat--should* (list 1 2 3) (list 3 2 1) #'<)
-    (compat--should* '[1 2 3] '[1 2 3] #'<)
-    (compat--should* '[1 2 3] '[3 2 1] #'<)))
+  (compat-test compat-sort
+    (compat--should (list 1 2 3) (list 1 2 3) #'<)
+    (compat--should (list 1 2 3) (list 3 2 1) #'<)
+    (compat--should '[1 2 3] '[1 2 3] #'<)
+    (compat--should '[1 2 3] '[3 2 1] #'<)))
 
 (ert-deftest compat-= ()
   "Check if `compat--=' was advised correctly."
-  (compat-test =
-    (compat--should* t 0 0)
-    (compat--should* t 0 0 0)
-    (compat--should* t 0 0 0 0)
-    (compat--should* t 0 0 0 0 0)
-    (compat--should* t 0.0 0.0)
-    (compat--should* t +0.0 -0.0)
-    (compat--should* t 0.0 0.0 0.0)
-    (compat--should* t 0.0 0.0 0.0 0.0)
-    (compat--should* nil 0 1)
-    (compat--should* nil 0 0 1)
-    (compat--should* nil 0 0 0 0 1)
-    (compat--error* wrong-type-argument 0 0 'a)
-    (compat--should* nil 0 1 'a)
-    (compat--should* nil 0.0 0.0 0.0 0.1)))
+  (compat-test compat-=
+    (compat--should t 0 0)
+    (compat--should t 0 0 0)
+    (compat--should t 0 0 0 0)
+    (compat--should t 0 0 0 0 0)
+    (compat--should t 0.0 0.0)
+    (compat--should t +0.0 -0.0)
+    (compat--should t 0.0 0.0 0.0)
+    (compat--should t 0.0 0.0 0.0 0.0)
+    (compat--should nil 0 1)
+    (compat--should nil 0 0 1)
+    (compat--should nil 0 0 0 0 1)
+    (compat--error wrong-type-argument 0 0 'a)
+    (compat--should nil 0 1 'a)
+    (compat--should nil 0.0 0.0 0.0 0.1)))
 
 (ert-deftest compat-< ()
   "Check if `compat--<' was advised correctly."
-  (compat-test <
-    (compat--should* nil 0 0)
-    (compat--should* nil 0 0 0)
-    (compat--should* nil 0 0 0 0)
-    (compat--should* nil 0 0 0 0 0)
-    (compat--should* nil 0.0 0.0)
-    (compat--should* nil +0.0 -0.0)
-    (compat--should* nil 0.0 0.0 0.0)
-    (compat--should* nil 0.0 0.0 0.0 0.0)
-    (compat--should* t 0 1)
-    (compat--should* nil 1 0)
-    (compat--should* nil 0 0 1)
-    (compat--should* t 0 1 2)
-    (compat--should* nil 2 1 0)
-    (compat--should* nil 0 0 0 0 1)
-    (compat--should* t 0 1 2 3 4)
-    (compat--error* wrong-type-argument 0 1 'a)
-    (compat--should* nil 0 0 'a)
-    (compat--should* nil 0.0 0.0 0.0 0.1)
-    (compat--should* t -0.1 0.0 0.2 0.4)
-    (compat--should* t -0.1 0 0.2 0.4)))
+  (compat-test compat-<
+    (compat--should nil 0 0)
+    (compat--should nil 0 0 0)
+    (compat--should nil 0 0 0 0)
+    (compat--should nil 0 0 0 0 0)
+    (compat--should nil 0.0 0.0)
+    (compat--should nil +0.0 -0.0)
+    (compat--should nil 0.0 0.0 0.0)
+    (compat--should nil 0.0 0.0 0.0 0.0)
+    (compat--should t 0 1)
+    (compat--should nil 1 0)
+    (compat--should nil 0 0 1)
+    (compat--should t 0 1 2)
+    (compat--should nil 2 1 0)
+    (compat--should nil 0 0 0 0 1)
+    (compat--should t 0 1 2 3 4)
+    (compat--error wrong-type-argument 0 1 'a)
+    (compat--should nil 0 0 'a)
+    (compat--should nil 0.0 0.0 0.0 0.1)
+    (compat--should t -0.1 0.0 0.2 0.4)
+    (compat--should t -0.1 0 0.2 0.4)))
 
 (ert-deftest compat-> ()
   "Check if `compat-->' was advised correctly."
-  (compat-test >
-    (compat--should* nil 0 0)
-    (compat--should* nil 0 0 0)
-    (compat--should* nil 0 0 0 0)
-    (compat--should* nil 0 0 0 0 0)
-    (compat--should* nil 0.0 0.0)
-    (compat--should* nil +0.0 -0.0)
-    (compat--should* nil 0.0 0.0 0.0)
-    (compat--should* nil 0.0 0.0 0.0 0.0)
-    (compat--should* t 1 0)
-    (compat--should* nil 1 0 0)
-    (compat--should* nil 0 1 2)
-    (compat--should* t 2 1 0)
-    (compat--should* nil 1 0 0 0 0)
-    (compat--should* t 4 3 2 1 0)
-    (compat--should* nil 4 3 2 1 1)
-    (compat--error* wrong-type-argument 1 0 'a)
-    (compat--should* nil 0 0 'a)
-    (compat--should* nil 0.1 0.0 0.0 0.0)
-    (compat--should* t 0.4 0.2 0.0 -0.1)
-    (compat--should* t 0.4 0.2 0 -0.1)))
+  (compat-test compat->
+    (compat--should nil 0 0)
+    (compat--should nil 0 0 0)
+    (compat--should nil 0 0 0 0)
+    (compat--should nil 0 0 0 0 0)
+    (compat--should nil 0.0 0.0)
+    (compat--should nil +0.0 -0.0)
+    (compat--should nil 0.0 0.0 0.0)
+    (compat--should nil 0.0 0.0 0.0 0.0)
+    (compat--should t 1 0)
+    (compat--should nil 1 0 0)
+    (compat--should nil 0 1 2)
+    (compat--should t 2 1 0)
+    (compat--should nil 1 0 0 0 0)
+    (compat--should t 4 3 2 1 0)
+    (compat--should nil 4 3 2 1 1)
+    (compat--error wrong-type-argument 1 0 'a)
+    (compat--should nil 0 0 'a)
+    (compat--should nil 0.1 0.0 0.0 0.0)
+    (compat--should t 0.4 0.2 0.0 -0.1)
+    (compat--should t 0.4 0.2 0 -0.1)))
 
 (ert-deftest compat-<= ()
   "Check if `compat--<=' was advised correctly."
-  (compat-test <=
-    (compat--should* t 0 0)
-    (compat--should* t 0 0 0)
-    (compat--should* t 0 0 0 0)
-    (compat--should* t 0 0 0 0 0)
-    (compat--should* t 0.0 0.0)
-    (compat--should* t +0.0 -0.0)
-    (compat--should* t 0.0 0.0 0.0)
-    (compat--should* t 0.0 0.0 0.0 0.0)
-    (compat--should* nil 1 0)
-    (compat--should* nil 1 0 0)
-    (compat--should* t 0 1 2)
-    (compat--should* nil 2 1 0)
-    (compat--should* nil 1 0 0 0 0)
-    (compat--should* nil 4 3 2 1 0)
-    (compat--should* nil 4 3 2 1 1)
-    (compat--should* t 0 1 2 3 4)
-    (compat--should* t 1 1 2 3 4)
-    (compat--error* wrong-type-argument 0 0 'a)
-    (compat--error* wrong-type-argument 0 1 'a)
-    (compat--should* nil 1 0 'a)
-    (compat--should* nil 0.1 0.0 0.0 0.0)
-    (compat--should* t 0.0 0.0 0.0 0.1)
-    (compat--should* t -0.1 0.0 0.2 0.4)
-    (compat--should* t -0.1 0.0 0.0 0.2 0.4)
-    (compat--should* t -0.1 0.0 0 0.2 0.4)
-    (compat--should* t -0.1 0 0.2 0.4)
-    (compat--should* nil 0.4 0.2 0.0 -0.1)
-    (compat--should* nil 0.4 0.2 0.0 0.0 -0.1)
-    (compat--should* nil 0.4 0.2 0 0.0 0.0 -0.1)
-    (compat--should* nil 0.4 0.2 0 -0.1)))
+  (compat-test compat-<=
+    (compat--should t 0 0)
+    (compat--should t 0 0 0)
+    (compat--should t 0 0 0 0)
+    (compat--should t 0 0 0 0 0)
+    (compat--should t 0.0 0.0)
+    (compat--should t +0.0 -0.0)
+    (compat--should t 0.0 0.0 0.0)
+    (compat--should t 0.0 0.0 0.0 0.0)
+    (compat--should nil 1 0)
+    (compat--should nil 1 0 0)
+    (compat--should t 0 1 2)
+    (compat--should nil 2 1 0)
+    (compat--should nil 1 0 0 0 0)
+    (compat--should nil 4 3 2 1 0)
+    (compat--should nil 4 3 2 1 1)
+    (compat--should t 0 1 2 3 4)
+    (compat--should t 1 1 2 3 4)
+    (compat--error wrong-type-argument 0 0 'a)
+    (compat--error wrong-type-argument 0 1 'a)
+    (compat--should nil 1 0 'a)
+    (compat--should nil 0.1 0.0 0.0 0.0)
+    (compat--should t 0.0 0.0 0.0 0.1)
+    (compat--should t -0.1 0.0 0.2 0.4)
+    (compat--should t -0.1 0.0 0.0 0.2 0.4)
+    (compat--should t -0.1 0.0 0 0.2 0.4)
+    (compat--should t -0.1 0 0.2 0.4)
+    (compat--should nil 0.4 0.2 0.0 -0.1)
+    (compat--should nil 0.4 0.2 0.0 0.0 -0.1)
+    (compat--should nil 0.4 0.2 0 0.0 0.0 -0.1)
+    (compat--should nil 0.4 0.2 0 -0.1)))
 
 (ert-deftest compat->= ()
   "Check if `compat-->=' was implemented correctly."
-  (compat-test >=
-    (compat--should* t 0 0)
-    (compat--should* t 0 0 0)
-    (compat--should* t 0 0 0 0)
-    (compat--should* t 0 0 0 0 0)
-    (compat--should* t 0.0 0.0)
-    (compat--should* t +0.0 -0.0)
-    (compat--should* t 0.0 0.0 0.0)
-    (compat--should* t 0.0 0.0 0.0 0.0)
-    (compat--should* t 1 0)
-    (compat--should* t 1 0 0)
-    (compat--should* nil 0 1 2)
-    (compat--should* t 2 1 0)
-    (compat--should* t 1 0 0 0 0)
-    (compat--should* t 4 3 2 1 0)
-    (compat--should* t 4 3 2 1 1)
-    (compat--error* wrong-type-argument 0 0 'a)
-    (compat--error* wrong-type-argument 1 0 'a)
-    (compat--should* nil 0 1 'a)
-    (compat--should* t 0.1 0.0 0.0 0.0)
-    (compat--should* nil 0.0 0.0 0.0 0.1)
-    (compat--should* nil -0.1 0.0 0.2 0.4)
-    (compat--should* nil -0.1 0.0 0.0 0.2 0.4)
-    (compat--should* nil -0.1 0.0 0 0.2 0.4)
-    (compat--should* nil -0.1 0 0.2 0.4)
-    (compat--should* t 0.4 0.2 0.0 -0.1)
-    (compat--should* t 0.4 0.2 0.0 0.0 -0.1)
-    (compat--should* t 0.4 0.2 0 0.0 0.0 -0.1)
-    (compat--should* t 0.4 0.2 0 -0.1)))
+  (compat-test compat->=
+    (compat--should t 0 0)
+    (compat--should t 0 0 0)
+    (compat--should t 0 0 0 0)
+    (compat--should t 0 0 0 0 0)
+    (compat--should t 0.0 0.0)
+    (compat--should t +0.0 -0.0)
+    (compat--should t 0.0 0.0 0.0)
+    (compat--should t 0.0 0.0 0.0 0.0)
+    (compat--should t 1 0)
+    (compat--should t 1 0 0)
+    (compat--should nil 0 1 2)
+    (compat--should t 2 1 0)
+    (compat--should t 1 0 0 0 0)
+    (compat--should t 4 3 2 1 0)
+    (compat--should t 4 3 2 1 1)
+    (compat--error wrong-type-argument 0 0 'a)
+    (compat--error wrong-type-argument 1 0 'a)
+    (compat--should nil 0 1 'a)
+    (compat--should t 0.1 0.0 0.0 0.0)
+    (compat--should nil 0.0 0.0 0.0 0.1)
+    (compat--should nil -0.1 0.0 0.2 0.4)
+    (compat--should nil -0.1 0.0 0.0 0.2 0.4)
+    (compat--should nil -0.1 0.0 0 0.2 0.4)
+    (compat--should nil -0.1 0 0.2 0.4)
+    (compat--should t 0.4 0.2 0.0 -0.1)
+    (compat--should t 0.4 0.2 0.0 0.0 -0.1)
+    (compat--should t 0.4 0.2 0 0.0 0.0 -0.1)
+    (compat--should t 0.4 0.2 0 -0.1)))
 
 (ert-deftest compat-special-form-p ()
   "Check if `compat--special-form-p' was implemented correctly."
@@ -1070,10 +1070,10 @@ the compatibility function."
 
 (ert-deftest compat-split-string ()
   "Check if `compat--split-string' was advised correctly."
-  (compat-test split-string
-    (compat--should* '("a" "b" "c") "a b c")
-    (compat--should* '("..a.." "..b.." "..c..") "..a.. ..b.. ..c..")
-    (compat--should* '("a" "b" "c") "..a.. ..b.. ..c.." nil nil "\\.+")))
+  (compat-test compat-split-string
+    (compat--should '("a" "b" "c") "a b c")
+    (compat--should '("..a.." "..b.." "..c..") "..a.. ..b.. ..c..")
+    (compat--should '("a" "b" "c") "..a.. ..b.. ..c.." nil nil "\\.+")))
 
 (ert-deftest compat-delete-consecutive-dups ()
   "Check if `compat--delete-consecutive-dups' was implemented correctly."
@@ -1152,21 +1152,21 @@ the compatibility function."
 
 (ert-deftest compat-file-size-human-readable ()
   "Check if `compat--file-size-human-readable' was advised properly."
-  (compat-test file-size-human-readable
-    (compat--should* "1000" 1000)
-    (compat--should* "1k" 1024)
-    (compat--should* "1M" (* 1024 1024))
-    (compat--should* "1G" (expt 1024 3))
-    (compat--should* "1T" (expt 1024 4))
-    (compat--should* "1k" 1000 'si)
-    (compat--should* "1KiB" 1024 'iec)
-    (compat--should* "1KiB" 1024 'iec)
-    (compat--should* "1 KiB" 1024 'iec " ")
-    (compat--should* "1KiA" 1024 'iec nil "A")
-    (compat--should* "1 KiA" 1024 'iec " " "A")
-    (compat--should* "1kA" 1000 'si nil "A")
-    (compat--should* "1 k" 1000 'si " ")
-    (compat--should* "1 kA" 1000 'si " " "A")))
+  (compat-test compat-file-size-human-readable
+    (compat--should "1000" 1000)
+    (compat--should "1k" 1024)
+    (compat--should "1M" (* 1024 1024))
+    (compat--should "1G" (expt 1024 3))
+    (compat--should "1T" (expt 1024 4))
+    (compat--should "1k" 1000 'si)
+    (compat--should "1KiB" 1024 'iec)
+    (compat--should "1KiB" 1024 'iec)
+    (compat--should "1 KiB" 1024 'iec " ")
+    (compat--should "1KiA" 1024 'iec nil "A")
+    (compat--should "1 KiA" 1024 'iec " " "A")
+    (compat--should "1kA" 1000 'si nil "A")
+    (compat--should "1 k" 1000 'si " ")
+    (compat--should "1 kA" 1000 'si " " "A")))
 
 (ert-deftest compat-format-prompt ()
   "Check if `compat--file-size-human-readable' was implemented properly."
@@ -1328,11 +1328,11 @@ the compatibility function."
         (b-map (make-sparse-keymap)))
     (define-key a-map "x" 'foo)
     (define-key b-map "x" 'bar)
-    (compat-test lookup-key
-      (compat--should* 'foo a-map "x")
-      (compat--should* 'bar b-map "x")
-      (compat--should* 'foo (list a-map b-map) "x")
-      (compat--should* 'bar (list b-map a-map) "x"))))
+    (compat-test compat-lookup-key
+      (compat--should 'foo a-map "x")
+      (compat--should 'bar b-map "x")
+      (compat--should 'foo (list a-map b-map) "x")
+      (compat--should 'bar (list b-map a-map) "x"))))
 
 (provide 'compat-tests)
 ;;; compat-tests.el ends here



reply via email to

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