summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/makefile.yml2
-rw-r--r--compat-tests.el72
2 files changed, 71 insertions, 3 deletions
diff --git a/.github/workflows/makefile.yml b/.github/workflows/makefile.yml
index 5c80dc7..b506632 100644
--- a/.github/workflows/makefile.yml
+++ b/.github/workflows/makefile.yml
@@ -19,7 +19,7 @@ jobs:
strategy:
matrix:
# See https://github.com/purcell/setup-emacs/blob/master/.github/workflows/test.yml
- emacs-version: [25.1, 25.2, 25.3, 26.1, 26.2, 26.3, 27.1, 27.2, 28.1, 28.2, 29.1, 29.2, 29.3, 29.4, 30.1] # release-snapshot, snapshot
+ emacs-version: [25.1, 25.2, 25.3, 26.1, 26.2, 26.3, 27.1, 27.2, 28.1, 28.2, 29.1, 29.2, 29.3, 29.4, 30.1, snapshot] # release-snapshot
steps:
- uses: actions/checkout@v4
- uses: purcell/setup-emacs@master
diff --git a/compat-tests.el b/compat-tests.el
index e92c9eb..0b0ac69 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -367,8 +367,10 @@
(fset #'read-char orig-rc)
(fset #'read-from-minibuffer orig-rm))))
+(defvar read-char-choice-use-read-key)
(ert-deftest compat-read-multiple-choice ()
- (let ((orig-re (symbol-function #'read-event))
+ (let ((read-char-choice-use-read-key t)
+ (orig-re (symbol-function #'read-event))
(orig-rc (symbol-function #'read-char))
(orig-rk (symbol-function #'read-key))
(orig-cr completing-read-function))
@@ -379,9 +381,9 @@
(?c "third"))
("Do it?" (?y "yes") (?n "no"))))
(dolist (choice (cdr test))
+ (fset #'read-key (lambda (&rest _) (car choice)))
(fset #'read-char (lambda (&rest _) (car choice)))
(fset #'read-event (lambda (&rest _) (car choice)))
- (fset #'read-key (lambda (&rest _) (car choice)))
(setq completing-read-function (lambda (&rest _) (cadr choice)))
(should-equal choice (compat-call read-multiple-choice
(car test) (cdr test) nil nil 'long))
@@ -2278,6 +2280,72 @@
(should-equal "else"
(if-let* (((= 5 6))) "then" "else")))
+(ert-deftest compat-when-let ()
+ (static-if (< emacs-major-version 31) ;; deprecated on Emacs 31
+ (progn
+ ;; FIXME Broken on Emacs 25
+ (static-if (= emacs-major-version 25)
+ (should-equal "second"
+ (when-let
+ ((x 3)
+ (y 2)
+ (z (+ x y))
+ ;; ((= z 5)) ;; FIXME Broken on Emacs 25
+ (true t))
+ "first" "second"))
+ (should-equal "second"
+ (when-let
+ ((x 3)
+ (y 2)
+ (z (+ x y))
+ ((= z 5))
+ (true t))
+ "first" "second"))
+ (should-equal "then" (when-let (((= 5 5))) "then"))
+ (should-not (when-let (((= 5 6))) t)))
+ (should-equal "last"
+ (when-let (e (memq 0 '(1 2 3 0 5 6)))
+ "first" "last"))
+ (should-equal "last" (when-let ((e (memq 0 '(1 2 3 0 5 6))))
+ "first" "last"))
+ (should-not (when-let ((e (memq 0 '(1 2 3 5 6)))
+ (d (memq 0 '(1 2 3 0 5 6))))
+ "first" "last")))))
+
+(ert-deftest compat-if-let ()
+ (static-if (< emacs-major-version 31) ;; deprecated on Emacs 31
+ (progn
+ ;; FIXME Broken on Emacs 25
+ (static-if (= emacs-major-version 25)
+ (should-equal "then"
+ (if-let
+ ((x 3)
+ (y 2)
+ (z (+ x y))
+ ;; ((= z 5)) ;; FIXME Broken on Emacs 25
+ (true t))
+ "then" "else"))
+ (should-equal "then"
+ (if-let
+ ((x 3)
+ (y 2)
+ (z (+ x y))
+ ((= z 5))
+ (true t))
+ "then" "else"))
+ (should-equal "else" (if-let (((= 5 6))) "then" "else"))
+ (should-not (if-let (((= 5 6))) t nil)))
+ (should (if-let (e (memq 0 '(1 2 3 0 5 6)))
+ e))
+ (should (if-let ((e (memq 0 '(1 2 3 0 5 6))))
+ e))
+ (should-not (if-let ((e (memq 0 '(1 2 3 5 6)))
+ (d (memq 0 '(1 2 3 0 5 6))))
+ t))
+ (should-not (if-let ((d (memq 0 '(1 2 3 0 5 6)))
+ (e (memq 0 '(1 2 3 5 6))))
+ t)))))
+
(ert-deftest compat-and-let* ()
(should ;trivial body
(and-let*