[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/compat eafe584 15/99: Remove unnecessary eval-and-compi
From: |
ELPA Syncer |
Subject: |
[elpa] externals/compat eafe584 15/99: Remove unnecessary eval-and-compile block from compat-tests |
Date: |
Sun, 17 Oct 2021 05:57:49 -0400 (EDT) |
branch: externals/compat
commit eafe5848b4c2c1b59dd9ba476d120110791502d5
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>
Remove unnecessary eval-and-compile block from compat-tests
---
compat-tests.el | 1543 +++++++++++++++++++++++++++----------------------------
1 file changed, 771 insertions(+), 772 deletions(-)
diff --git a/compat-tests.el b/compat-tests.el
index fe83f04..f4495a3 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -64,273 +64,272 @@
;;; Code:
(require 'ert)
-(eval-and-compile
- (require 'compat-macs)
-
- (load "compat-24.2.el" nil nil nil t)
- (load "compat-24.3.el" nil nil nil t)
- (load "compat-24.4.el" nil nil nil t)
- (load "compat-25.1.el" nil nil nil t)
- (load "compat-26.1.el" nil nil nil t)
- (load "compat-27.1.el" nil nil nil t)
- (load "compat-28.1.el" nil nil nil t)
-
- (defvar compat--current-fn nil)
- (defvar compat--compat-fn nil)
-
- (defmacro compat--should (result &rest input)
- "Generate code for test with INPUT evaluating to RESULT."
- (let ((cfn (or compat--compat-fn
- (intern (format "compat--%s" compat--current-fn))))
- (rfn compat--current-fn))
- `(progn
- (should (equal (,cfn ,@input) ,result))
- (should (equal (,rfn ,@input) ,result)))))
-
- (defmacro compat--should* (result &rest input)
- "Generate code for test with INPUT evaluating to RESULT."
- (let ((cfn (or compat--compat-fn
- (intern (format "compat--%s" compat--current-fn))))
- (rfn compat--current-fn))
- `(progn
- (should (equal (funcall (apply-partially #',cfn #',rfn) ,@input)
,result))
- (should (equal (,rfn ,@input) ,result)))))
-
- (defmacro compat--mshould (result &rest input)
- "Generate code for test with INPUT evaluating to RESULT."
- (let ((cfn (or compat--compat-fn
- (intern (format "compat--%s" compat--current-fn))))
- (rfn compat--current-fn))
- `(progn
- (should (equal (macroexpand-all `(,',cfn ,,@input)) ,result))
- (should (equal (macroexpand-all `(,',rfn ,,@input)) ,result)))))
-
- (defmacro compat--error (error &rest input)
- "Generate code for test FN with INPUT to signal ERROR."
- (let ((cfn (or compat--compat-fn
- (intern (format "compat--%s" compat--current-fn))))
- (rfn compat--current-fn))
- `(progn
- (should-error (,cfn ,@input) :type ',error)
- (should-error (,rfn ,@input) :type ',error))))
-
- (defmacro compat--error* (error &rest input)
- "Generate code for test FN with INPUT to signal ERROR."
- (let ((cfn (or compat--compat-fn
- (intern (format "compat--%s" compat--current-fn))))
- (rfn compat--current-fn))
- `(progn
- (should-error (funcall (apply-partially #',cfn #',rfn) ,@input) :type
',error)
- (should-error (,rfn ,@input) :type ',error))))
-
- ;; FIXME: extract the name of the test out of the ERT-test, instead
- ;; of having to re-declare the name of the test redundantly.
- (defmacro compat-test (fn &rest body)
- "Set `compat--current-fn' to FN in BODY.
+(require 'compat-macs)
+
+(load "compat-24.2.el" nil nil nil t)
+(load "compat-24.3.el" nil nil nil t)
+(load "compat-24.4.el" nil nil nil t)
+(load "compat-25.1.el" nil nil nil t)
+(load "compat-26.1.el" nil nil nil t)
+(load "compat-27.1.el" nil nil nil t)
+(load "compat-28.1.el" nil nil nil t)
+
+(defvar compat--current-fn nil)
+(defvar compat--compat-fn nil)
+
+(defmacro compat--should (result &rest input)
+ "Generate code for test with INPUT evaluating to RESULT."
+ (let ((cfn (or compat--compat-fn
+ (intern (format "compat--%s" compat--current-fn))))
+ (rfn compat--current-fn))
+ `(progn
+ (should (equal (,cfn ,@input) ,result))
+ (should (equal (,rfn ,@input) ,result)))))
+
+(defmacro compat--should* (result &rest input)
+ "Generate code for test with INPUT evaluating to RESULT."
+ (let ((cfn (or compat--compat-fn
+ (intern (format "compat--%s" compat--current-fn))))
+ (rfn compat--current-fn))
+ `(progn
+ (should (equal (funcall (apply-partially #',cfn #',rfn) ,@input)
,result))
+ (should (equal (,rfn ,@input) ,result)))))
+
+(defmacro compat--mshould (result &rest input)
+ "Generate code for test with INPUT evaluating to RESULT."
+ (let ((cfn (or compat--compat-fn
+ (intern (format "compat--%s" compat--current-fn))))
+ (rfn compat--current-fn))
+ `(progn
+ (should (equal (macroexpand-all `(,',cfn ,,@input)) ,result))
+ (should (equal (macroexpand-all `(,',rfn ,,@input)) ,result)))))
+
+(defmacro compat--error (error &rest input)
+ "Generate code for test FN with INPUT to signal ERROR."
+ (let ((cfn (or compat--compat-fn
+ (intern (format "compat--%s" compat--current-fn))))
+ (rfn compat--current-fn))
+ `(progn
+ (should-error (,cfn ,@input) :type ',error)
+ (should-error (,rfn ,@input) :type ',error))))
+
+(defmacro compat--error* (error &rest input)
+ "Generate code for test FN with INPUT to signal ERROR."
+ (let ((cfn (or compat--compat-fn
+ (intern (format "compat--%s" compat--current-fn))))
+ (rfn compat--current-fn))
+ `(progn
+ (should-error (funcall (apply-partially #',cfn #',rfn) ,@input) :type
',error)
+ (should-error (,rfn ,@input) :type ',error))))
+
+;; FIXME: extract the name of the test out of the ERT-test, instead
+;; of having to re-declare the name of the test redundantly.
+(defmacro compat-test (fn &rest body)
+ "Set `compat--current-fn' to FN in BODY.
If FN is a list, the car should be the actual function, and cadr
the compatibility function."
- (declare (indent 1))
- (if (consp fn)
- (setq compat--current-fn (car fn)
- compat--compat-fn (cadr fn))
- (setq compat--current-fn fn
- compat--compat-fn nil))
- (macroexp-progn body)))
+ (declare (indent 1))
+ (if (consp fn)
+ (setq compat--current-fn (car fn)
+ compat--compat-fn (cadr fn))
+ (setq compat--current-fn fn
+ compat--compat-fn nil))
+ (macroexp-progn body))
(ert-deftest compat-string-search ()
"Check if `string-search' was implemented correctly."
(compat-test string-search
- ;; Find needle at the beginning of a haystack:
- (compat--should 0 "a" "abb")
- ;; Find needle at the begining of a haystack, with more potential
- ;; needles that could be found:
- (compat--should 0 "a" "abba")
- ;; Find needle with more than one charachter at the beginning of
- ;; a line:
- (compat--should 0 "aa" "aabbb")
- ;; Find a needle midstring:
- (compat--should 1 "a" "bab")
- ;; Find a needle at the end:
- (compat--should 2 "a" "bba")
- ;; Find a longer needle midstring:
- (compat--should 1 "aa" "baab")
- ;; Find a longer needle at the end:
- (compat--should 2 "aa" "bbaa")
- ;; Find a case-sensitive needle:
- (compat--should 2 "a" "AAa")
- ;; Find another case-sensitive needle:
- (compat--should 2 "aa" "AAaa")
- ;; Test regular expression quoting (1):
- (compat--should 5 "." "abbbb.b")
- ;; Test regular expression quoting (2):
- (compat--should 5 ".*" "abbbb.*b")
- ;; Attempt to find non-existent needle:
- (compat--should nil "a" "bbb")
- ;; Attempt to find non-existent needle that has the form of a
- ;; regular expression:
- (compat--should nil "." "bbb")
- ;; Handle empty string as needle:
- (compat--should 0 "" "abc")
- ;; Handle empty string as haystack:
- (compat--should nil "a" "")
- ;; Handle empty string as needle and haystack:
- (compat--should 0 "" "")
- ;; Handle START argument:
- (compat--should 3 "a" "abba" 1)
- ;; Additional test copied from:
- (compat--should 6 "zot" "foobarzot")
- (compat--should 0 "foo" "foobarzot")
- (compat--should nil "fooz" "foobarzot")
- (compat--should nil "zot" "foobarzo")
- (compat--should 0 "ab" "ab")
- (compat--should nil "ab\0" "ab")
- (compat--should 4 "ab" "abababab" 3)
- (compat--should nil "ab" "ababac" 3)
- (compat--should nil "aaa" "aa")
- (compat--should 5
- (make-string 2 130)
- (concat "helló" (make-string 5 130 t) "bár"))
- (compat--should 5
- (make-string 2 127)
- (concat "helló" (make-string 5 127 t) "bár"))
- (compat--should 1 "\377" "a\377ø")
- (compat--should 1 "\377" "a\377a")
- (compat--should nil (make-string 1 255) "a\377ø")
- (compat--should nil (make-string 1 255) "a\377a")
- (compat--should 3 "fóo" "zotfóo")
- (compat--should 2 (string-to-multibyte "\377") "ab\377c")
- (compat--should nil "\303" "aøb")
- (compat--should nil "\270" "aøb")
- (compat--should nil "ø" "\303\270")
- (compat--should nil "ø" (make-string 32 ?a))
- (compat--should nil "ø" (string-to-multibyte (make-string 32 ?a)))
- (compat--should 14 "o" (string-to-multibyte
- (apply #'string (number-sequence ?a ?z))))
- (compat--should 2 "a\U00010f98z" "a\U00010f98a\U00010f98z")
- (compat--error (args-out-of-range -1) "a" "abc" -1)
- (compat--error (args-out-of-range 4) "a" "abc" 4)
- (compat--error (args-out-of-range 100000000000)
- "a" "abc" 100000000000)
- (compat--should nil "a" "aaa" 3)
- (compat--should nil "aa" "aa" 1)
- (compat--should nil "\0" "")
- (compat--should 0 "" "")
- (compat--error (args-out-of-range 1) "" "" 1)
- (compat--should 0 "" "abc")
- (compat--should 2 "" "abc" 2)
- (compat--should 3 "" "abc" 3)
- (compat--error (args-out-of-range 4) "" "abc" 4)
- (compat--error (args-out-of-range -1) "" "abc" -1)
- (compat--should nil "ø" "foo\303\270")
- (compat--should nil "\303\270" "ø")
- (compat--should nil "\370" "ø")
- (compat--should nil (string-to-multibyte "\370") "ø")
- (compat--should nil "ø" "\370")
- (compat--should nil "ø" (string-to-multibyte "\370"))
- (compat--should nil "\303\270" "\370")
- (compat--should nil (string-to-multibyte "\303\270") "\370")
- (compat--should nil "\303\270" (string-to-multibyte "\370"))
- (compat--should nil
- (string-to-multibyte "\303\270")
- (string-to-multibyte "\370"))
- (compat--should nil "\370" "\303\270")
- (compat--should nil (string-to-multibyte "\370") "\303\270")
- (compat--should nil "\370" (string-to-multibyte "\303\270"))
- (compat--should nil
- (string-to-multibyte "\370")
- (string-to-multibyte "\303\270"))
- (compat--should 2
- (string-to-multibyte "o\303\270")
- "foo\303\270")
- (compat--should 3 "\303\270" "foo\303\270")))
+ ;; Find needle at the beginning of a haystack:
+ (compat--should 0 "a" "abb")
+ ;; Find needle at the begining of a haystack, with more
potential
+ ;; needles that could be found:
+ (compat--should 0 "a" "abba")
+ ;; Find needle with more than one charachter at the beginning of
+ ;; a line:
+ (compat--should 0 "aa" "aabbb")
+ ;; Find a needle midstring:
+ (compat--should 1 "a" "bab")
+ ;; Find a needle at the end:
+ (compat--should 2 "a" "bba")
+ ;; Find a longer needle midstring:
+ (compat--should 1 "aa" "baab")
+ ;; Find a longer needle at the end:
+ (compat--should 2 "aa" "bbaa")
+ ;; Find a case-sensitive needle:
+ (compat--should 2 "a" "AAa")
+ ;; Find another case-sensitive needle:
+ (compat--should 2 "aa" "AAaa")
+ ;; Test regular expression quoting (1):
+ (compat--should 5 "." "abbbb.b")
+ ;; Test regular expression quoting (2):
+ (compat--should 5 ".*" "abbbb.*b")
+ ;; Attempt to find non-existent needle:
+ (compat--should nil "a" "bbb")
+ ;; Attempt to find non-existent needle that has the form of a
+ ;; regular expression:
+ (compat--should nil "." "bbb")
+ ;; Handle empty string as needle:
+ (compat--should 0 "" "abc")
+ ;; Handle empty string as haystack:
+ (compat--should nil "a" "")
+ ;; Handle empty string as needle and haystack:
+ (compat--should 0 "" "")
+ ;; Handle START argument:
+ (compat--should 3 "a" "abba" 1)
+ ;; Additional test copied from:
+ (compat--should 6 "zot" "foobarzot")
+ (compat--should 0 "foo" "foobarzot")
+ (compat--should nil "fooz" "foobarzot")
+ (compat--should nil "zot" "foobarzo")
+ (compat--should 0 "ab" "ab")
+ (compat--should nil "ab\0" "ab")
+ (compat--should 4 "ab" "abababab" 3)
+ (compat--should nil "ab" "ababac" 3)
+ (compat--should nil "aaa" "aa")
+ (compat--should 5
+ (make-string 2 130)
+ (concat "helló" (make-string 5 130 t) "bár"))
+ (compat--should 5
+ (make-string 2 127)
+ (concat "helló" (make-string 5 127 t) "bár"))
+ (compat--should 1 "\377" "a\377ø")
+ (compat--should 1 "\377" "a\377a")
+ (compat--should nil (make-string 1 255) "a\377ø")
+ (compat--should nil (make-string 1 255) "a\377a")
+ (compat--should 3 "fóo" "zotfóo")
+ (compat--should 2 (string-to-multibyte "\377") "ab\377c")
+ (compat--should nil "\303" "aøb")
+ (compat--should nil "\270" "aøb")
+ (compat--should nil "ø" "\303\270")
+ (compat--should nil "ø" (make-string 32 ?a))
+ (compat--should nil "ø" (string-to-multibyte (make-string 32
?a)))
+ (compat--should 14 "o" (string-to-multibyte
+ (apply #'string (number-sequence ?a
?z))))
+ (compat--should 2 "a\U00010f98z" "a\U00010f98a\U00010f98z")
+ (compat--error (args-out-of-range -1) "a" "abc" -1)
+ (compat--error (args-out-of-range 4) "a" "abc" 4)
+ (compat--error (args-out-of-range 100000000000)
+ "a" "abc" 100000000000)
+ (compat--should nil "a" "aaa" 3)
+ (compat--should nil "aa" "aa" 1)
+ (compat--should nil "\0" "")
+ (compat--should 0 "" "")
+ (compat--error (args-out-of-range 1) "" "" 1)
+ (compat--should 0 "" "abc")
+ (compat--should 2 "" "abc" 2)
+ (compat--should 3 "" "abc" 3)
+ (compat--error (args-out-of-range 4) "" "abc" 4)
+ (compat--error (args-out-of-range -1) "" "abc" -1)
+ (compat--should nil "ø" "foo\303\270")
+ (compat--should nil "\303\270" "ø")
+ (compat--should nil "\370" "ø")
+ (compat--should nil (string-to-multibyte "\370") "ø")
+ (compat--should nil "ø" "\370")
+ (compat--should nil "ø" (string-to-multibyte "\370"))
+ (compat--should nil "\303\270" "\370")
+ (compat--should nil (string-to-multibyte "\303\270") "\370")
+ (compat--should nil "\303\270" (string-to-multibyte "\370"))
+ (compat--should nil
+ (string-to-multibyte "\303\270")
+ (string-to-multibyte "\370"))
+ (compat--should nil "\370" "\303\270")
+ (compat--should nil (string-to-multibyte "\370") "\303\270")
+ (compat--should nil "\370" (string-to-multibyte "\303\270"))
+ (compat--should nil
+ (string-to-multibyte "\370")
+ (string-to-multibyte "\303\270"))
+ (compat--should 2
+ (string-to-multibyte "o\303\270")
+ "foo\303\270")
+ (compat--should 3 "\303\270" "foo\303\270")))
(ert-deftest compat-string-replace ()
"Check if `string-replace' was implemented correctly."
(compat-test string-replace
- (compat--should "bba" "aa" "bb" "aaa")
- (compat--should "AAA" "aa" "bb" "AAA")
- ;; Additional test copied from subr-tests.el:
- (compat--should "zot" "foo" "bar" "zot")
- (compat--should "barzot" "foo" "bar" "foozot")
- (compat--should "barbarzot" "foo" "bar" "barfoozot")
- (compat--should "barfoobar" "zot" "bar" "barfoozot")
- (compat--should "barfoobarot" "z" "bar" "barfoozot")
- (compat--should "zat" "zot" "bar" "zat")
- (compat--should "zat" "azot" "bar" "zat")
- (compat--should "bar" "azot" "bar" "azot")
- (compat--should "foozotbar" "azot" "bar" "foozotbar")
- (compat--should "labarbarbarzot" "fo" "bar" "lafofofozot")
- (compat--should "axb" "\377" "x" "a\377b")
- (compat--should "axø" "\377" "x" "a\377ø")
- (compat--should "axb" (string-to-multibyte "\377") "x" "a\377b")
- (compat--should "axø" (string-to-multibyte "\377") "x" "a\377ø")
- (compat--should "ANAnas" "ana" "ANA" "ananas")
- (compat--should "" "a" "" "")
- (compat--should "" "a" "" "aaaaa")
- (compat--should "" "ab" "" "ababab")
- (compat--should "ccc" "ab" "" "abcabcabc")
- (compat--should "aaaaaa" "a" "aa" "aaa")
- (compat--should "defg" "abc" "defg" "abc")
- (compat--error wrong-length-argument "" "x" "abc")))
+ (compat--should "bba" "aa" "bb" "aaa")
+ (compat--should "AAA" "aa" "bb" "AAA")
+ ;; Additional test copied from subr-tests.el:
+ (compat--should "zot" "foo" "bar" "zot")
+ (compat--should "barzot" "foo" "bar" "foozot")
+ (compat--should "barbarzot" "foo" "bar" "barfoozot")
+ (compat--should "barfoobar" "zot" "bar" "barfoozot")
+ (compat--should "barfoobarot" "z" "bar" "barfoozot")
+ (compat--should "zat" "zot" "bar" "zat")
+ (compat--should "zat" "azot" "bar" "zat")
+ (compat--should "bar" "azot" "bar" "azot")
+ (compat--should "foozotbar" "azot" "bar" "foozotbar")
+ (compat--should "labarbarbarzot" "fo" "bar" "lafofofozot")
+ (compat--should "axb" "\377" "x" "a\377b")
+ (compat--should "axø" "\377" "x" "a\377ø")
+ (compat--should "axb" (string-to-multibyte "\377") "x" "a\377b")
+ (compat--should "axø" (string-to-multibyte "\377") "x" "a\377ø")
+ (compat--should "ANAnas" "ana" "ANA" "ananas")
+ (compat--should "" "a" "" "")
+ (compat--should "" "a" "" "aaaaa")
+ (compat--should "" "ab" "" "ababab")
+ (compat--should "ccc" "ab" "" "abcabcabc")
+ (compat--should "aaaaaa" "a" "aa" "aaa")
+ (compat--should "defg" "abc" "defg" "abc")
+ (compat--error wrong-length-argument "" "x" "abc")))
(ert-deftest compat-length= ()
"Check if `string-length=' was implemented correctly."
(compat-test length=
- (compat--should t '() 0) ;empty list
- (compat--should t '(1) 1) ;single element
- (compat--should t '(1 2 3) 3) ;multiple elements
- (compat--should nil '(1 2 3) 2) ;less than
- (compat--should nil '(1) 0)
- (compat--should nil '(1 2 3) 4) ;more than
- (compat--should nil '(1) 2)
- (compat--should nil '() 1)
- (compat--should t [] 0) ;empty vector
- (compat--should t [1] 1) ;single element vector
- (compat--should t [1 2 3] 3) ;multiple element vector
- (compat--should nil [1 2 3] 2) ;less than
- (compat--should nil [1 2 3] 4) ;more than
- (compat--error wrong-type-argument 3 nil)))
+ (compat--should t '() 0) ;empty list
+ (compat--should t '(1) 1) ;single element
+ (compat--should t '(1 2 3) 3) ;multiple elements
+ (compat--should nil '(1 2 3) 2) ;less than
+ (compat--should nil '(1) 0)
+ (compat--should nil '(1 2 3) 4) ;more than
+ (compat--should nil '(1) 2)
+ (compat--should nil '() 1)
+ (compat--should t [] 0) ;empty vector
+ (compat--should t [1] 1) ;single element
vector
+ (compat--should t [1 2 3] 3) ;multiple element
vector
+ (compat--should nil [1 2 3] 2) ;less than
+ (compat--should nil [1 2 3] 4) ;more than
+ (compat--error wrong-type-argument 3 nil)))
(ert-deftest compat-length< ()
"Check if `length<' was implemented correctly."
(compat-test length<
- (compat--should nil '(1) 0) ;single element
- (compat--should nil '(1 2 3) 2) ;multiple elements
- (compat--should nil '(1 2 3) 3) ;equal length
- (compat--should nil '(1) 1)
- (compat--should t '(1 2 3) 4) ;more than
- (compat--should t '(1) 2)
- (compat--should t '() 1)
- (compat--should nil [1] 0) ;single element vector
- (compat--should nil [1 2 3] 2) ;multiple element vector
- (compat--should nil [1 2 3] 3) ;equal length
- (compat--should t [1 2 3] 4) ;more than
- (compat--error wrong-type-argument 3 nil)))
+ (compat--should nil '(1) 0) ;single element
+ (compat--should nil '(1 2 3) 2) ;multiple elements
+ (compat--should nil '(1 2 3) 3) ;equal length
+ (compat--should nil '(1) 1)
+ (compat--should t '(1 2 3) 4) ;more than
+ (compat--should t '(1) 2)
+ (compat--should t '() 1)
+ (compat--should nil [1] 0) ;single element vector
+ (compat--should nil [1 2 3] 2) ;multiple element
vector
+ (compat--should nil [1 2 3] 3) ;equal length
+ (compat--should t [1 2 3] 4) ;more than
+ (compat--error wrong-type-argument 3 nil)))
(ert-deftest compat-length> ()
"Check if `length>' was implemented correctly."
(compat-test length>
- (compat--should t '(1) 0) ;single element
- (compat--should t '(1 2 3) 2) ;multiple elements
- (compat--should nil '(1 2 3) 3) ;equal length
- (compat--should nil '(1) 1)
- (compat--should nil '(1 2 3) 4) ;more than
- (compat--should nil '(1) 2)
- (compat--should nil '() 1)
- (compat--should t [1] 0) ;single element vector
- (compat--should t [1 2 3] 2) ;multiple element vector
- (compat--should nil [1 2 3] 3) ;equal length
- (compat--should nil [1 2 3] 4) ;more than
- (compat--error wrong-type-argument 3 nil)))
+ (compat--should t '(1) 0) ;single element
+ (compat--should t '(1 2 3) 2) ;multiple elements
+ (compat--should nil '(1 2 3) 3) ;equal length
+ (compat--should nil '(1) 1)
+ (compat--should nil '(1 2 3) 4) ;more than
+ (compat--should nil '(1) 2)
+ (compat--should nil '() 1)
+ (compat--should t [1] 0) ;single element
vector
+ (compat--should t [1 2 3] 2) ;multiple element
vector
+ (compat--should nil [1 2 3] 3) ;equal length
+ (compat--should nil [1 2 3] 4) ;more than
+ (compat--error wrong-type-argument 3 nil)))
(ert-deftest compat-always ()
"Check if `always' was implemented correctly."
(compat-test always
- (compat--should t) ;no arguments
- (compat--should t 1) ;single argument
- (compat--should t 1 2 3 4))) ;multiple arguments
+ (compat--should t) ;no arguments
+ (compat--should t 1) ;single argument
+ (compat--should t 1 2 3 4))) ;multiple arguments
(ert-deftest compat-insert-into-buffer ()
"Check if `insert-into-buffer' was implemented correctly."
@@ -386,135 +385,135 @@ the compatibility function."
(ert-deftest compat-file-name-with-extension ()
"Check if `file-name-with-extension' was implemented correctly."
(compat-test file-name-with-extension
- (compat--should "file.ext" "file" "ext")
- (compat--should "file.ext" "file" ".ext")
- (compat--should "file.ext" "file." ".ext")
- (compat--should "file..ext" "file.." ".ext")
- (compat--should "file..ext" "file." "..ext")
- (compat--should "file...ext" "file.." "..ext")
- (compat--should "/abs/file.ext" "/abs/file" "ext")
- (compat--should "/abs/file.ext" "/abs/file" ".ext")
- (compat--should "/abs/file.ext" "/abs/file." ".ext")
- (compat--should "/abs/file..ext" "/abs/file.." ".ext")
- (compat--should "/abs/file..ext" "/abs/file." "..ext")
- (compat--should "/abs/file...ext" "/abs/file.." "..ext")
- (compat--error error "file" "")
- (compat--error error '"" "ext")
- (compat--error error "file" "")
- (compat--error error "rel/" "ext")
- (compat--error error "/abs/" "ext")))
+ (compat--should "file.ext" "file" "ext")
+ (compat--should "file.ext" "file" ".ext")
+ (compat--should "file.ext" "file." ".ext")
+ (compat--should "file..ext" "file.." ".ext")
+ (compat--should "file..ext" "file." "..ext")
+ (compat--should "file...ext" "file.." "..ext")
+ (compat--should "/abs/file.ext" "/abs/file" "ext")
+ (compat--should "/abs/file.ext" "/abs/file" ".ext")
+ (compat--should "/abs/file.ext" "/abs/file." ".ext")
+ (compat--should "/abs/file..ext" "/abs/file.." ".ext")
+ (compat--should "/abs/file..ext" "/abs/file." "..ext")
+ (compat--should "/abs/file...ext" "/abs/file.." "..ext")
+ (compat--error error "file" "")
+ (compat--error error '"" "ext")
+ (compat--error error "file" "")
+ (compat--error error "rel/" "ext")
+ (compat--error error "/abs/" "ext")))
(ert-deftest compat-file-name-with-extension ()
"Check if `file-name-with-extension' was implemented correctly."
(compat-test file-name-with-extension
- (compat--should "file.ext" "file" "ext")
- (compat--should "file.ext" "file" ".ext")
- (compat--should "file.ext" "file." ".ext")
- (compat--should "file..ext" "file.." ".ext")
- (compat--should "file..ext" "file." "..ext")
- (compat--should "file...ext" "file.." "..ext")
- (compat--should "/abs/file.ext" "/abs/file" "ext")
- (compat--should "/abs/file.ext" "/abs/file" ".ext")
- (compat--should "/abs/file.ext" "/abs/file." ".ext")
- (compat--should "/abs/file..ext" "/abs/file.." ".ext")
- (compat--should "/abs/file..ext" "/abs/file." "..ext")
- (compat--should "/abs/file...ext" "/abs/file.." "..ext")
- (compat--error error "file" "")
- (compat--error error "" "ext")
- (compat--error error "file" "")
- (compat--error error "rel/" "ext")
- (compat--error error "/abs/" "ext")))
+ (compat--should "file.ext" "file" "ext")
+ (compat--should "file.ext" "file" ".ext")
+ (compat--should "file.ext" "file." ".ext")
+ (compat--should "file..ext" "file.." ".ext")
+ (compat--should "file..ext" "file." "..ext")
+ (compat--should "file...ext" "file.." "..ext")
+ (compat--should "/abs/file.ext" "/abs/file" "ext")
+ (compat--should "/abs/file.ext" "/abs/file" ".ext")
+ (compat--should "/abs/file.ext" "/abs/file." ".ext")
+ (compat--should "/abs/file..ext" "/abs/file.." ".ext")
+ (compat--should "/abs/file..ext" "/abs/file." "..ext")
+ (compat--should "/abs/file...ext" "/abs/file.." "..ext")
+ (compat--error error "file" "")
+ (compat--error error "" "ext")
+ (compat--error error "file" "")
+ (compat--error error "rel/" "ext")
+ (compat--error error "/abs/" "ext")))
(ert-deftest compat-string-width ()
"Check if `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--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 `ensure-list' was implemented correctly."
(compat-test ensure-list
- (compat--should nil nil) ;empty list
- (compat--should '(1) '(1)) ;single element list
- (compat--should '(1 2 3) '(1 2 3)) ;multiple element list
- (compat--should '(1) 1))) ;atom
+ (compat--should nil nil) ;empty list
+ (compat--should '(1) '(1)) ;single
element list
+ (compat--should '(1 2 3) '(1 2 3)) ;multiple
element list
+ (compat--should '(1) 1))) ;atom
(ert-deftest compat-proper-list-p-1 ()
"Check if `proper-list-p' was implemented correctly (>=26.1)."
(compat-test (proper-list-p compat--proper-list-p-length-signal)
- (compat--should 0 ()) ;empty list
- (compat--should 1 '(1)) ;single element
- (compat--should 3 '(1 2 3)) ;multiple elements
- (compat--should nil '(1 . 2)) ;cons
- (compat--should nil '(1 2 . 3)) ;dotted
- (compat--should nil (let ((l (list 1 2 3))) ;circular
- (setf (nthcdr 3 l) l)
- l))))
+ (compat--should 0 ()) ;empty list
+ (compat--should 1 '(1)) ;single element
+ (compat--should 3 '(1 2 3)) ;multiple
elements
+ (compat--should nil '(1 . 2)) ;cons
+ (compat--should nil '(1 2 . 3)) ;dotted
+ (compat--should nil (let ((l (list 1 2 3)))
;circular
+ (setf (nthcdr 3 l) l)
+ l))))
(ert-deftest compat-proper-list-p-1 ()
"Check if `proper-list-p' was implemented correctly (<25.3)."
(compat-test (proper-list-p compat--proper-list-p-tortoise-hare)
- (compat--should 0 ()) ;empty list
- (compat--should 1 '(1)) ;single element
- (compat--should 3 '(1 2 3)) ;multiple elements
- (compat--should nil '(1 . 2)) ;cons
- (compat--should nil '(1 2 . 3)) ;dotted
- (compat--should nil (let ((l (list 1 2 3))) ;circular
- (setf (nthcdr 3 l) l)
- l))))
+ (compat--should 0 ()) ;empty list
+ (compat--should 1 '(1)) ;single element
+ (compat--should 3 '(1 2 3)) ;multiple
elements
+ (compat--should nil '(1 . 2)) ;cons
+ (compat--should nil '(1 2 . 3)) ;dotted
+ (compat--should nil (let ((l (list 1 2 3)))
;circular
+ (setf (nthcdr 3 l) l)
+ l))))
(ert-deftest compat-flatten-tree ()
"Check if `flatten-tree' was implemented correctly."
(compat-test flatten-tree
- ;; Example from docstring:
- (compat--should '(1 2 3 4 5 6 7) '(1 (2 . 3) nil (4 5 (6)) 7))
- ;; Trivial example
- (compat--should nil ())
- ;; Simple examples
- (compat--should '(1) '(1))
- (compat--should '(1 2) '(1 2))
- (compat--should '(1 2 3) '(1 2 3))
- ;; Regular sublists
- (compat--should '(1) '((1)))
- (compat--should '(1 2) '((1) (2)))
- (compat--should '(1 2 3) '((1) (2) (3)))
- ;; Complex examples
- (compat--should '(1) '(((((1))))))
- (compat--should '(1 2 3 4) '((1) nil 2 ((3 4))))
- (compat--should '(1 2 3 4) '(((1 nil)) 2 (((3 nil nil) 4))))))
+ ;; Example from docstring:
+ (compat--should '(1 2 3 4 5 6 7) '(1 (2 . 3) nil (4 5 (6)) 7))
+ ;; Trivial example
+ (compat--should nil ())
+ ;; Simple examples
+ (compat--should '(1) '(1))
+ (compat--should '(1 2) '(1 2))
+ (compat--should '(1 2 3) '(1 2 3))
+ ;; Regular sublists
+ (compat--should '(1) '((1)))
+ (compat--should '(1 2) '((1) (2)))
+ (compat--should '(1 2 3) '((1) (2) (3)))
+ ;; Complex examples
+ (compat--should '(1) '(((((1))))))
+ (compat--should '(1 2 3 4) '((1) nil 2 ((3 4))))
+ (compat--should '(1 2 3 4) '(((1 nil)) 2 (((3 nil nil) 4))))))
(ert-deftest compat-xor ()
"Check if `xor' was implemented correctly."
(compat-test xor
- (compat--should t t nil)
- (compat--should t nil t)
- (compat--should nil nil nil)
- (compat--should nil t t)))
+ (compat--should t t nil)
+ (compat--should t nil t)
+ (compat--should nil nil nil)
+ (compat--should nil t t)))
(ert-deftest compat-string-distance ()
"Check if `string-distance' was implemented correctly."
(compat-test string-distance
- (compat--should 3 "kitten" "sitting") ;from wikipedia
- (compat--should 0 "" "") ;trivial examples
- (compat--should 0 "a" "a")
- (compat--should 1 "" "a")
- (compat--should 1 "b" "a")
- (compat--should 2 "aa" "bb")
- (compat--should 2 "aa" "bba")
- (compat--should 2 "aaa" "bba")
- (compat--should 3 "a" "あ" t) ;byte example
- (compat--should 1 "a" "あ")))
+ (compat--should 3 "kitten" "sitting") ;from wikipedia
+ (compat--should 0 "" "") ;trivial examples
+ (compat--should 0 "a" "a")
+ (compat--should 1 "" "a")
+ (compat--should 1 "b" "a")
+ (compat--should 2 "aa" "bb")
+ (compat--should 2 "aa" "bba")
+ (compat--should 2 "aaa" "bba")
+ (compat--should 3 "a" "あ" t) ;byte example
+ (compat--should 1 "a" "あ")))
(ert-deftest compat-regexp-unmatchable ()
"Check if `string-distance' was implemented correctly."
@@ -528,14 +527,14 @@ the compatibility function."
(ert-deftest compat-regexp-opt ()
"Check if `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))
+ ;; 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 (regexp-opt '())))
(dolist (str '("" ;empty string
"a" ;simple string
@@ -546,182 +545,182 @@ the compatibility function."
(ert-deftest compat-assoc ()
"Check if `assoc' advice was advised correctly."
(compat-test 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)))
- ;; 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"))
- (lambda (s1 s2) (not (string= s1 s2))))
- (compat--should*
- '("\\.el\\'" . emacs-lisp-mode)
- "file.el"
- '(("\\.c\\'" . c-mode)
- ("\\.p\\'" . pascal-mode)
- ("\\.el\\'" . emacs-lisp-mode)
- ("\\.awk\\'" . awk-mode))
- #'string-match-p)))
+ ;; 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)))
+ ;; 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"))
+ (lambda (s1 s2) (not (string= s1 s2))))
+ (compat--should*
+ '("\\.el\\'" . emacs-lisp-mode)
+ "file.el"
+ '(("\\.c\\'" . c-mode)
+ ("\\.p\\'" . pascal-mode)
+ ("\\.el\\'" . emacs-lisp-mode)
+ ("\\.awk\\'" . awk-mode))
+ #'string-match-p)))
(ert-deftest compat-alist-get-1 ()
"Check if `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)))
+ ;; 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 `alist-get' was implemented correctly."
(compat-test (alist-get compat--alist-get-full-elisp)
- ;; 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)))
+ ;; 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-string-trim-left ()
"Check if `string-trim-left' was implemented correctly."
(compat-test string-trim-left'
- (compat--should "" "") ;empty string
- (compat--should "a" "a") ;"full" string
- (compat--should "aaa" "aaa")
- (compat--should "へっろ" "へっろ")
- (compat--should "hello world" "hello world")
- (compat--should "a " "a ") ;right trailing
- (compat--should "aaa " "aaa ")
- (compat--should "a " "a ")
- (compat--should "a\t\t" "a\t\t")
- (compat--should "a\n \t" "a\n \t")
- (compat--should "a" " a") ;left trailing
- (compat--should "aaa" " aaa")
- (compat--should "a" "a")
- (compat--should "a" "\t\ta")
- (compat--should "a" "\n \ta")
- (compat--should "a " " a ") ;both trailing
- (compat--should "aaa " " aaa ")
- (compat--should "a\t\n" "\t\ta\t\n")
- (compat--should "a \n" "\n \ta \n")))
+ (compat--should "" "") ;empty string
+ (compat--should "a" "a") ;"full" string
+ (compat--should "aaa" "aaa")
+ (compat--should "へっろ" "へっろ")
+ (compat--should "hello world" "hello world")
+ (compat--should "a " "a ") ;right
trailing
+ (compat--should "aaa " "aaa ")
+ (compat--should "a " "a ")
+ (compat--should "a\t\t" "a\t\t")
+ (compat--should "a\n \t" "a\n \t")
+ (compat--should "a" " a") ;left trailing
+ (compat--should "aaa" " aaa")
+ (compat--should "a" "a")
+ (compat--should "a" "\t\ta")
+ (compat--should "a" "\n \ta")
+ (compat--should "a " " a ") ;both
trailing
+ (compat--should "aaa " " aaa ")
+ (compat--should "a\t\n" "\t\ta\t\n")
+ (compat--should "a \n" "\n \ta \n")))
(ert-deftest compat-string-trim-right ()
"Check if `string-trim-right' was implemented correctly."
(compat-test string-trim-right
- (compat--should "" "") ;empty string
- (compat--should "a" "a") ;"full" string
- (compat--should "aaa" "aaa")
- (compat--should "へっろ" "へっろ")
- (compat--should "hello world" "hello world")
- (compat--should "a" "a") ;right trailing
- (compat--should "aaa" "aaa")
- (compat--should "a" "a ")
- (compat--should "a" "a\t\t")
- (compat--should "a" "a\n \t")
- (compat--should " a" " a") ;left trailing
- (compat--should " aaa" " aaa")
- (compat--should "a" "a")
- (compat--should "\t\ta" "\t\ta")
- (compat--should "\n \ta" "\n \ta")
- (compat--should " a" " a ") ;both trailing
- (compat--should " aaa" " aaa")
- (compat--should "\t\ta" "\t\ta\t\n")
- (compat--should "\n \ta" "\n \ta \n")))
+ (compat--should "" "") ;empty string
+ (compat--should "a" "a") ;"full" string
+ (compat--should "aaa" "aaa")
+ (compat--should "へっろ" "へっろ")
+ (compat--should "hello world" "hello world")
+ (compat--should "a" "a") ;right trailing
+ (compat--should "aaa" "aaa")
+ (compat--should "a" "a ")
+ (compat--should "a" "a\t\t")
+ (compat--should "a" "a\n \t")
+ (compat--should " a" " a") ;left trailing
+ (compat--should " aaa" " aaa")
+ (compat--should "a" "a")
+ (compat--should "\t\ta" "\t\ta")
+ (compat--should "\n \ta" "\n \ta")
+ (compat--should " a" " a ") ;both
trailing
+ (compat--should " aaa" " aaa")
+ (compat--should "\t\ta" "\t\ta\t\n")
+ (compat--should "\n \ta" "\n \ta \n")))
(ert-deftest compat-string-trim ()
"Check if `string-trim' was implemented correctly."
(compat-test string-trim
- (compat--should "" "") ;empty string
- (compat--should "a" "a") ;"full" string
- (compat--should "aaa" "aaa")
- (compat--should "へっろ" "へっろ")
- (compat--should "hello world" "hello world")
- (compat--should "a" "a ") ;right trailing
- (compat--should "aaa" "aaa ")
- (compat--should "a" "a ")
- (compat--should "a" "a\t\t")
- (compat--should "a" "a\n \t")
- (compat--should "a" " a") ;left trailing
- (compat--should "aaa" " aaa")
- (compat--should "a" "a")
- (compat--should "a" "\t\ta")
- (compat--should "a" "\n \ta")
- (compat--should "a" " a ") ;both trailing
- (compat--should "aaa" " aaa ")
- (compat--should "t\ta" "t\ta\t\n")
- (compat--should "a" "\n \ta \n")))
+ (compat--should "" "") ;empty string
+ (compat--should "a" "a") ;"full" string
+ (compat--should "aaa" "aaa")
+ (compat--should "へっろ" "へっろ")
+ (compat--should "hello world" "hello world")
+ (compat--should "a" "a ") ;right trailing
+ (compat--should "aaa" "aaa ")
+ (compat--should "a" "a ")
+ (compat--should "a" "a\t\t")
+ (compat--should "a" "a\n \t")
+ (compat--should "a" " a") ;left trailing
+ (compat--should "aaa" " aaa")
+ (compat--should "a" "a")
+ (compat--should "a" "\t\ta")
+ (compat--should "a" "\n \ta")
+ (compat--should "a" " a ") ;both trailing
+ (compat--should "aaa" " aaa ")
+ (compat--should "t\ta" "t\ta\t\n")
+ (compat--should "a" "\n \ta \n")))
(ert-deftest compat-mapcan ()
"Check if `mapcan' was implemented correctly."
(compat-test mapcan
- (compat--should nil #'identity nil)
- (compat--should (list 1)
- #'identity
- (list (list 1)))
- (compat--should (list 1 2 3 4)
- #'identity
- (list (list 1) (list 2 3) (list 4)))
- (compat--should (list (list 1) (list 2 3) (list 4))
- #'list
- (list (list 1) (list 2 3) (list 4)))
- (compat--should (list 1 2 3 4)
- #'identity
- (list (list 1) (list) (list 2 3) (list 4)))
- (compat--should (list (list 1) (list) (list 2 3) (list 4))
- #'list
- (list (list 1) (list) (list 2 3) (list 4)))
- (compat--should (list)
- #'identity
- (list (list) (list) (list) (list)))))
+ (compat--should nil #'identity nil)
+ (compat--should (list 1)
+ #'identity
+ (list (list 1)))
+ (compat--should (list 1 2 3 4)
+ #'identity
+ (list (list 1) (list 2 3) (list 4)))
+ (compat--should (list (list 1) (list 2 3) (list 4))
+ #'list
+ (list (list 1) (list 2 3) (list 4)))
+ (compat--should (list 1 2 3 4)
+ #'identity
+ (list (list 1) (list) (list 2 3) (list 4)))
+ (compat--should (list (list 1) (list) (list 2 3) (list 4))
+ #'list
+ (list (list 1) (list) (list 2 3) (list 4)))
+ (compat--should (list)
+ #'identity
+ (list (list) (list) (list) (list)))))
;; Note: as the cXXX+r implementations are relatively trivial, their
;; tests are not as extensive.
@@ -738,462 +737,462 @@ the compatibility function."
(ert-deftest compat-caaar ()
"Check if `caaar' was implemented correctly."
(compat-test caaar
- (compat--should nil ())
- (compat--should 'a compat-cXXXr-test)))
+ (compat--should nil ())
+ (compat--should 'a compat-cXXXr-test)))
(ert-deftest compat-caadr ()
"Check if `caadr' was implemented correctly."
(compat-test caadr
- (compat--should nil ())
- (compat--should 'e compat-cXXXr-test)))
+ (compat--should nil ())
+ (compat--should 'e compat-cXXXr-test)))
(ert-deftest compat-cadar ()
"Check if `cadar' was implemented correctly."
(compat-test cadar
- (compat--should nil ())
- (compat--should 'c compat-cXXXr-test)))
+ (compat--should nil ())
+ (compat--should 'c compat-cXXXr-test)))
(ert-deftest compat-caddr ()
"Check if `caddr' was implemented correctly."
(compat-test caddr
- (compat--should nil ())
- (compat--should 'g compat-cXXXr-test)))
+ (compat--should nil ())
+ (compat--should 'g compat-cXXXr-test)))
(ert-deftest compat-cdaar ()
"Check if `cdaar' was implemented correctly."
(compat-test cdaar
- (compat--should nil ())
- (compat--should 'b compat-cXXXr-test)))
+ (compat--should nil ())
+ (compat--should 'b compat-cXXXr-test)))
(ert-deftest compat-cdadr ()
"Check if `cdadr' was implemented correctly."
(compat-test cdadr
- (compat--should nil ())
- (compat--should 'f compat-cXXXr-test)))
+ (compat--should nil ())
+ (compat--should 'f compat-cXXXr-test)))
(ert-deftest compat-cddar ()
"Check if `cddar' was implemented correctly."
(compat-test cddar
- (compat--should nil ())
- (compat--should 'd compat-cXXXr-test)))
+ (compat--should nil ())
+ (compat--should 'd compat-cXXXr-test)))
(ert-deftest compat-cdddr ()
"Check if `cdddr' was implemented correctly."
(compat-test cdddr
- (compat--should nil ())
- (compat--should 'h compat-cXXXr-test)
- #'cdddr))
+ (compat--should nil ())
+ (compat--should 'h compat-cXXXr-test)
+ #'cdddr))
(ert-deftest compat-caaaar ()
"Check if `caaaar' was implemented correctly."
(compat-test caaaar
- (compat--should nil ())
- (compat--should 'a compat-cXXXXr-test)))
+ (compat--should nil ())
+ (compat--should 'a compat-cXXXXr-test)))
(ert-deftest compat-caaadr ()
"Check if `caaadr' was implemented correctly."
(compat-test caaadr
- (compat--should nil ())
- (compat--should 'i compat-cXXXXr-test)))
+ (compat--should nil ())
+ (compat--should 'i compat-cXXXXr-test)))
(ert-deftest compat-caadar ()
"Check if `caadar' was implemented correctly."
(compat-test caadar
- (compat--should nil ())
- (compat--should 'e compat-cXXXXr-test)))
+ (compat--should nil ())
+ (compat--should 'e compat-cXXXXr-test)))
(ert-deftest compat-caaddr ()
"Check if `caaddr' was implemented correctly."
(compat-test caaddr
- (compat--should nil ())
- (compat--should 'm compat-cXXXXr-test)))
+ (compat--should nil ())
+ (compat--should 'm compat-cXXXXr-test)))
(ert-deftest compat-cadaar ()
"Check if `cadaar' was implemented correctly."
(compat-test cadaar
- (compat--should nil ())
- (compat--should 'c compat-cXXXXr-test)))
+ (compat--should nil ())
+ (compat--should 'c compat-cXXXXr-test)))
(ert-deftest compat-cadadr ()
"Check if `cadadr' was implemented correctly."
(compat-test cadadr
- (compat--should nil ())
- (compat--should 'k compat-cXXXXr-test)))
+ (compat--should nil ())
+ (compat--should 'k compat-cXXXXr-test)))
(ert-deftest compat-caddar ()
"Check if `caddar' was implemented correctly."
(compat-test caddar
- (compat--should nil ())
- (compat--should 'g compat-cXXXXr-test)))
+ (compat--should nil ())
+ (compat--should 'g compat-cXXXXr-test)))
(ert-deftest compat-cadddr ()
"Check if `cadddr' was implemented correctly."
(compat-test cadddr
- (compat--should nil ())
- (compat--should 'o compat-cXXXXr-test)))
+ (compat--should nil ())
+ (compat--should 'o compat-cXXXXr-test)))
(ert-deftest compat-cdaaar ()
"Check if `cdaaar' was implemented correctly."
(compat-test cdaaar
- (compat--should nil ())
- (compat--should 'b compat-cXXXXr-test)))
+ (compat--should nil ())
+ (compat--should 'b compat-cXXXXr-test)))
(ert-deftest compat-cdaadr ()
"Check if `cdaadr' was implemented correctly."
(compat-test cdaadr
- (compat--should nil ())
- (compat--should 'j compat-cXXXXr-test)))
+ (compat--should nil ())
+ (compat--should 'j compat-cXXXXr-test)))
(ert-deftest compat-cdadar ()
"Check if `cdadar' was implemented correctly."
(compat-test cdadar
- (compat--should nil ())
- (compat--should 'f compat-cXXXXr-test)))
+ (compat--should nil ())
+ (compat--should 'f compat-cXXXXr-test)))
(ert-deftest compat-cdaddr ()
"Check if `cdaddr' was implemented correctly."
(compat-test cdaddr
- (compat--should nil ())
- (compat--should 'j compat-cXXXXr-test)))
+ (compat--should nil ())
+ (compat--should 'j compat-cXXXXr-test)))
(ert-deftest compat-cddaar ()
"Check if `cddaar' was implemented correctly."
(compat-test cddaar
- (compat--should nil ())
- (compat--should 'd compat-cXXXXr-test)))
+ (compat--should nil ())
+ (compat--should 'd compat-cXXXXr-test)))
(ert-deftest compat-cddadr ()
"Check if `cddadr' was implemented correctly."
(compat-test cddadr
- (compat--should nil ())
- (compat--should 'l compat-cXXXXr-test)))
+ (compat--should nil ())
+ (compat--should 'l compat-cXXXXr-test)))
(ert-deftest compat-cdddar ()
"Check if `cdddar' was implemented correctly."
(compat-test cdddar
- (compat--should nil ())
- (compat--should 'h compat-cXXXXr-test)))
+ (compat--should nil ())
+ (compat--should 'h compat-cXXXXr-test)))
(ert-deftest compat-string-greaterp ()
"Check if `string-greaterp' was implemented correctly."
(compat-test string-greaterp
- (compat--should t "b" "a")
- (compat--should nil "a" "b")
- (compat--should t "aaab" "aaaa")
- (compat--should nil "aaaa" "aaab")))
+ (compat--should t "b" "a")
+ (compat--should nil "a" "b")
+ (compat--should t "aaab" "aaaa")
+ (compat--should nil "aaaa" "aaab")))
(ert-deftest compat-sort ()
"Check if `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--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 `=' 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--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 `<' 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--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 `>' 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--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 `<=' 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--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 `>=' 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--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 `special-form-p' was implemented correctly."
(compat-test special-form-p
- (compat--should t 'if)
- (compat--should t 'cond)
- (compat--should nil 'when)
- (compat--should nil 'defun)
- (compat--should nil '+)
- (compat--should nil nil)
- (compat--should nil "macro")
- (compat--should nil '(macro . +))))
+ (compat--should t 'if)
+ (compat--should t 'cond)
+ (compat--should nil 'when)
+ (compat--should nil 'defun)
+ (compat--should nil '+)
+ (compat--should nil nil)
+ (compat--should nil "macro")
+ (compat--should nil '(macro . +))))
(ert-deftest compat-macrop ()
"Check if `macrop' was implemented correctly."
(compat-test macrop
- (compat--should t 'lambda)
- (compat--should t 'defun)
- (compat--should t 'defmacro)
- (compat--should nil 'defalias)
- (compat--should nil 'if)
- (compat--should nil '+)
- (compat--should nil 1)
- (compat--should nil nil)
- (compat--should nil "macro")
- (compat--should t '(macro . +))))
+ (compat--should t 'lambda)
+ (compat--should t 'defun)
+ (compat--should t 'defmacro)
+ (compat--should nil 'defalias)
+ (compat--should nil 'if)
+ (compat--should nil '+)
+ (compat--should nil 1)
+ (compat--should nil nil)
+ (compat--should nil "macro")
+ (compat--should t '(macro . +))))
(ert-deftest compat-string-suffix-p ()
"Check if `string-suffix-p' was implemented correctly."
(compat-test string-suffix-p
- (compat--should t "a" "abba")
- (compat--should t "ba" "abba")
- (compat--should t "abba" "abba")
- (compat--should nil "a" "ABBA")
- (compat--should nil "bA" "ABBA")
- (compat--should nil "aBBA" "ABBA")
- (compat--should nil "c" "ABBA")
- (compat--should nil "c" "abba")
- (compat--should nil "cddc" "abba")
- (compat--should nil "aabba" "abba")))
+ (compat--should t "a" "abba")
+ (compat--should t "ba" "abba")
+ (compat--should t "abba" "abba")
+ (compat--should nil "a" "ABBA")
+ (compat--should nil "bA" "ABBA")
+ (compat--should nil "aBBA" "ABBA")
+ (compat--should nil "c" "ABBA")
+ (compat--should nil "c" "abba")
+ (compat--should nil "cddc" "abba")
+ (compat--should nil "aabba" "abba")))
(ert-deftest compat-split-string ()
"Check if `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--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 `delete-consecutive-dups' was implemented correctly."
(compat-test delete-consecutive-dups
- (compat--should '(1 2 3 4) '(1 2 3 4))
- (compat--should '(1 2 3 4) '(1 2 2 3 4 4))
- (compat--should '(1 2 3 2 4) '(1 2 2 3 2 4 4))))
+ (compat--should '(1 2 3 4) '(1 2 3 4))
+ (compat--should '(1 2 3 4) '(1 2 2 3 4 4))
+ (compat--should '(1 2 3 2 4) '(1 2 2 3 2 4 4))))
(ert-deftest compat-autoloadp ()
"Check if `autoloadp' was implemented correctly."
(compat-test autoloadp
- (compat--should t '(autoload . anything))
- (compat--should nil 'anything)))
+ (compat--should t '(autoload . anything))
+ (compat--should nil 'anything)))
(ert-deftest compat-file-name-base ()
"Check if `file-name-base' was implemented correctly."
(compat-test file-name-base
- (compat--should "file" "file.txt")
- (compat--should "file" "/path/to/some/file.txt")
- (compat--should "file" "/path/to/some/file")))
+ (compat--should "file" "file.txt")
+ (compat--should "file" "/path/to/some/file.txt")
+ (compat--should "file" "/path/to/some/file")))
(ert-deftest compat-posnp ()
"Check if `posnp' was implemented correctly."
(compat-test posnp
- ;; FIXME: return an actual posn.
- ;; (compat--should t (posn-at-point))
- (compat--should nil (current-buffer))
- (compat--should nil (point-max))
- (compat--should nil (point-min))
- (compat--should nil nil)))
+ ;; FIXME: return an actual posn.
+ ;; (compat--should t (posn-at-point))
+ (compat--should nil (current-buffer))
+ (compat--should nil (point-max))
+ (compat--should nil (point-min))
+ (compat--should nil nil)))
(ert-deftest compat-string-clean-whitespace ()
"Check if `string-clean-whitespace' was implemented correctly."
(compat-test string-clean-whitespace
- (compat--should "a b c" "a b c")
- (compat--should "a b c" " a b c")
- (compat--should "a b c" "a b c ")
- (compat--should "a b c" "a b c")
- (compat--should "a b c" "a b c")
- (compat--should "a b c" "a b c")
- (compat--should "a b c" " a b c")
- (compat--should "a b c" "a b c ")
- (compat--should "a b c" " a b c ")
- (compat--should "aa bb cc" "aa bb cc")
- (compat--should "aa bb cc" " aa bb cc")
- (compat--should "aa bb cc" "aa bb cc ")
- (compat--should "aa bb cc" "aa bb cc")
- (compat--should "aa bb cc" "aa bb cc")
- (compat--should "aa bb cc" "aa bb cc")
- (compat--should "aa bb cc" " aa bb cc")
- (compat--should "aa bb cc" "aa bb cc ")
- (compat--should "aa bb cc" " aa bb cc ")))
+ (compat--should "a b c" "a b c")
+ (compat--should "a b c" " a b c")
+ (compat--should "a b c" "a b c ")
+ (compat--should "a b c" "a b c")
+ (compat--should "a b c" "a b c")
+ (compat--should "a b c" "a b c")
+ (compat--should "a b c" " a b c")
+ (compat--should "a b c" "a b c ")
+ (compat--should "a b c" " a b c ")
+ (compat--should "aa bb cc" "aa bb cc")
+ (compat--should "aa bb cc" " aa bb cc")
+ (compat--should "aa bb cc" "aa bb cc ")
+ (compat--should "aa bb cc" "aa bb cc")
+ (compat--should "aa bb cc" "aa bb cc")
+ (compat--should "aa bb cc" "aa bb cc")
+ (compat--should "aa bb cc" " aa bb cc")
+ (compat--should "aa bb cc" "aa bb cc ")
+ (compat--should "aa bb cc" " aa bb cc ")))
(ert-deftest compat-string-fill ()
"Check if `string-fill' was implemented correctly."
(compat-test string-fill
- (compat--should "a a a a a" "a a a a a" 9)
- (compat--should "a a a a a" "a a a a a" 10)
- (compat--should "a a a a\na" "a a a a a" 8)
- (compat--should "a a a a\na" "a a a a a" 8)
- (compat--should "a a\na a\na" "a a a a a" 4)
- (compat--should "a\na\na\na\na" "a a a a a" 2)
- (compat--should "a\na\na\na\na" "a a a a a" 1)))
+ (compat--should "a a a a a" "a a a a a" 9)
+ (compat--should "a a a a a" "a a a a a" 10)
+ (compat--should "a a a a\na" "a a a a a" 8)
+ (compat--should "a a a a\na" "a a a a a" 8)
+ (compat--should "a a\na a\na" "a a a a a" 4)
+ (compat--should "a\na\na\na\na" "a a a a a" 2)
+ (compat--should "a\na\na\na\na" "a a a a a" 1)))
(ert-deftest compat-string-lines ()
"Check if `string-lines' was implemented correctly."
(compat-test string-lines
- (compat--should '("a" "b" "c") "a\nb\nc")
- (compat--should '("a" "b" "c" "") "a\nb\nc\n")
- (compat--should '("a" "b" "c") "a\nb\nc\n" t)
- (compat--should '("abc" "bcd" "cde") "abc\nbcd\ncde")
- (compat--should '(" abc" " bcd " "cde ") " abc\n bcd \ncde ")))
+ (compat--should '("a" "b" "c") "a\nb\nc")
+ (compat--should '("a" "b" "c" "") "a\nb\nc\n")
+ (compat--should '("a" "b" "c") "a\nb\nc\n" t)
+ (compat--should '("abc" "bcd" "cde") "abc\nbcd\ncde")
+ (compat--should '(" abc" " bcd " "cde ") " abc\n bcd \ncde ")))
(ert-deftest compat-string-pad ()
"Check if `string-pad' was implemented correctly."
(compat-test string-pad
- (compat--should "a " "a" 4)
- (compat--should "aaaa" "aaaa" 4)
- (compat--should "aaaaaa" "aaaaaa" 4)
- (compat--should "a..." "a" 4 ?.)
- (compat--should " a" "a" 4 nil t)
- (compat--should "...a" "a" 4 ?. t)))
+ (compat--should "a " "a" 4)
+ (compat--should "aaaa" "aaaa" 4)
+ (compat--should "aaaaaa" "aaaaaa" 4)
+ (compat--should "a..." "a" 4 ?.)
+ (compat--should " a" "a" 4 nil t)
+ (compat--should "...a" "a" 4 ?. t)))
(ert-deftest compat-string-chop-newline ()
"Check if `string-chop-newline' was implemented correctly."
(compat-test string-chop-newline
- (compat--should "" "")
- (compat--should "" "\n")
- (compat--should "aaa" "aaa")
- (compat--should "aaa" "aaa\n")
- (compat--should "aaa\n" "aaa\n\n")))
+ (compat--should "" "")
+ (compat--should "" "\n")
+ (compat--should "aaa" "aaa")
+ (compat--should "aaa" "aaa\n")
+ (compat--should "aaa\n" "aaa\n\n")))
(ert-deftest compat-macroexpand-1 ()
"Check if `macroexpand-1' was implemented correctly."
(compat-test macroexpand-1
- (compat--should '(if a b c) '(if a b c))
- (compat--should '(if a (progn b)) '(when a b))
- (compat--should '(if a (progn (unless b c))) '(when a (unless b c)))))
+ (compat--should '(if a b c) '(if a b c))
+ (compat--should '(if a (progn b)) '(when a b))
+ (compat--should '(if a (progn (unless b c))) '(when a (unless b
c)))))
(ert-deftest compat-file-size-human-readable ()
"Check if `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--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 `file-size-human-readable' was implemented properly."
(compat-test format-prompt
- (compat--should "Prompt: " "Prompt" nil)
- (compat--should "Prompt (default 3): " "Prompt" 3)
- (compat--should "Prompt (default abc): " "Prompt" "abc")
- (compat--should "Prompt (default abc def): " "Prompt" "abc def")
- (compat--should "Prompt 10: " "Prompt %d" nil 10)
- (compat--should "Prompt \"abc\" (default 3): " "Prompt %S" 3 "abc")))
+ (compat--should "Prompt: " "Prompt" nil)
+ (compat--should "Prompt (default 3): " "Prompt" 3)
+ (compat--should "Prompt (default abc): " "Prompt" "abc")
+ (compat--should "Prompt (default abc def): " "Prompt" "abc def")
+ (compat--should "Prompt 10: " "Prompt %d" nil 10)
+ (compat--should "Prompt \"abc\" (default 3): " "Prompt %S" 3
"abc")))
(provide 'compat-tests)
;;; compat-tests.el ends here
- [elpa] branch externals/compat created (now 5506770), ELPA Syncer, 2021/10/17
- [elpa] externals/compat 51b832c 02/99: Remove compat--disable-defer check from installation check, ELPA Syncer, 2021/10/17
- [elpa] externals/compat 10033e0 01/99: Initial import, ELPA Syncer, 2021/10/17
- [elpa] externals/compat e00fc9c 03/99: Simplify mapcan implementation, ELPA Syncer, 2021/10/17
- [elpa] externals/compat 9688d79 05/99: Split proper-list-p into two implementations, ELPA Syncer, 2021/10/17
- [elpa] externals/compat c445418 04/99: Fix named-let implementation, ELPA Syncer, 2021/10/17
- [elpa] externals/compat b8e8cba 07/99: Use markdown instead of outline-mode for the README file, ELPA Syncer, 2021/10/17
- [elpa] externals/compat a403485 10/99: Require compat-macs in eval-when-compile instead of eval-and-compile, ELPA Syncer, 2021/10/17
- [elpa] externals/compat 0d77194 14/99: Remove compat--disable-defer variable, ELPA Syncer, 2021/10/17
- [elpa] externals/compat eafe584 15/99: Remove unnecessary eval-and-compile block from compat-tests,
ELPA Syncer <=
- [elpa] externals/compat c7d1615 06/99: Remove elisp-shorthands from compat-tests.el, ELPA Syncer, 2021/10/17
- [elpa] externals/compat 5936773 08/99: Fix installation check, ELPA Syncer, 2021/10/17
- [elpa] externals/compat d77b31f 11/99: Reorder files to byte compile in Makefile, ELPA Syncer, 2021/10/17
- [elpa] externals/compat 12e36f7 12/99: Check if actual name is fbound before binding a function or macro, ELPA Syncer, 2021/10/17
- [elpa] externals/compat 5846fbe 13/99: Pull compatibility definition out of eval-after-load block, ELPA Syncer, 2021/10/17
- [elpa] externals/compat b3d1100 17/99: Prepend font-lock-preprocessor-face to compatibility symbols, ELPA Syncer, 2021/10/17
- [elpa] externals/compat c626917 18/99: Add a named-let test, ELPA Syncer, 2021/10/17
- [elpa] externals/compat 4c6c31b 29/99: Replace :force with more general :cond, ELPA Syncer, 2021/10/17
- [elpa] externals/compat a983e8c 30/99: Install advice using advice instead of nadvice for Emacs 24.3, ELPA Syncer, 2021/10/17
- [elpa] externals/compat 08c77ed 33/99: Declare variable for gensym, ELPA Syncer, 2021/10/17