emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 028d80f 2/2: Add an automated test for let-when-com


From: Oleh Krehel
Subject: [Emacs-diffs] master 028d80f 2/2: Add an automated test for let-when-compile
Date: Wed, 20 May 2015 13:48:02 +0000

branch: master
commit 028d80f3a25bd167940e528895185f03960eceb0
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    Add an automated test for let-when-compile
    
    * test/automated/subr-tests.el (let-when-compile): New test.
---
 test/automated/subr-tests.el |   62 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 62 insertions(+), 0 deletions(-)

diff --git a/test/automated/subr-tests.el b/test/automated/subr-tests.el
new file mode 100644
index 0000000..a42acf5
--- /dev/null
+++ b/test/automated/subr-tests.el
@@ -0,0 +1,62 @@
+;;; subr-tests.el --- Tests for subr.el
+
+;; Copyright (C) 2015 Free Software Foundation, Inc.
+
+;; Author: Oleh Krehel <address@hidden>
+;; Keywords:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(require 'ert)
+
+(ert-deftest let-when-compile ()
+  ;; good case
+  (should (equal (macroexpand '(let-when-compile ((foo (+ 2 3)))
+                                (setq bar (eval-when-compile (+ foo foo)))
+                                (setq boo (eval-when-compile (* foo foo)))))
+                 '(progn
+                   (setq bar (quote 10))
+                   (setq boo (quote 25)))))
+  ;; bad case: `eval-when-compile' omitted, byte compiler should catch this
+  (should (equal (macroexpand
+                  '(let-when-compile ((foo (+ 2 3)))
+                    (setq bar (+ foo foo))
+                    (setq boo (eval-when-compile (* foo foo)))))
+                 '(progn
+                   (setq bar (+ foo foo))
+                   (setq boo (quote 25)))))
+  ;; something practical
+  (should (equal (macroexpand
+                  '(let-when-compile ((keywords '("true" "false")))
+                    (font-lock-add-keywords
+                     'c++-mode
+                     `((,(eval-when-compile
+                           (format "\\<%s\\>" (regexp-opt keywords)))
+                         0 font-lock-keyword-face)))))
+                 '(font-lock-add-keywords
+                   (quote c++-mode)
+                   (list
+                    (cons (quote
+                           "\\<\\(?:\\(?:fals\\|tru\\)e\\)\\>")
+                     (quote
+                      (0 font-lock-keyword-face))))))))
+
+(provide 'subr-tests)
+;;; subr-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]