diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/ChangeLog | 6 | ||||
| -rw-r--r-- | test/automated/advice-tests.el | 17 |
2 files changed, 23 insertions, 0 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index 32fc077459b..d744a5c788d 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2013-08-04 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * automated/advice-tests.el (advice-tests-nadvice): Test removal | ||
| 4 | before definition. | ||
| 5 | (advice-tests-macroaliases): New test. | ||
| 6 | |||
| 1 | 2013-08-04 Glenn Morris <rgm@gnu.org> | 7 | 2013-08-04 Glenn Morris <rgm@gnu.org> |
| 2 | 8 | ||
| 3 | * automated/ert-tests.el: Disable failing test that no-one seems | 9 | * automated/ert-tests.el: Disable failing test that no-one seems |
diff --git a/test/automated/advice-tests.el b/test/automated/advice-tests.el index 69c15e34ed0..424f447ae4b 100644 --- a/test/automated/advice-tests.el +++ b/test/automated/advice-tests.el | |||
| @@ -25,7 +25,12 @@ | |||
| 25 | 25 | ||
| 26 | (ert-deftest advice-tests-nadvice () | 26 | (ert-deftest advice-tests-nadvice () |
| 27 | "Test nadvice code." | 27 | "Test nadvice code." |
| 28 | (advice-add 'sm-test1 :around (lambda (f y) (* (funcall f y) 5))) | ||
| 29 | (advice-add 'sm-test1 :around (lambda (f y) (* (funcall f y) 2))) | ||
| 30 | (advice-remove 'sm-test1 (lambda (f y) (* (funcall f y) 5))) | ||
| 28 | (defun sm-test1 (x) (+ x 4)) | 31 | (defun sm-test1 (x) (+ x 4)) |
| 32 | (should (equal (sm-test1 6) 20)) | ||
| 33 | (advice-remove 'sm-test1 (lambda (f y) (* (funcall f y) 2))) | ||
| 29 | (should (equal (sm-test1 6) 10)) | 34 | (should (equal (sm-test1 6) 10)) |
| 30 | (advice-add 'sm-test1 :around (lambda (f y) (* (funcall f y) 5))) | 35 | (advice-add 'sm-test1 :around (lambda (f y) (* (funcall f y) 5))) |
| 31 | (should (equal (sm-test1 6) 50)) | 36 | (should (equal (sm-test1 6) 50)) |
| @@ -42,6 +47,18 @@ | |||
| 42 | (defmacro sm-test3 (x) `(call-test3 ,x)) | 47 | (defmacro sm-test3 (x) `(call-test3 ,x)) |
| 43 | (should (equal (macroexpand '(sm-test3 56)) '(toto (call-test3 56))))) | 48 | (should (equal (macroexpand '(sm-test3 56)) '(toto (call-test3 56))))) |
| 44 | 49 | ||
| 50 | (ert-deftest advice-tests-macroaliases () | ||
| 51 | "Test nadvice code on aliases to macros." | ||
| 52 | (defmacro sm-test1 (a) `(list ',a)) | ||
| 53 | (defalias 'sm-test1-alias 'sm-test1) | ||
| 54 | (should (equal (macroexpand '(sm-test1-alias 5)) '(list '5))) | ||
| 55 | (advice-add 'sm-test1-alias :around | ||
| 56 | (lambda (f &rest args) `(cons 1 ,(apply f args)))) | ||
| 57 | (should (equal (macroexpand '(sm-test1-alias 5)) '(cons 1 (list '5)))) | ||
| 58 | (defmacro sm-test1 (a) `(list 0 ',a)) | ||
| 59 | (should (equal (macroexpand '(sm-test1-alias 5)) '(cons 1 (list 0 '5))))) | ||
| 60 | |||
| 61 | |||
| 45 | (ert-deftest advice-tests-advice () | 62 | (ert-deftest advice-tests-advice () |
| 46 | "Test advice code." | 63 | "Test advice code." |
| 47 | (defun sm-test2 (x) (+ x 4)) | 64 | (defun sm-test2 (x) (+ x 4)) |