diff options
| author | Andrea Corallo | 2020-09-23 09:36:49 +0200 |
|---|---|---|
| committer | Andrea Corallo | 2020-09-24 09:57:17 +0200 |
| commit | 0cc1804d42e25e0213f8b3872cc6133c6480a5b0 (patch) | |
| tree | 462808a9ea700063818a0114ffc5f6df89cf242b /test/src | |
| parent | db354ffd578a46d898cac161ea1de1b42f96d2a0 (diff) | |
| download | emacs-0cc1804d42e25e0213f8b3872cc6133c6480a5b0.tar.gz emacs-0cc1804d42e25e0213f8b3872cc6133c6480a5b0.zip | |
Add a test for primitive advicing effectiveness
* test/src/comp-test-funcs.el (comp-test-primitive-advice-f): New
function.
* test/src/comp-tests.el (comp-test-primitive-advice): New test.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/comp-test-funcs.el | 4 | ||||
| -rw-r--r-- | test/src/comp-tests.el | 13 |
2 files changed, 17 insertions, 0 deletions
diff --git a/test/src/comp-test-funcs.el b/test/src/comp-test-funcs.el index fe9943a1b91..19acec2716e 100644 --- a/test/src/comp-test-funcs.el +++ b/test/src/comp-test-funcs.el | |||
| @@ -337,6 +337,10 @@ | |||
| 337 | (concat head-padding (substring str from-idx idx) | 337 | (concat head-padding (substring str from-idx idx) |
| 338 | tail-padding ellipsis))))) | 338 | tail-padding ellipsis))))) |
| 339 | 339 | ||
| 340 | (defun comp-test-primitive-advice-f (x y) | ||
| 341 | (declare (speed 2)) | ||
| 342 | (+ x y)) | ||
| 343 | |||
| 340 | 344 | ||
| 341 | ;;;;;;;;;;;;;;;;;;;; | 345 | ;;;;;;;;;;;;;;;;;;;; |
| 342 | ;; Tromey's tests ;; | 346 | ;; Tromey's tests ;; |
diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el index 220bf1c7736..356bd876ffb 100644 --- a/test/src/comp-tests.el +++ b/test/src/comp-tests.el | |||
| @@ -375,6 +375,19 @@ https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-03/msg00914.html." | |||
| 375 | (should (string= (comp-test-42360-f "Nel mezzo del " 18 0 32 "yyy" nil) | 375 | (should (string= (comp-test-42360-f "Nel mezzo del " 18 0 32 "yyy" nil) |
| 376 | "Nel mezzo del yyy"))) | 376 | "Nel mezzo del yyy"))) |
| 377 | 377 | ||
| 378 | (defvar comp-test-primitive-advice) | ||
| 379 | (ert-deftest comp-test-primitive-advice () | ||
| 380 | "Test effectiveness of primitve advicing." | ||
| 381 | (let (comp-test-primitive-advice | ||
| 382 | (f (lambda (&rest args) | ||
| 383 | (setq comp-test-primitive-advice args)))) | ||
| 384 | (advice-add #'+ :before f) | ||
| 385 | (unwind-protect | ||
| 386 | (progn | ||
| 387 | (should (= (comp-test-primitive-advice-f 3 4) 7)) | ||
| 388 | (should (equal comp-test-primitive-advice '(3 4)))) | ||
| 389 | (advice-remove #'+ f)))) | ||
| 390 | |||
| 378 | 391 | ||
| 379 | ;;;;;;;;;;;;;;;;;;;;; | 392 | ;;;;;;;;;;;;;;;;;;;;; |
| 380 | ;; Tromey's tests. ;; | 393 | ;; Tromey's tests. ;; |