diff options
| author | Andrea Corallo | 2019-12-10 12:55:34 +0100 |
|---|---|---|
| committer | Andrea Corallo | 2020-06-22 00:02:57 +0200 |
| commit | 47ab6c237e703cf4b5bbcd3c301e324e0deb1173 (patch) | |
| tree | 56a0f15802f65f9c90a5fb7452a7a2927c3a416a /test | |
| parent | c37b5446d1f8e567f97f5708008b14a80b6c6d65 (diff) | |
| download | emacs-47ab6c237e703cf4b5bbcd3c301e324e0deb1173.tar.gz emacs-47ab6c237e703cf4b5bbcd3c301e324e0deb1173.zip | |
Add some testing for dynamic scope
* test/src/comp-test-funcs-dyn.el: New file.
* test/src/comp-tests.el (comp-tests-dynamic-ffuncall): Add
new tests.
Diffstat (limited to 'test')
| -rw-r--r-- | test/src/comp-test-funcs-dyn.el | 40 | ||||
| -rw-r--r-- | test/src/comp-tests.el | 46 |
2 files changed, 82 insertions, 4 deletions
diff --git a/test/src/comp-test-funcs-dyn.el b/test/src/comp-test-funcs-dyn.el new file mode 100644 index 00000000000..0e342a39d3e --- /dev/null +++ b/test/src/comp-test-funcs-dyn.el | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | ;;; comp-test-funcs.el --- compilation unit tested by comp-tests.el -*- lexical-binding: nil; -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2020 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Andrea Corallo <akrl@sdf.org> | ||
| 6 | |||
| 7 | ;; This file is part of GNU Emacs. | ||
| 8 | |||
| 9 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 10 | ;; it under the terms of the GNU General Public License as published by | ||
| 11 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 12 | ;; (at your option) any later version. | ||
| 13 | |||
| 14 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 15 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | ;; GNU General Public License for more details. | ||
| 18 | |||
| 19 | ;; You should have received a copy of the GNU General Public License | ||
| 20 | ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. | ||
| 21 | |||
| 22 | ;;; Commentary: | ||
| 23 | |||
| 24 | ;;; Code: | ||
| 25 | |||
| 26 | (defun comp-tests-ffuncall-callee-dyn-f (a b) | ||
| 27 | (list a b)) | ||
| 28 | |||
| 29 | (defun comp-tests-ffuncall-callee-opt-dyn-f (a b &optional c d) | ||
| 30 | (list a b c d)) | ||
| 31 | |||
| 32 | (defun comp-tests-ffuncall-callee-rest-dyn-f (a b &rest c) | ||
| 33 | (list a b c)) | ||
| 34 | |||
| 35 | (defun comp-tests-ffuncall-callee-opt-rest-dyn-f (a b &optional c &rest d) | ||
| 36 | (list a b c d)) | ||
| 37 | |||
| 38 | (provide 'comp-test-dyn-funcs) | ||
| 39 | |||
| 40 | ;;; comp-test-funcs-dyn.el ends here | ||
diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el index 3e40dba10b4..ee96d5656e7 100644 --- a/test/src/comp-tests.el +++ b/test/src/comp-tests.el | |||
| @@ -34,8 +34,14 @@ | |||
| 34 | (defconst comp-test-src | 34 | (defconst comp-test-src |
| 35 | (concat comp-test-directory "comp-test-funcs.el")) | 35 | (concat comp-test-directory "comp-test-funcs.el")) |
| 36 | 36 | ||
| 37 | (message "Compiling %s" comp-test-src) | 37 | (defconst comp-test-dyn-src |
| 38 | (concat comp-test-directory "comp-test-funcs-dyn.el")) | ||
| 39 | |||
| 40 | (message "Compiling tests...") | ||
| 38 | (load (native-compile comp-test-src)) | 41 | (load (native-compile comp-test-src)) |
| 42 | (load (native-compile comp-test-dyn-src)) | ||
| 43 | |||
| 44 | |||
| 39 | 45 | ||
| 40 | (ert-deftest comp-tests-bootstrap () | 46 | (ert-deftest comp-tests-bootstrap () |
| 41 | "Compile the compiler and load it to compile it-self. | 47 | "Compile the compiler and load it to compile it-self. |
| @@ -353,9 +359,9 @@ https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-03/msg00914.html." | |||
| 353 | (should (eq (comp-test-40187-2-f) 'bar))) | 359 | (should (eq (comp-test-40187-2-f) 'bar))) |
| 354 | 360 | ||
| 355 | 361 | ||
| 356 | ;;;;;;;;;;;;;;;;;;;; | 362 | ;;;;;;;;;;;;;;;;;;;;; |
| 357 | ;; Tromey's tests ;; | 363 | ;; Tromey's tests. ;; |
| 358 | ;;;;;;;;;;;;;;;;;;;; | 364 | ;;;;;;;;;;;;;;;;;;;;; |
| 359 | 365 | ||
| 360 | (ert-deftest comp-consp () | 366 | (ert-deftest comp-consp () |
| 361 | (should-not (comp-test-consp 23)) | 367 | (should-not (comp-test-consp 23)) |
| @@ -520,4 +526,36 @@ https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-03/msg00914.html." | |||
| 520 | nil)) | 526 | nil)) |
| 521 | (should (eq comp-test-up-val 999))) | 527 | (should (eq comp-test-up-val 999))) |
| 522 | 528 | ||
| 529 | |||
| 530 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 531 | ;; Tests for dynamic scope. ;; | ||
| 532 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 533 | |||
| 534 | (ert-deftest comp-tests-dynamic-ffuncall () | ||
| 535 | "Test calling convention for dynamic binding." | ||
| 536 | |||
| 537 | (should (equal (comp-tests-ffuncall-callee-dyn-f 1 2) | ||
| 538 | '(1 2))) | ||
| 539 | |||
| 540 | (should (equal (comp-tests-ffuncall-callee-opt-dyn-f 1 2 3 4) | ||
| 541 | '(1 2 3 4))) | ||
| 542 | (should (equal (comp-tests-ffuncall-callee-opt-dyn-f 1 2 3) | ||
| 543 | '(1 2 3 nil))) | ||
| 544 | (should (equal (comp-tests-ffuncall-callee-opt-dyn-f 1 2) | ||
| 545 | '(1 2 nil nil))) | ||
| 546 | |||
| 547 | (should (equal (comp-tests-ffuncall-callee-rest-dyn-f 1 2) | ||
| 548 | '(1 2 nil))) | ||
| 549 | (should (equal (comp-tests-ffuncall-callee-rest-dyn-f 1 2 3) | ||
| 550 | '(1 2 (3)))) | ||
| 551 | (should (equal (comp-tests-ffuncall-callee-rest-dyn-f 1 2 3 4) | ||
| 552 | '(1 2 (3 4)))) | ||
| 553 | |||
| 554 | (should (equal (comp-tests-ffuncall-callee-opt-rest-dyn-f 1 2) | ||
| 555 | '(1 2 nil nil))) | ||
| 556 | (should (equal (comp-tests-ffuncall-callee-opt-rest-dyn-f 1 2 3) | ||
| 557 | '(1 2 3 nil))) | ||
| 558 | (should (equal (comp-tests-ffuncall-callee-opt-rest-dyn-f 1 2 3 4) | ||
| 559 | '(1 2 3 (4))))) | ||
| 560 | |||
| 523 | ;;; comp-tests.el ends here | 561 | ;;; comp-tests.el ends here |