aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorStefan Monnier2014-05-10 16:07:01 -0400
committerStefan Monnier2014-05-10 16:07:01 -0400
commit5d03fb436fcfb1fe704cc7a66dec7bd2d21d49f1 (patch)
tree7884824b46c957bc5bfce46066e756d4ae4992db /test
parent4a5c71d7c275b93238c629601526a87eca08e6fd (diff)
downloademacs-5d03fb436fcfb1fe704cc7a66dec7bd2d21d49f1.tar.gz
emacs-5d03fb436fcfb1fe704cc7a66dec7bd2d21d49f1.zip
* lisp/emacs-lisp/nadvice.el: Support adding a given function multiple times.
(advice--member-p): If name is given, only compare the name. (advice--remove-function): Don't stop at the first match. (advice--normalize-place): New function. (add-function, remove-function): Use it. (advice--add-function): Pass the name, if any, to advice--remove-function.
Diffstat (limited to 'test')
-rw-r--r--test/automated/advice-tests.el23
-rwxr-xr-xtest/indent/perl.perl13
-rw-r--r--test/indent/ruby.rb3
3 files changed, 38 insertions, 1 deletions
diff --git a/test/automated/advice-tests.el b/test/automated/advice-tests.el
index f755e8defef..e0c3b40487e 100644
--- a/test/automated/advice-tests.el
+++ b/test/automated/advice-tests.el
@@ -179,6 +179,29 @@ function being an around advice."
179 (interactive "P") nil) 179 (interactive "P") nil)
180 (should (equal (interactive-form 'sm-test9) '(interactive "P")))) 180 (should (equal (interactive-form 'sm-test9) '(interactive "P"))))
181 181
182(ert-deftest advice-test-multiples ()
183 (let ((sm-test10 (lambda (a) (+ a 10)))
184 (sm-advice (lambda (x) (if (consp x) (list (* 5 (car x))) (* 4 x)))))
185 (should (equal (funcall sm-test10 5) 15))
186 (add-function :filter-args (var sm-test10) sm-advice)
187 (should (equal (funcall sm-test10 5) 35))
188 (add-function :filter-return (var sm-test10) sm-advice)
189 (should (equal (funcall sm-test10 5) 60))
190 ;; Make sure we can add multiple times the same function, under the
191 ;; condition that they have different `name' properties.
192 (add-function :filter-args (var sm-test10) sm-advice '((name . "args")))
193 (should (equal (funcall sm-test10 5) 140))
194 (remove-function (var sm-test10) "args")
195 (should (equal (funcall sm-test10 5) 60))
196 (add-function :filter-args (var sm-test10) sm-advice '((name . "args")))
197 (add-function :filter-return (var sm-test10) sm-advice '((name . "ret")))
198 (should (equal (funcall sm-test10 5) 560))
199 ;; Make sure that if we specify to remove a function that was added
200 ;; multiple times, they are all removed, rather than removing only some
201 ;; arbitrary subset of them.
202 (remove-function (var sm-test10) sm-advice)
203 (should (equal (funcall sm-test10 5) 15))))
204
182;; Local Variables: 205;; Local Variables:
183;; no-byte-compile: t 206;; no-byte-compile: t
184;; End: 207;; End:
diff --git a/test/indent/perl.perl b/test/indent/perl.perl
index c7a2fbfb2d2..aca478a1375 100755
--- a/test/indent/perl.perl
+++ b/test/indent/perl.perl
@@ -1,9 +1,20 @@
1#!/usr/bin/perl 1#!/usr/bin/perl
2# -*- eval: (bug-reference-mode 1) -*- 2# -*- eval: (bug-reference-mode 1) -*-
3 3
4use v5.14;
5
6my $str= <<END;
7Hello
8END
9
10my $a = $';
11
12my $b=3;
13
14print $str;
4if ($c && /====/){xyz;} 15if ($c && /====/){xyz;}
5 16
6print <<"EOF1" . s/he"llo/th'ere/; 17print << "EOF1" . s/he"llo/th'ere/;
7foo 18foo
8EOF2 19EOF2
9bar 20bar
diff --git a/test/indent/ruby.rb b/test/indent/ruby.rb
index fb341ee7ba6..7e778798996 100644
--- a/test/indent/ruby.rb
+++ b/test/indent/ruby.rb
@@ -16,6 +16,9 @@ d = %(hello (nested) world)
16# Don't propertize percent literals inside strings. 16# Don't propertize percent literals inside strings.
17"(%s, %s)" % [123, 456] 17"(%s, %s)" % [123, 456]
18 18
19"abc/#{def}ghi"
20"abc\#{def}ghi"
21
19# Or inside comments. 22# Or inside comments.
20x = # "tot %q/to"; = 23x = # "tot %q/to"; =
21 y = 2 / 3 24 y = 2 / 3