diff options
Diffstat (limited to 'test/lisp/emacs-lisp')
-rw-r--r-- | test/lisp/emacs-lisp/cl-macs-tests.el | 4 | ||||
-rw-r--r-- | test/lisp/emacs-lisp/derived-tests.el | 4 | ||||
-rw-r--r-- | test/lisp/emacs-lisp/eieio-tests/eieio-tests.el | 40 | ||||
-rw-r--r-- | test/lisp/emacs-lisp/generator-tests.el | 3 | ||||
-rw-r--r-- | test/lisp/emacs-lisp/lisp-tests.el | 1 | ||||
-rw-r--r-- | test/lisp/emacs-lisp/seq-tests.el | 20 | ||||
-rw-r--r-- | test/lisp/emacs-lisp/subr-x-tests.el | 26 | ||||
-rw-r--r-- | test/lisp/emacs-lisp/timer-tests.el | 3 |
8 files changed, 57 insertions, 44 deletions
diff --git a/test/lisp/emacs-lisp/cl-macs-tests.el b/test/lisp/emacs-lisp/cl-macs-tests.el index be2c0fa02b4..7c3afefaadd 100644 --- a/test/lisp/emacs-lisp/cl-macs-tests.el +++ b/test/lisp/emacs-lisp/cl-macs-tests.el @@ -668,6 +668,10 @@ collection clause." #'len)) (`(function (lambda (,_ ,_) . ,_)) t)))) +(with-suppressed-warnings ((lexical test) (lexical test1) (lexical test2)) + (defvar test) + (defvar test1) + (defvar test2)) (ert-deftest cl-macs--progv () (should (= (cl-progv '(test test) '(1 2) test) 2)) (should (equal (cl-progv '(test1 test2) '(1 2) (list test1 test2)) diff --git a/test/lisp/emacs-lisp/derived-tests.el b/test/lisp/emacs-lisp/derived-tests.el index 9c8e6c33b4c..2647b86826a 100644 --- a/test/lisp/emacs-lisp/derived-tests.el +++ b/test/lisp/emacs-lisp/derived-tests.el @@ -24,13 +24,13 @@ (define-derived-mode derived-tests--parent-mode prog-mode "P" :after-hook (let ((f (let ((x "S")) (lambda () x)))) - (insert (format "AFP=%s " (let ((x "D")) (funcall f))))) + (insert (format "AFP=%s " (let ((x "D")) x (funcall f))))) (insert "PB ")) (define-derived-mode derived-tests--child-mode derived-tests--parent-mode "C" :after-hook (let ((f (let ((x "S")) (lambda () x)))) - (insert (format "AFC=%s " (let ((x "D")) (funcall f))))) + (insert (format "AFC=%s " (let ((x "D")) x (funcall f))))) (insert "CB ")) (ert-deftest derived-tests-after-hook-lexical () diff --git a/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el b/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el index ba2e5f7be4a..dfdfb63b584 100644 --- a/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el +++ b/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el @@ -172,7 +172,7 @@ ;; Check that generic-p works (should (generic-p 'generic1)) - (defmethod generic1 ((c class-a)) + (defmethod generic1 ((_c class-a)) "Method on generic1." 'monkey) @@ -240,12 +240,12 @@ Argument C is the class bound to this static method." (should (make-instance 'class-a :water 'cho)) (should (make-instance 'class-b))) -(defmethod class-cn ((a class-a)) +(defmethod class-cn ((_a class-a)) "Try calling `call-next-method' when there isn't one. Argument A is object of type symbol `class-a'." (call-next-method)) -(defmethod no-next-method ((a class-a) &rest args) +(defmethod no-next-method ((_a class-a) &rest _args) "Override signal throwing for variable `class-a'. Argument A is the object of class variable `class-a'." 'moose) @@ -254,7 +254,7 @@ Argument A is the object of class variable `class-a'." ;; Play with call-next-method (should (eq (class-cn eitest-ab) 'moose))) -(defmethod no-applicable-method ((b class-b) method &rest args) +(defmethod no-applicable-method ((_b class-b) _method &rest _args) "No need. Argument B is for booger. METHOD is the method that was attempting to be called." @@ -264,38 +264,38 @@ METHOD is the method that was attempting to be called." ;; Non-existing methods. (should (eq (class-cn eitest-b) 'moose))) -(defmethod class-fun ((a class-a)) +(defmethod class-fun ((_a class-a)) "Fun with class A." 'moose) -(defmethod class-fun ((b class-b)) +(defmethod class-fun ((_b class-b)) "Fun with class B." (error "Class B fun should not be called") ) -(defmethod class-fun-foo ((b class-b)) +(defmethod class-fun-foo ((_b class-b)) "Foo Fun with class B." 'moose) -(defmethod class-fun2 ((a class-a)) +(defmethod class-fun2 ((_a class-a)) "More fun with class A." 'moose) -(defmethod class-fun2 ((b class-b)) +(defmethod class-fun2 ((_b class-b)) "More fun with class B." (error "Class B fun2 should not be called") ) -(defmethod class-fun2 ((ab class-ab)) +(defmethod class-fun2 ((_ab class-ab)) "More fun with class AB." (call-next-method)) ;; How about if B is the only slot? -(defmethod class-fun3 ((b class-b)) +(defmethod class-fun3 ((_b class-b)) "Even More fun with class B." 'moose) -(defmethod class-fun3 ((ab class-ab)) +(defmethod class-fun3 ((_ab class-ab)) "Even More fun with class AB." (call-next-method)) @@ -314,17 +314,17 @@ METHOD is the method that was attempting to be called." (defvar class-fun-value-seq '()) -(defmethod class-fun-value :BEFORE ((a class-a)) +(defmethod class-fun-value :BEFORE ((_a class-a)) "Return `before', and push `before' in `class-fun-value-seq'." (push 'before class-fun-value-seq) 'before) -(defmethod class-fun-value :PRIMARY ((a class-a)) +(defmethod class-fun-value :PRIMARY ((_a class-a)) "Return `primary', and push `primary' in `class-fun-value-seq'." (push 'primary class-fun-value-seq) 'primary) -(defmethod class-fun-value :AFTER ((a class-a)) +(defmethod class-fun-value :AFTER ((_a class-a)) "Return `after', and push `after' in `class-fun-value-seq'." (push 'after class-fun-value-seq) 'after) @@ -343,14 +343,14 @@ METHOD is the method that was attempting to be called." ;; (ert-deftest eieio-test-13-init-methods () - (defmethod initialize-instance ((a class-a) &rest slots) + (defmethod initialize-instance ((a class-a) &rest _slots) "Initialize the slots of class-a." (call-next-method) (if (/= (oref a test-tag) 1) (error "shared-initialize test failed.")) (oset a test-tag 2)) - (defmethod shared-initialize ((a class-a) &rest slots) + (defmethod shared-initialize ((a class-a) &rest _slots) "Shared initialize method for class-a." (call-next-method) (oset a test-tag 1)) @@ -369,7 +369,7 @@ METHOD is the method that was attempting to be called." (ert-deftest eieio-test-15-slot-missing () - (defmethod slot-missing ((ab class-ab) &rest foo) + (defmethod slot-missing ((_ab class-ab) &rest _foo) "If a slot in AB is unbound, return something cool. FOO." 'moose) @@ -425,7 +425,7 @@ METHOD is the method that was attempting to be called." (ert-deftest eieio-test-18-slot-unbound () - (defmethod slot-unbound ((a class-a) &rest foo) + (defmethod slot-unbound ((_a class-a) &rest _foo) "If a slot in A is unbound, ignore FOO." 'moose) @@ -448,7 +448,7 @@ METHOD is the method that was attempting to be called." (should (eq (oref (class-a) water) 'penguin)) ;; Revert the above - (defmethod slot-unbound ((a class-a) &rest foo) + (defmethod slot-unbound ((_a class-a) &rest _foo) "If a slot in A is unbound, ignore FOO." ;; Disable the old slot-unbound so we can run this test ;; more than once diff --git a/test/lisp/emacs-lisp/generator-tests.el b/test/lisp/emacs-lisp/generator-tests.el index 50b8cc53a28..492c4e40853 100644 --- a/test/lisp/emacs-lisp/generator-tests.el +++ b/test/lisp/emacs-lisp/generator-tests.el @@ -74,7 +74,7 @@ identical output." (cps-testcase cps-prog1-b (prog1 1)) (cps-testcase cps-prog1-c (prog2 1 2 3)) (cps-testcase cps-quote (progn 'hello)) -(cps-testcase cps-function (progn #'hello)) +(cps-testcase cps-function (progn #'message)) (cps-testcase cps-and-fail (and 1 nil 2)) (cps-testcase cps-and-succeed (and 1 2 3)) @@ -307,6 +307,7 @@ identical output." (1+ it))))))) -2))) +(defun generator-tests-edebug ()) ; silence byte-compiler (ert-deftest generator-tests-edebug () "Check that Bug#40434 is fixed." (with-temp-buffer diff --git a/test/lisp/emacs-lisp/lisp-tests.el b/test/lisp/emacs-lisp/lisp-tests.el index 8301d9906a2..7f4d50c5958 100644 --- a/test/lisp/emacs-lisp/lisp-tests.el +++ b/test/lisp/emacs-lisp/lisp-tests.el @@ -213,6 +213,7 @@ (should-error (forward-sexp)))) ;; FIXME: Shouldn't be an error. ;; Test some core Elisp rules. +(defvar c-e-x) (ert-deftest core-elisp-tests-1-defvar-in-let () "Test some core Elisp rules." (with-temp-buffer diff --git a/test/lisp/emacs-lisp/seq-tests.el b/test/lisp/emacs-lisp/seq-tests.el index 8dc0b93b5af..8cfa3bdb862 100644 --- a/test/lisp/emacs-lisp/seq-tests.el +++ b/test/lisp/emacs-lisp/seq-tests.el @@ -172,17 +172,23 @@ Evaluate BODY for each created sequence. (should-not (seq-find #'null '(1 2 3))) (should (seq-find #'null '(1 2 3) 'sentinel))) +;; Hack to work around the ERT limitation that we can't reliably use +;; `with-suppressed-warnings' inside an `ert-deftest'. (Bug#36568) +(defun seq--contains (&rest args) + (with-suppressed-warnings ((obsolete seq-contains)) + (apply #'seq-contains args))) + (ert-deftest test-seq-contains () (with-test-sequences (seq '(3 4 5 6)) - (should (seq-contains seq 3)) - (should-not (seq-contains seq 7))) + (should (seq--contains seq 3)) + (should-not (seq--contains seq 7))) (with-test-sequences (seq '()) - (should-not (seq-contains seq 3)) - (should-not (seq-contains seq nil)))) + (should-not (seq--contains seq 3)) + (should-not (seq--contains seq nil)))) (ert-deftest test-seq-contains-should-return-the-elt () (with-test-sequences (seq '(3 4 5 6)) - (should (= 5 (seq-contains seq 5))))) + (should (= 5 (seq--contains seq 5))))) (ert-deftest test-seq-contains-p () (with-test-sequences (seq '(3 4 5 6)) @@ -404,7 +410,7 @@ Evaluate BODY for each created sequence. (let ((seq '(1 (2 (3 (4)))))) (seq-let (_ (_ (_ (a)))) seq (should (= a 4)))) - (let (seq) + (let ((seq nil)) (seq-let (a b c) seq (should (null a)) (should (null b)) @@ -428,7 +434,7 @@ Evaluate BODY for each created sequence. (seq '(1 (2 (3 (4)))))) (seq-setq (_ (_ (_ (a)))) seq) (should (= a 4))) - (let (seq a b c) + (let ((seq nil) a b c) (seq-setq (a b c) seq) (should (null a)) (should (null b)) diff --git a/test/lisp/emacs-lisp/subr-x-tests.el b/test/lisp/emacs-lisp/subr-x-tests.el index 69d59e84f6d..d8369506000 100644 --- a/test/lisp/emacs-lisp/subr-x-tests.el +++ b/test/lisp/emacs-lisp/subr-x-tests.el @@ -169,13 +169,13 @@ "no") "no")) (should (equal - (let (z) + (let ((z nil)) (if-let* (z (a 1) (b 2) (c 3)) "yes" "no")) "no")) (should (equal - (let (d) + (let ((d nil)) (if-let* ((a 1) (b 2) (c 3) d) "yes" "no")) @@ -191,7 +191,7 @@ (ert-deftest subr-x-test-if-let*-and-laziness-is-preserved () "Test `if-let' respects `and' laziness." - (let (a-called b-called c-called) + (let ((a-called nil) (b-called nil) c-called) (should (equal (if-let* ((a nil) (b (setq b-called t)) @@ -199,7 +199,7 @@ "yes" (list a-called b-called c-called)) (list nil nil nil)))) - (let (a-called b-called c-called) + (let ((a-called nil) (b-called nil) c-called) (should (equal (if-let* ((a (setq a-called t)) (b nil) @@ -207,12 +207,12 @@ "yes" (list a-called b-called c-called)) (list t nil nil)))) - (let (a-called b-called c-called) + (let ((a-called nil) (b-called nil) c-called) (should (equal (if-let* ((a (setq a-called t)) - (b (setq b-called t)) - (c nil) - (d (setq c-called t))) + (b (setq b-called t)) + (c nil) + (d (setq c-called t))) "yes" (list a-called b-called c-called)) (list t t nil))))) @@ -329,12 +329,12 @@ "no") nil)) (should (equal - (let (z) + (let ((z nil)) (when-let* (z (a 1) (b 2) (c 3)) "no")) nil)) (should (equal - (let (d) + (let ((d nil)) (when-let* ((a 1) (b 2) (c 3) d) "no")) nil))) @@ -348,7 +348,7 @@ (ert-deftest subr-x-test-when-let*-and-laziness-is-preserved () "Test `when-let' respects `and' laziness." - (let (a-called b-called c-called) + (let ((a-called nil) (b-called nil) (c-called nil)) (should (equal (progn (when-let* ((a nil) @@ -357,7 +357,7 @@ "yes") (list a-called b-called c-called)) (list nil nil nil)))) - (let (a-called b-called c-called) + (let ((a-called nil) (b-called nil) (c-called nil)) (should (equal (progn (when-let* ((a (setq a-called t)) @@ -366,7 +366,7 @@ "yes") (list a-called b-called c-called)) (list t nil nil)))) - (let (a-called b-called c-called) + (let ((a-called nil) (b-called nil) (c-called nil)) (should (equal (progn (when-let* ((a (setq a-called t)) diff --git a/test/lisp/emacs-lisp/timer-tests.el b/test/lisp/emacs-lisp/timer-tests.el index 7856c217f9e..0f5b1a71868 100644 --- a/test/lisp/emacs-lisp/timer-tests.el +++ b/test/lisp/emacs-lisp/timer-tests.el @@ -37,7 +37,8 @@ (ert-deftest timer-tests-debug-timer-check () ;; This function exists only if --enable-checking. (skip-unless (fboundp 'debug-timer-check)) - (should (debug-timer-check))) + (when (fboundp 'debug-timer-check) ; silence byte-compiler + (should (debug-timer-check)))) (ert-deftest timer-test-multiple-of-time () (should (time-equal-p |