mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
Silence byte-compiler in some tests
* test/lisp/dired-tests.el: * test/lisp/emacs-lisp/cl-macs-tests.el: * test/lisp/emacs-lisp/derived-tests.el: * test/lisp/emacs-lisp/eieio-tests/eieio-tests.el: * test/lisp/emacs-lisp/generator-tests.el: * test/lisp/emacs-lisp/lisp-tests.el: * test/lisp/emacs-lisp/seq-tests.el (test-seq-let) (test-seq-setq): * test/lisp/emacs-lisp/subr-x-tests.el (subr-x-test-if-let*-false) (subr-x-test-if-let*-and-laziness-is-preserved) (subr-x-test-when-let*-false) (subr-x-test-when-let*-and-laziness-is-preserved): * test/lisp/emacs-lisp/timer-tests.el (timer-tests-debug-timer-check): * test/lisp/format-spec-tests.el (format-spec-do-flags-truncate) (format-spec-do-flags-pad): * test/lisp/ls-lisp-tests.el (ls-lisp-test-bug27762): * test/lisp/obsolete/cl-tests.el (labels-function-quoting): * test/lisp/progmodes/elisp-mode-tests.el: * test/lisp/replace-tests.el (replace-regexp-bug45973): * test/lisp/ses-tests.el: * test/lisp/subr-tests.el: * test/lisp/tar-mode-tests.el (tar-mode-test-tar-grind-file-mode): * test/src/data-tests.el (data-tests--set-default-per-buffer): * test/src/search-tests.el (test-replace-match-modification-hooks): Silence byte-compiler.
This commit is contained in:
parent
aa6681a51a
commit
7c68c84674
19 changed files with 152 additions and 101 deletions
|
|
@ -543,10 +543,12 @@ path's data to use."
|
||||||
((equal "." path) default-directory)
|
((equal "." path) default-directory)
|
||||||
(path)))
|
(path)))
|
||||||
(return-size
|
(return-size
|
||||||
(car (files-tests--look-up-free-data path))))
|
;; It is always defined but this silences the byte-compiler:
|
||||||
|
(when (fboundp 'files-tests--look-up-free-data)
|
||||||
|
(car (files-tests--look-up-free-data path)))))
|
||||||
(list return-size return-size return-size))))
|
(list return-size return-size return-size))))
|
||||||
|
|
||||||
(defun files-tests--insert-directory-output (dir &optional verbose)
|
(defun files-tests--insert-directory-output (dir &optional _verbose)
|
||||||
"Run `insert-directory' and return its output."
|
"Run `insert-directory' and return its output."
|
||||||
(with-current-buffer-window "files-tests--insert-directory" nil nil
|
(with-current-buffer-window "files-tests--insert-directory" nil nil
|
||||||
(let ((dired-free-space 'separate))
|
(let ((dired-free-space 'separate))
|
||||||
|
|
@ -555,35 +557,46 @@ path's data to use."
|
||||||
|
|
||||||
(ert-deftest files-tests-insert-directory-shows-files ()
|
(ert-deftest files-tests-insert-directory-shows-files ()
|
||||||
"Verify `insert-directory' reports the files in the directory."
|
"Verify `insert-directory' reports the files in the directory."
|
||||||
(let* ((test-dir (car test-files))
|
;; It is always defined but this silences the byte-compiler:
|
||||||
(files (cdr test-files))
|
(when (fboundp 'files-tests--insert-directory-output)
|
||||||
(output (files-tests--insert-directory-output test-dir)))
|
(let* ((test-dir (car test-files))
|
||||||
(dolist (file files)
|
(files (cdr test-files))
|
||||||
(should (string-match-p file output)))))
|
(output (files-tests--insert-directory-output test-dir)))
|
||||||
|
(dolist (file files)
|
||||||
|
(should (string-match-p file output))))))
|
||||||
|
|
||||||
(defun files-tests--insert-directory-shows-given-free (dir &optional
|
(defun files-tests--insert-directory-shows-given-free (dir &optional
|
||||||
info-func)
|
info-func)
|
||||||
"Run `insert-directory' and verify it reports the correct available space.
|
"Run `insert-directory' and verify it reports the correct available space.
|
||||||
Stub `file-system-info' to ensure the available space is consistent,
|
Stub `file-system-info' to ensure the available space is consistent,
|
||||||
either with the given stub function or a default one using test data."
|
either with the given stub function or a default one using test data."
|
||||||
(cl-letf (((symbol-function 'file-system-info)
|
;; It is always defined but this silences the byte-compiler:
|
||||||
(or info-func
|
(when (and (fboundp 'files-tests--make-file-system-info-stub)
|
||||||
(files-tests--make-file-system-info-stub))))
|
(fboundp 'files-tests--look-up-free-data)
|
||||||
(should (string-match-p (cadr
|
(fboundp 'files-tests--insert-directory-output))
|
||||||
(files-tests--look-up-free-data dir))
|
(cl-letf (((symbol-function 'file-system-info)
|
||||||
(files-tests--insert-directory-output dir t)))))
|
(or info-func
|
||||||
|
(files-tests--make-file-system-info-stub))))
|
||||||
|
(should (string-match-p (cadr
|
||||||
|
(files-tests--look-up-free-data dir))
|
||||||
|
(files-tests--insert-directory-output dir t))))))
|
||||||
|
|
||||||
(ert-deftest files-tests-insert-directory-shows-free ()
|
(ert-deftest files-tests-insert-directory-shows-free ()
|
||||||
"Test that verbose `insert-directory' shows the correct available space."
|
"Test that verbose `insert-directory' shows the correct available space."
|
||||||
(files-tests--insert-directory-shows-given-free
|
;; It is always defined but this silences the byte-compiler:
|
||||||
test-dir
|
(when (and (fboundp 'files-tests--insert-directory-shows-given-free)
|
||||||
(files-tests--make-file-system-info-stub test-dir)))
|
(fboundp 'files-tests--make-file-system-info-stub))
|
||||||
|
(files-tests--insert-directory-shows-given-free
|
||||||
|
test-dir
|
||||||
|
(files-tests--make-file-system-info-stub test-dir))))
|
||||||
|
|
||||||
(ert-deftest files-tests-bug-50630 ()
|
(ert-deftest files-tests-bug-50630 ()
|
||||||
"Verify verbose `insert-directory' shows free space of the target directory.
|
"Verify verbose `insert-directory' shows free space of the target directory.
|
||||||
The current directory at call time should not affect the result (Bug#50630)."
|
The current directory at call time should not affect the result (Bug#50630)."
|
||||||
(let ((default-directory test-dir-other))
|
;; It is always defined but this silences the byte-compiler:
|
||||||
(files-tests--insert-directory-shows-given-free test-dir))))
|
(when (fboundp 'files-tests--insert-directory-shows-given-free)
|
||||||
|
(let ((default-directory test-dir-other))
|
||||||
|
(files-tests--insert-directory-shows-given-free test-dir)))))
|
||||||
|
|
||||||
(provide 'dired-tests)
|
(provide 'dired-tests)
|
||||||
;;; dired-tests.el ends here
|
;;; dired-tests.el ends here
|
||||||
|
|
|
||||||
|
|
@ -668,6 +668,10 @@ collection clause."
|
||||||
#'len))
|
#'len))
|
||||||
(`(function (lambda (,_ ,_) . ,_)) t))))
|
(`(function (lambda (,_ ,_) . ,_)) t))))
|
||||||
|
|
||||||
|
(with-suppressed-warnings ((lexical test) (lexical test1) (lexical test2))
|
||||||
|
(defvar test)
|
||||||
|
(defvar test1)
|
||||||
|
(defvar test2))
|
||||||
(ert-deftest cl-macs--progv ()
|
(ert-deftest cl-macs--progv ()
|
||||||
(should (= (cl-progv '(test test) '(1 2) test) 2))
|
(should (= (cl-progv '(test test) '(1 2) test) 2))
|
||||||
(should (equal (cl-progv '(test1 test2) '(1 2) (list test1 test2))
|
(should (equal (cl-progv '(test1 test2) '(1 2) (list test1 test2))
|
||||||
|
|
|
||||||
|
|
@ -24,13 +24,13 @@
|
||||||
(define-derived-mode derived-tests--parent-mode prog-mode "P"
|
(define-derived-mode derived-tests--parent-mode prog-mode "P"
|
||||||
:after-hook
|
:after-hook
|
||||||
(let ((f (let ((x "S")) (lambda () x))))
|
(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 "))
|
(insert "PB "))
|
||||||
|
|
||||||
(define-derived-mode derived-tests--child-mode derived-tests--parent-mode "C"
|
(define-derived-mode derived-tests--child-mode derived-tests--parent-mode "C"
|
||||||
:after-hook
|
:after-hook
|
||||||
(let ((f (let ((x "S")) (lambda () x))))
|
(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 "))
|
(insert "CB "))
|
||||||
|
|
||||||
(ert-deftest derived-tests-after-hook-lexical ()
|
(ert-deftest derived-tests-after-hook-lexical ()
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,7 @@
|
||||||
;; Check that generic-p works
|
;; Check that generic-p works
|
||||||
(should (generic-p 'generic1))
|
(should (generic-p 'generic1))
|
||||||
|
|
||||||
(defmethod generic1 ((c class-a))
|
(defmethod generic1 ((_c class-a))
|
||||||
"Method on generic1."
|
"Method on generic1."
|
||||||
'monkey)
|
'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-a :water 'cho))
|
||||||
(should (make-instance 'class-b)))
|
(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.
|
"Try calling `call-next-method' when there isn't one.
|
||||||
Argument A is object of type symbol `class-a'."
|
Argument A is object of type symbol `class-a'."
|
||||||
(call-next-method))
|
(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'.
|
"Override signal throwing for variable `class-a'.
|
||||||
Argument A is the object of class variable `class-a'."
|
Argument A is the object of class variable `class-a'."
|
||||||
'moose)
|
'moose)
|
||||||
|
|
@ -254,7 +254,7 @@ Argument A is the object of class variable `class-a'."
|
||||||
;; Play with call-next-method
|
;; Play with call-next-method
|
||||||
(should (eq (class-cn eitest-ab) 'moose)))
|
(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.
|
"No need.
|
||||||
Argument B is for booger.
|
Argument B is for booger.
|
||||||
METHOD is the method that was attempting to be called."
|
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.
|
;; Non-existing methods.
|
||||||
(should (eq (class-cn eitest-b) 'moose)))
|
(should (eq (class-cn eitest-b) 'moose)))
|
||||||
|
|
||||||
(defmethod class-fun ((a class-a))
|
(defmethod class-fun ((_a class-a))
|
||||||
"Fun with class A."
|
"Fun with class A."
|
||||||
'moose)
|
'moose)
|
||||||
|
|
||||||
(defmethod class-fun ((b class-b))
|
(defmethod class-fun ((_b class-b))
|
||||||
"Fun with class B."
|
"Fun with class B."
|
||||||
(error "Class B fun should not be called")
|
(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."
|
"Foo Fun with class B."
|
||||||
'moose)
|
'moose)
|
||||||
|
|
||||||
(defmethod class-fun2 ((a class-a))
|
(defmethod class-fun2 ((_a class-a))
|
||||||
"More fun with class A."
|
"More fun with class A."
|
||||||
'moose)
|
'moose)
|
||||||
|
|
||||||
(defmethod class-fun2 ((b class-b))
|
(defmethod class-fun2 ((_b class-b))
|
||||||
"More fun with class B."
|
"More fun with class B."
|
||||||
(error "Class B fun2 should not be called")
|
(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."
|
"More fun with class AB."
|
||||||
(call-next-method))
|
(call-next-method))
|
||||||
|
|
||||||
;; How about if B is the only slot?
|
;; 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."
|
"Even More fun with class B."
|
||||||
'moose)
|
'moose)
|
||||||
|
|
||||||
(defmethod class-fun3 ((ab class-ab))
|
(defmethod class-fun3 ((_ab class-ab))
|
||||||
"Even More fun with class AB."
|
"Even More fun with class AB."
|
||||||
(call-next-method))
|
(call-next-method))
|
||||||
|
|
||||||
|
|
@ -314,17 +314,17 @@ METHOD is the method that was attempting to be called."
|
||||||
|
|
||||||
|
|
||||||
(defvar class-fun-value-seq '())
|
(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'."
|
"Return `before', and push `before' in `class-fun-value-seq'."
|
||||||
(push 'before class-fun-value-seq)
|
(push 'before class-fun-value-seq)
|
||||||
'before)
|
'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'."
|
"Return `primary', and push `primary' in `class-fun-value-seq'."
|
||||||
(push 'primary class-fun-value-seq)
|
(push 'primary class-fun-value-seq)
|
||||||
'primary)
|
'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'."
|
"Return `after', and push `after' in `class-fun-value-seq'."
|
||||||
(push 'after class-fun-value-seq)
|
(push 'after class-fun-value-seq)
|
||||||
'after)
|
'after)
|
||||||
|
|
@ -343,14 +343,14 @@ METHOD is the method that was attempting to be called."
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(ert-deftest eieio-test-13-init-methods ()
|
(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."
|
"Initialize the slots of class-a."
|
||||||
(call-next-method)
|
(call-next-method)
|
||||||
(if (/= (oref a test-tag) 1)
|
(if (/= (oref a test-tag) 1)
|
||||||
(error "shared-initialize test failed."))
|
(error "shared-initialize test failed."))
|
||||||
(oset a test-tag 2))
|
(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."
|
"Shared initialize method for class-a."
|
||||||
(call-next-method)
|
(call-next-method)
|
||||||
(oset a test-tag 1))
|
(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 ()
|
(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."
|
"If a slot in AB is unbound, return something cool. FOO."
|
||||||
'moose)
|
'moose)
|
||||||
|
|
||||||
|
|
@ -425,7 +425,7 @@ METHOD is the method that was attempting to be called."
|
||||||
|
|
||||||
(ert-deftest eieio-test-18-slot-unbound ()
|
(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."
|
"If a slot in A is unbound, ignore FOO."
|
||||||
'moose)
|
'moose)
|
||||||
|
|
||||||
|
|
@ -448,7 +448,7 @@ METHOD is the method that was attempting to be called."
|
||||||
(should (eq (oref (class-a) water) 'penguin))
|
(should (eq (oref (class-a) water) 'penguin))
|
||||||
|
|
||||||
;; Revert the above
|
;; 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."
|
"If a slot in A is unbound, ignore FOO."
|
||||||
;; Disable the old slot-unbound so we can run this test
|
;; Disable the old slot-unbound so we can run this test
|
||||||
;; more than once
|
;; more than once
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ identical output."
|
||||||
(cps-testcase cps-prog1-b (prog1 1))
|
(cps-testcase cps-prog1-b (prog1 1))
|
||||||
(cps-testcase cps-prog1-c (prog2 1 2 3))
|
(cps-testcase cps-prog1-c (prog2 1 2 3))
|
||||||
(cps-testcase cps-quote (progn 'hello))
|
(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-fail (and 1 nil 2))
|
||||||
(cps-testcase cps-and-succeed (and 1 2 3))
|
(cps-testcase cps-and-succeed (and 1 2 3))
|
||||||
|
|
@ -307,6 +307,7 @@ identical output."
|
||||||
(1+ it)))))))
|
(1+ it)))))))
|
||||||
-2)))
|
-2)))
|
||||||
|
|
||||||
|
(defun generator-tests-edebug ()) ; silence byte-compiler
|
||||||
(ert-deftest generator-tests-edebug ()
|
(ert-deftest generator-tests-edebug ()
|
||||||
"Check that Bug#40434 is fixed."
|
"Check that Bug#40434 is fixed."
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
|
|
|
||||||
|
|
@ -213,6 +213,7 @@
|
||||||
(should-error (forward-sexp)))) ;; FIXME: Shouldn't be an error.
|
(should-error (forward-sexp)))) ;; FIXME: Shouldn't be an error.
|
||||||
|
|
||||||
;; Test some core Elisp rules.
|
;; Test some core Elisp rules.
|
||||||
|
(defvar c-e-x)
|
||||||
(ert-deftest core-elisp-tests-1-defvar-in-let ()
|
(ert-deftest core-elisp-tests-1-defvar-in-let ()
|
||||||
"Test some core Elisp rules."
|
"Test some core Elisp rules."
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
|
|
|
||||||
|
|
@ -172,17 +172,23 @@ Evaluate BODY for each created sequence.
|
||||||
(should-not (seq-find #'null '(1 2 3)))
|
(should-not (seq-find #'null '(1 2 3)))
|
||||||
(should (seq-find #'null '(1 2 3) 'sentinel)))
|
(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 ()
|
(ert-deftest test-seq-contains ()
|
||||||
(with-test-sequences (seq '(3 4 5 6))
|
(with-test-sequences (seq '(3 4 5 6))
|
||||||
(should (seq-contains seq 3))
|
(should (seq--contains seq 3))
|
||||||
(should-not (seq-contains seq 7)))
|
(should-not (seq--contains seq 7)))
|
||||||
(with-test-sequences (seq '())
|
(with-test-sequences (seq '())
|
||||||
(should-not (seq-contains seq 3))
|
(should-not (seq--contains seq 3))
|
||||||
(should-not (seq-contains seq nil))))
|
(should-not (seq--contains seq nil))))
|
||||||
|
|
||||||
(ert-deftest test-seq-contains-should-return-the-elt ()
|
(ert-deftest test-seq-contains-should-return-the-elt ()
|
||||||
(with-test-sequences (seq '(3 4 5 6))
|
(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 ()
|
(ert-deftest test-seq-contains-p ()
|
||||||
(with-test-sequences (seq '(3 4 5 6))
|
(with-test-sequences (seq '(3 4 5 6))
|
||||||
|
|
@ -404,7 +410,7 @@ Evaluate BODY for each created sequence.
|
||||||
(let ((seq '(1 (2 (3 (4))))))
|
(let ((seq '(1 (2 (3 (4))))))
|
||||||
(seq-let (_ (_ (_ (a)))) seq
|
(seq-let (_ (_ (_ (a)))) seq
|
||||||
(should (= a 4))))
|
(should (= a 4))))
|
||||||
(let (seq)
|
(let ((seq nil))
|
||||||
(seq-let (a b c) seq
|
(seq-let (a b c) seq
|
||||||
(should (null a))
|
(should (null a))
|
||||||
(should (null b))
|
(should (null b))
|
||||||
|
|
@ -428,7 +434,7 @@ Evaluate BODY for each created sequence.
|
||||||
(seq '(1 (2 (3 (4))))))
|
(seq '(1 (2 (3 (4))))))
|
||||||
(seq-setq (_ (_ (_ (a)))) seq)
|
(seq-setq (_ (_ (_ (a)))) seq)
|
||||||
(should (= a 4)))
|
(should (= a 4)))
|
||||||
(let (seq a b c)
|
(let ((seq nil) a b c)
|
||||||
(seq-setq (a b c) seq)
|
(seq-setq (a b c) seq)
|
||||||
(should (null a))
|
(should (null a))
|
||||||
(should (null b))
|
(should (null b))
|
||||||
|
|
|
||||||
|
|
@ -169,13 +169,13 @@
|
||||||
"no")
|
"no")
|
||||||
"no"))
|
"no"))
|
||||||
(should (equal
|
(should (equal
|
||||||
(let (z)
|
(let ((z nil))
|
||||||
(if-let* (z (a 1) (b 2) (c 3))
|
(if-let* (z (a 1) (b 2) (c 3))
|
||||||
"yes"
|
"yes"
|
||||||
"no"))
|
"no"))
|
||||||
"no"))
|
"no"))
|
||||||
(should (equal
|
(should (equal
|
||||||
(let (d)
|
(let ((d nil))
|
||||||
(if-let* ((a 1) (b 2) (c 3) d)
|
(if-let* ((a 1) (b 2) (c 3) d)
|
||||||
"yes"
|
"yes"
|
||||||
"no"))
|
"no"))
|
||||||
|
|
@ -191,7 +191,7 @@
|
||||||
|
|
||||||
(ert-deftest subr-x-test-if-let*-and-laziness-is-preserved ()
|
(ert-deftest subr-x-test-if-let*-and-laziness-is-preserved ()
|
||||||
"Test `if-let' respects `and' laziness."
|
"Test `if-let' respects `and' laziness."
|
||||||
(let (a-called b-called c-called)
|
(let ((a-called nil) (b-called nil) c-called)
|
||||||
(should (equal
|
(should (equal
|
||||||
(if-let* ((a nil)
|
(if-let* ((a nil)
|
||||||
(b (setq b-called t))
|
(b (setq b-called t))
|
||||||
|
|
@ -199,7 +199,7 @@
|
||||||
"yes"
|
"yes"
|
||||||
(list a-called b-called c-called))
|
(list a-called b-called c-called))
|
||||||
(list nil nil nil))))
|
(list nil nil nil))))
|
||||||
(let (a-called b-called c-called)
|
(let ((a-called nil) (b-called nil) c-called)
|
||||||
(should (equal
|
(should (equal
|
||||||
(if-let* ((a (setq a-called t))
|
(if-let* ((a (setq a-called t))
|
||||||
(b nil)
|
(b nil)
|
||||||
|
|
@ -207,12 +207,12 @@
|
||||||
"yes"
|
"yes"
|
||||||
(list a-called b-called c-called))
|
(list a-called b-called c-called))
|
||||||
(list t nil nil))))
|
(list t nil nil))))
|
||||||
(let (a-called b-called c-called)
|
(let ((a-called nil) (b-called nil) c-called)
|
||||||
(should (equal
|
(should (equal
|
||||||
(if-let* ((a (setq a-called t))
|
(if-let* ((a (setq a-called t))
|
||||||
(b (setq b-called t))
|
(b (setq b-called t))
|
||||||
(c nil)
|
(c nil)
|
||||||
(d (setq c-called t)))
|
(d (setq c-called t)))
|
||||||
"yes"
|
"yes"
|
||||||
(list a-called b-called c-called))
|
(list a-called b-called c-called))
|
||||||
(list t t nil)))))
|
(list t t nil)))))
|
||||||
|
|
@ -329,12 +329,12 @@
|
||||||
"no")
|
"no")
|
||||||
nil))
|
nil))
|
||||||
(should (equal
|
(should (equal
|
||||||
(let (z)
|
(let ((z nil))
|
||||||
(when-let* (z (a 1) (b 2) (c 3))
|
(when-let* (z (a 1) (b 2) (c 3))
|
||||||
"no"))
|
"no"))
|
||||||
nil))
|
nil))
|
||||||
(should (equal
|
(should (equal
|
||||||
(let (d)
|
(let ((d nil))
|
||||||
(when-let* ((a 1) (b 2) (c 3) d)
|
(when-let* ((a 1) (b 2) (c 3) d)
|
||||||
"no"))
|
"no"))
|
||||||
nil)))
|
nil)))
|
||||||
|
|
@ -348,7 +348,7 @@
|
||||||
|
|
||||||
(ert-deftest subr-x-test-when-let*-and-laziness-is-preserved ()
|
(ert-deftest subr-x-test-when-let*-and-laziness-is-preserved ()
|
||||||
"Test `when-let' respects `and' laziness."
|
"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
|
(should (equal
|
||||||
(progn
|
(progn
|
||||||
(when-let* ((a nil)
|
(when-let* ((a nil)
|
||||||
|
|
@ -357,7 +357,7 @@
|
||||||
"yes")
|
"yes")
|
||||||
(list a-called b-called c-called))
|
(list a-called b-called c-called))
|
||||||
(list nil nil nil))))
|
(list nil nil nil))))
|
||||||
(let (a-called b-called c-called)
|
(let ((a-called nil) (b-called nil) (c-called nil))
|
||||||
(should (equal
|
(should (equal
|
||||||
(progn
|
(progn
|
||||||
(when-let* ((a (setq a-called t))
|
(when-let* ((a (setq a-called t))
|
||||||
|
|
@ -366,7 +366,7 @@
|
||||||
"yes")
|
"yes")
|
||||||
(list a-called b-called c-called))
|
(list a-called b-called c-called))
|
||||||
(list t nil nil))))
|
(list t nil nil))))
|
||||||
(let (a-called b-called c-called)
|
(let ((a-called nil) (b-called nil) (c-called nil))
|
||||||
(should (equal
|
(should (equal
|
||||||
(progn
|
(progn
|
||||||
(when-let* ((a (setq a-called t))
|
(when-let* ((a (setq a-called t))
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,8 @@
|
||||||
(ert-deftest timer-tests-debug-timer-check ()
|
(ert-deftest timer-tests-debug-timer-check ()
|
||||||
;; This function exists only if --enable-checking.
|
;; This function exists only if --enable-checking.
|
||||||
(skip-unless (fboundp 'debug-timer-check))
|
(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 ()
|
(ert-deftest timer-test-multiple-of-time ()
|
||||||
(should (time-equal-p
|
(should (time-equal-p
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@
|
||||||
|
|
||||||
(ert-deftest format-spec-do-flags-truncate ()
|
(ert-deftest format-spec-do-flags-truncate ()
|
||||||
"Test `format-spec--do-flags' truncation."
|
"Test `format-spec--do-flags' truncation."
|
||||||
(let (flags)
|
(let ((flags nil))
|
||||||
(should (equal (format-spec--do-flags "" flags nil 0) ""))
|
(should (equal (format-spec--do-flags "" flags nil 0) ""))
|
||||||
(should (equal (format-spec--do-flags "" flags nil 1) ""))
|
(should (equal (format-spec--do-flags "" flags nil 1) ""))
|
||||||
(should (equal (format-spec--do-flags "a" flags nil 0) ""))
|
(should (equal (format-spec--do-flags "a" flags nil 0) ""))
|
||||||
|
|
@ -75,7 +75,7 @@
|
||||||
|
|
||||||
(ert-deftest format-spec-do-flags-pad ()
|
(ert-deftest format-spec-do-flags-pad ()
|
||||||
"Test `format-spec--do-flags' padding."
|
"Test `format-spec--do-flags' padding."
|
||||||
(let (flags)
|
(let ((flags nil))
|
||||||
(should (equal (format-spec--do-flags "" flags 0 nil) ""))
|
(should (equal (format-spec--do-flags "" flags 0 nil) ""))
|
||||||
(should (equal (format-spec--do-flags "" flags 1 nil) " "))
|
(should (equal (format-spec--do-flags "" flags 1 nil) " "))
|
||||||
(should (equal (format-spec--do-flags "a" flags 0 nil) "a"))
|
(should (equal (format-spec--do-flags "a" flags 0 nil) "a"))
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,8 @@
|
||||||
(kill-buffer buf)
|
(kill-buffer buf)
|
||||||
(setq buf (dired (nconc (list dir) files)))
|
(setq buf (dired (nconc (list dir) files)))
|
||||||
(should (looking-at "src"))
|
(should (looking-at "src"))
|
||||||
(next-line) ; File names must be aligned.
|
(with-suppressed-warnings ((interactive-only next-line))
|
||||||
|
(next-line)) ; File names must be aligned.
|
||||||
(should (looking-at "src")))
|
(should (looking-at "src")))
|
||||||
(when (buffer-live-p buf) (kill-buffer buf)))))
|
(when (buffer-live-p buf) (kill-buffer buf)))))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,15 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;; Hack to work around the ERT limitation that we can't reliably use
|
||||||
|
;; `with-suppressed-warnings' inside an `ert-deftest'. (Bug#36568)
|
||||||
|
(defun cl-tests-labels-test ()
|
||||||
|
(with-suppressed-warnings ((obsolete labels))
|
||||||
|
(funcall (labels ((foo () t))
|
||||||
|
#'foo))))
|
||||||
|
|
||||||
(ert-deftest labels-function-quoting ()
|
(ert-deftest labels-function-quoting ()
|
||||||
"Test that #'foo does the right thing in `labels'." ; Bug#31792.
|
"Test that #'foo does the right thing in `labels'." ; Bug#31792.
|
||||||
(should (eq (funcall (labels ((foo () t))
|
(should (eq (cl-tests-labels-test) t)))
|
||||||
#'foo))
|
|
||||||
t)))
|
|
||||||
|
|
||||||
;;; cl-tests.el ends here
|
;;; cl-tests.el ends here
|
||||||
|
|
|
||||||
|
|
@ -438,7 +438,8 @@ to (xref-elisp-test-descr-to-target xref)."
|
||||||
;; track down the problem.
|
;; track down the problem.
|
||||||
(cl-defmethod xref-elisp-generic-no-default ((this xref-elisp-root-type) arg2)
|
(cl-defmethod xref-elisp-generic-no-default ((this xref-elisp-root-type) arg2)
|
||||||
"Doc string generic no-default xref-elisp-root-type."
|
"Doc string generic no-default xref-elisp-root-type."
|
||||||
"non-default for no-default")
|
"non-default for no-default"
|
||||||
|
(list this arg2)) ; silence byte-compiler
|
||||||
|
|
||||||
;; defgeneric after defmethod in file to ensure the fallback search
|
;; defgeneric after defmethod in file to ensure the fallback search
|
||||||
;; method of just looking for the function name will fail.
|
;; method of just looking for the function name will fail.
|
||||||
|
|
@ -463,19 +464,23 @@ to (xref-elisp-test-descr-to-target xref)."
|
||||||
|
|
||||||
(cl-defmethod xref-elisp-generic-separate-default (arg1 arg2)
|
(cl-defmethod xref-elisp-generic-separate-default (arg1 arg2)
|
||||||
"Doc string generic separate-default default."
|
"Doc string generic separate-default default."
|
||||||
"separate default")
|
"separate default"
|
||||||
|
(list arg1 arg2)) ; silence byte-compiler
|
||||||
|
|
||||||
(cl-defmethod xref-elisp-generic-separate-default ((this xref-elisp-root-type) arg2)
|
(cl-defmethod xref-elisp-generic-separate-default ((this xref-elisp-root-type) arg2)
|
||||||
"Doc string generic separate-default xref-elisp-root-type."
|
"Doc string generic separate-default xref-elisp-root-type."
|
||||||
"non-default for separate-default")
|
"non-default for separate-default"
|
||||||
|
(list this arg2)) ; silence byte-compiler
|
||||||
|
|
||||||
(cl-defmethod xref-elisp-generic-implicit-generic (arg1 arg2)
|
(cl-defmethod xref-elisp-generic-implicit-generic (arg1 arg2)
|
||||||
"Doc string generic implicit-generic default."
|
"Doc string generic implicit-generic default."
|
||||||
"default for implicit generic")
|
"default for implicit generic"
|
||||||
|
(list arg1 arg2)) ; silence byte-compiler
|
||||||
|
|
||||||
(cl-defmethod xref-elisp-generic-implicit-generic ((this xref-elisp-root-type) arg2)
|
(cl-defmethod xref-elisp-generic-implicit-generic ((this xref-elisp-root-type) arg2)
|
||||||
"Doc string generic implicit-generic xref-elisp-root-type."
|
"Doc string generic implicit-generic xref-elisp-root-type."
|
||||||
"non-default for implicit generic")
|
"non-default for implicit generic"
|
||||||
|
(list this arg2)) ; silence byte-compiler
|
||||||
|
|
||||||
|
|
||||||
(xref-elisp-deftest find-defs-defgeneric-no-methods
|
(xref-elisp-deftest find-defs-defgeneric-no-methods
|
||||||
|
|
@ -845,7 +850,8 @@ to (xref-elisp-test-descr-to-target xref)."
|
||||||
(if (stringp form)
|
(if (stringp form)
|
||||||
(insert form)
|
(insert form)
|
||||||
(pp form (current-buffer)))
|
(pp form (current-buffer)))
|
||||||
(font-lock-debug-fontify)
|
(with-suppressed-warnings ((interactive-only font-lock-debug-fontify))
|
||||||
|
(font-lock-debug-fontify))
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(and (re-search-forward search nil t)
|
(and (re-search-forward search nil t)
|
||||||
(get-text-property (match-beginning 1) 'face))))
|
(get-text-property (match-beginning 1) 'face))))
|
||||||
|
|
|
||||||
|
|
@ -599,11 +599,12 @@ bound to HIGHLIGHT-LOCUS."
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(insert before)
|
(insert before)
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(replace-regexp
|
(with-suppressed-warnings ((interactive-only replace-regexp))
|
||||||
"\\(\\(L\\)\\|\\(R\\)\\)"
|
(replace-regexp
|
||||||
'(replace-eval-replacement
|
"\\(\\(L\\)\\|\\(R\\)\\)"
|
||||||
replace-quote
|
'(replace-eval-replacement
|
||||||
(if (match-string 2) "R" "L")))
|
replace-quote
|
||||||
|
(if (match-string 2) "R" "L"))))
|
||||||
(should (equal (buffer-string) after)))))
|
(should (equal (buffer-string) after)))))
|
||||||
|
|
||||||
(ert-deftest test-count-matches ()
|
(ert-deftest test-count-matches ()
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,10 @@
|
||||||
(require 'ert)
|
(require 'ert)
|
||||||
(require 'ses)
|
(require 'ses)
|
||||||
|
|
||||||
|
;; Silence byte-compiler.
|
||||||
|
(with-suppressed-warnings ((lexical A2) (lexical A3))
|
||||||
|
(defvar A2)
|
||||||
|
(defvar A3))
|
||||||
|
|
||||||
;; PLAIN FORMULA TESTS
|
;; PLAIN FORMULA TESTS
|
||||||
;; ======================================================================
|
;; ======================================================================
|
||||||
|
|
|
||||||
|
|
@ -926,6 +926,7 @@ See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=19350."
|
||||||
(should-not (apropos-internal "^next-line$" #'keymapp)))
|
(should-not (apropos-internal "^next-line$" #'keymapp)))
|
||||||
|
|
||||||
|
|
||||||
|
(defvar test-global-boundp)
|
||||||
(ert-deftest test-buffer-local-boundp ()
|
(ert-deftest test-buffer-local-boundp ()
|
||||||
(let ((buf (generate-new-buffer "boundp")))
|
(let ((buf (generate-new-buffer "boundp")))
|
||||||
(with-current-buffer buf
|
(with-current-buffer buf
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,12 @@
|
||||||
(defvar tar-mode-tests-data-directory
|
(defvar tar-mode-tests-data-directory
|
||||||
(expand-file-name "test/data/decompress" source-directory))
|
(expand-file-name "test/data/decompress" source-directory))
|
||||||
|
|
||||||
|
;; Hack to work around the ERT limitation that we can't reliably use
|
||||||
|
;; `with-suppressed-warnings' inside an `ert-deftest'. (Bug#36568)
|
||||||
|
(defun tar-mode-tests--tar-grind-file-mode (&rest args)
|
||||||
|
(with-suppressed-warnings ((obsolete tar-grind-file-mode))
|
||||||
|
(apply #'tar-grind-file-mode args)))
|
||||||
|
|
||||||
(ert-deftest tar-mode-test-tar-grind-file-mode ()
|
(ert-deftest tar-mode-test-tar-grind-file-mode ()
|
||||||
(let ((alist (list (cons 448 "rwx------")
|
(let ((alist (list (cons 448 "rwx------")
|
||||||
(cons 420 "rw-r--r--")
|
(cons 420 "rw-r--r--")
|
||||||
|
|
@ -32,7 +38,7 @@
|
||||||
(cons 1024 "-----S---")
|
(cons 1024 "-----S---")
|
||||||
(cons 2048 "--S------"))))
|
(cons 2048 "--S------"))))
|
||||||
(dolist (x alist)
|
(dolist (x alist)
|
||||||
(should (equal (cdr x) (tar-grind-file-mode (car x)))))))
|
(should (equal (cdr x) (tar-mode-tests--tar-grind-file-mode (car x)))))))
|
||||||
|
|
||||||
(ert-deftest tar-mode-test-tar-extract-gz ()
|
(ert-deftest tar-mode-test-tar-extract-gz ()
|
||||||
(skip-unless (executable-find "gzip"))
|
(skip-unless (executable-find "gzip"))
|
||||||
|
|
|
||||||
|
|
@ -433,26 +433,27 @@ comparing the subr with a much slower Lisp implementation."
|
||||||
;; More specifically, test the problem seen in bug#41029 where setting
|
;; More specifically, test the problem seen in bug#41029 where setting
|
||||||
;; the default value of a variable takes time proportional to the
|
;; the default value of a variable takes time proportional to the
|
||||||
;; number of buffers.
|
;; number of buffers.
|
||||||
(let* ((fun #'error)
|
(when (fboundp 'current-cpu-time) ; silence byte-compiler
|
||||||
(test (lambda ()
|
(let* ((fun #'error)
|
||||||
(with-temp-buffer
|
(test (lambda ()
|
||||||
(let ((st (car (current-cpu-time))))
|
(with-temp-buffer
|
||||||
(dotimes (_ 1000)
|
(let ((st (car (current-cpu-time))))
|
||||||
(let ((case-fold-search 'data-test))
|
(dotimes (_ 1000)
|
||||||
;; Use an indirection through a mutable var
|
(let ((case-fold-search 'data-test))
|
||||||
;; to try and make sure the byte-compiler
|
;; Use an indirection through a mutable var
|
||||||
;; doesn't optimize away the let bindings.
|
;; to try and make sure the byte-compiler
|
||||||
(funcall fun)))
|
;; doesn't optimize away the let bindings.
|
||||||
;; FIXME: Handle the wraparound, if any.
|
(funcall fun)))
|
||||||
(- (car (current-cpu-time)) st)))))
|
;; FIXME: Handle the wraparound, if any.
|
||||||
(_ (setq fun #'ignore))
|
(- (car (current-cpu-time)) st)))))
|
||||||
(time1 (funcall test))
|
(_ (setq fun #'ignore))
|
||||||
(bufs (mapcar (lambda (_) (generate-new-buffer " data-test"))
|
(time1 (funcall test))
|
||||||
(make-list 1000 nil)))
|
(bufs (mapcar (lambda (_) (generate-new-buffer " data-test"))
|
||||||
(time2 (funcall test)))
|
(make-list 1000 nil)))
|
||||||
(mapc #'kill-buffer bufs)
|
(time2 (funcall test)))
|
||||||
;; Don't divide one time by the other since they may be 0.
|
(mapc #'kill-buffer bufs)
|
||||||
(should (< time2 (* time1 5)))))
|
;; Don't divide one time by the other since they may be 0.
|
||||||
|
(should (< time2 (* time1 5))))))
|
||||||
|
|
||||||
;; More tests to write -
|
;; More tests to write -
|
||||||
;; kill-local-variable
|
;; kill-local-variable
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
(setq ov-set (make-overlay 3 5))
|
(setq ov-set (make-overlay 3 5))
|
||||||
(overlay-put
|
(overlay-put
|
||||||
ov-set 'modification-hooks
|
ov-set 'modification-hooks
|
||||||
(list (lambda (o after &rest _args)
|
(list (lambda (_o after &rest _args)
|
||||||
(when after
|
(when after
|
||||||
(let ((inhibit-modification-hooks t))
|
(let ((inhibit-modification-hooks t))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue