diff options
| author | Ryan | 2013-09-20 15:59:42 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2013-09-20 15:59:42 -0400 |
| commit | 31dca772aded1c089b135d6335e4e444fd63078a (patch) | |
| tree | fc0b81bb9e78daae93cca7ef169d366e47afe17a /test | |
| parent | 1e835c22e8ec9e387b4275196103d4d6d0617899 (diff) | |
| download | emacs-31dca772aded1c089b135d6335e4e444fd63078a.tar.gz emacs-31dca772aded1c089b135d6335e4e444fd63078a.zip | |
* lisp/subr.el (internal--call-interactively): New const.
(called-interactively-p): Use it.
* test/automated/advice-tests.el (advice-test-called-interactively-p-around)
(advice-test-called-interactively-p-filter-args)
(advice-test-called-interactively-p-around): New tests.
Fixes: debbugs:3984
Diffstat (limited to 'test')
| -rw-r--r-- | test/ChangeLog | 6 | ||||
| -rw-r--r-- | test/automated/advice-tests.el | 32 |
2 files changed, 38 insertions, 0 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index 000f8e257f1..14d819c7f77 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2013-09-20 Ryan <rct@thompsonclan.org> (tiny change) | ||
| 2 | |||
| 3 | * automated/advice-tests.el (advice-test-called-interactively-p-around) | ||
| 4 | (advice-test-called-interactively-p-filter-args) | ||
| 5 | (advice-test-called-interactively-p-around): New tests. | ||
| 6 | |||
| 1 | 2013-09-16 Glenn Morris <rgm@gnu.org> | 7 | 2013-09-16 Glenn Morris <rgm@gnu.org> |
| 2 | 8 | ||
| 3 | * automated/eshell.el (eshell-match-result): | 9 | * automated/eshell.el (eshell-match-result): |
diff --git a/test/automated/advice-tests.el b/test/automated/advice-tests.el index 424f447ae4b..bdb0eb09b40 100644 --- a/test/automated/advice-tests.el +++ b/test/automated/advice-tests.el | |||
| @@ -130,6 +130,38 @@ | |||
| 130 | (cons (cons 2 (called-interactively-p)) (apply f args)))) | 130 | (cons (cons 2 (called-interactively-p)) (apply f args)))) |
| 131 | (should (equal (call-interactively 'sm-test7) '((2 . t) (1 . t) 11)))) | 131 | (should (equal (call-interactively 'sm-test7) '((2 . t) (1 . t) 11)))) |
| 132 | 132 | ||
| 133 | (ert-deftest advice-test-called-interactively-p-around () | ||
| 134 | "Check interaction between around advice and called-interactively-p. | ||
| 135 | |||
| 136 | This tests the currently broken case of the innermost advice to a | ||
| 137 | function being an around advice." | ||
| 138 | :expected-result :failed | ||
| 139 | (defun sm-test7.2 () (interactive) (cons 1 (called-interactively-p))) | ||
| 140 | (advice-add 'sm-test7.2 :around | ||
| 141 | (lambda (f &rest args) | ||
| 142 | (list (cons 1 (called-interactively-p)) (apply f args)))) | ||
| 143 | (should (equal (sm-test7.2) '((1 . nil) (1 . nil)))) | ||
| 144 | (should (equal (call-interactively 'sm-test7.2) '((1 . t) (1 . t))))) | ||
| 145 | |||
| 146 | (ert-deftest advice-test-called-interactively-p-filter-args () | ||
| 147 | "Check interaction between filter-args advice and called-interactively-p." | ||
| 148 | :expected-result :failed | ||
| 149 | (defun sm-test7.3 () (interactive) (cons 1 (called-interactively-p))) | ||
| 150 | (advice-add 'sm-test7.3 :filter-args #'list) | ||
| 151 | (should (equal (sm-test7.3) '(1 . nil))) | ||
| 152 | (should (equal (call-interactively 'sm-test7.3) '(1 . t)))) | ||
| 153 | |||
| 154 | (ert-deftest advice-test-call-interactively () | ||
| 155 | "Check interaction between advice on call-interactively and called-interactively-p." | ||
| 156 | (defun sm-test7.4 () (interactive) (cons 1 (called-interactively-p))) | ||
| 157 | (let ((old (symbol-function 'call-interactively))) | ||
| 158 | (unwind-protect | ||
| 159 | (progn | ||
| 160 | (advice-add 'call-interactively :before #'ignore) | ||
| 161 | (should (equal (sm-test7.4) '(1 . nil))) | ||
| 162 | (should (equal (call-interactively 'sm-test7.4) '(1 . t)))) | ||
| 163 | (fset 'call-interactively old)))) | ||
| 164 | |||
| 133 | (ert-deftest advice-test-interactive () | 165 | (ert-deftest advice-test-interactive () |
| 134 | "Check handling of interactive spec." | 166 | "Check handling of interactive spec." |
| 135 | (defun sm-test8 (a) (interactive "p") a) | 167 | (defun sm-test8 (a) (interactive "p") a) |