diff options
| author | Artur Malabarba | 2014-12-18 19:37:15 -0200 |
|---|---|---|
| committer | Artur Malabarba | 2014-12-18 19:37:54 -0200 |
| commit | 645a6aa4a5ee66659133f57ebeb5638bdc43beaa (patch) | |
| tree | 362c715b0f0d4014686ab672549125bc7dae08d2 | |
| parent | d8183f8fef11d654d0aae2b24eddcdfad6d63164 (diff) | |
| download | emacs-645a6aa4a5ee66659133f57ebeb5638bdc43beaa.tar.gz emacs-645a6aa4a5ee66659133f57ebeb5638bdc43beaa.zip | |
* automated/let-alist.el: New file.
| -rw-r--r-- | test/ChangeLog | 4 | ||||
| -rw-r--r-- | test/automated/let-alist.el | 52 |
2 files changed, 56 insertions, 0 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index 86703d569f4..8ddd80f8e61 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2014-12-18 Artur Malabarba <bruce.connor.am@gmail.com> | ||
| 2 | |||
| 3 | * automated/let-alist.el: New file. | ||
| 4 | |||
| 1 | 2014-12-16 Nicolas Petton <petton.nicolas@gmail.com> | 5 | 2014-12-16 Nicolas Petton <petton.nicolas@gmail.com> |
| 2 | 6 | ||
| 3 | * automated/seq-tests.el: New file. | 7 | * automated/seq-tests.el: New file. |
diff --git a/test/automated/let-alist.el b/test/automated/let-alist.el new file mode 100644 index 00000000000..2054a965b67 --- /dev/null +++ b/test/automated/let-alist.el | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | ;;; let-alist.el --- tests for file handling. -*- lexical-binding: t; -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2012-2014 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 8 | ;; it under the terms of the GNU General Public License as published by | ||
| 9 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 10 | ;; (at your option) any later version. | ||
| 11 | |||
| 12 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | ;; GNU General Public License for more details. | ||
| 16 | |||
| 17 | ;; You should have received a copy of the GNU General Public License | ||
| 18 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 19 | |||
| 20 | ;;; Code: | ||
| 21 | |||
| 22 | (require 'ert) | ||
| 23 | |||
| 24 | (ert-deftest let-alist-surface-test () | ||
| 25 | "Tests basic macro expansion for `let-alist'." | ||
| 26 | (should | ||
| 27 | (equal '(let ((symbol data)) | ||
| 28 | (let ((.test-one (cdr (assq 'test-one symbol))) | ||
| 29 | (.test-two (cdr (assq 'test-two symbol)))) | ||
| 30 | (list .test-one .test-two | ||
| 31 | .test-two .test-two))) | ||
| 32 | (cl-letf (((symbol-function #'gensym) (lambda (x) 'symbol))) | ||
| 33 | (macroexpand | ||
| 34 | '(let-alist data (list .test-one .test-two | ||
| 35 | .test-two .test-two))))))) | ||
| 36 | |||
| 37 | (defvar let-alist--test-counter 0 | ||
| 38 | "Used to count number of times a function is called.") | ||
| 39 | |||
| 40 | (ert-deftest let-alist-evaluate-once () | ||
| 41 | "Check that the alist argument is only evaluated once." | ||
| 42 | (let ((let-alist--test-counter 0)) | ||
| 43 | (should | ||
| 44 | (equal | ||
| 45 | (let-alist (list | ||
| 46 | (cons 'test-two (cl-incf let-alist--test-counter)) | ||
| 47 | (cons 'test-three (cl-incf let-alist--test-counter))) | ||
| 48 | (list .test-one .test-two .test-two .test-three .cl-incf)) | ||
| 49 | '(nil 1 1 2 nil))))) | ||
| 50 | |||
| 51 | |||
| 52 | ;;; let-alist.el ends here | ||