Commit 028d80f3 authored by Oleh Krehel's avatar Oleh Krehel
Browse files

Add an automated test for let-when-compile

* test/automated/subr-tests.el (let-when-compile): New test.
parent 5d752c8a
;;; subr-tests.el --- Tests for subr.el
;; Copyright (C) 2015 Free Software Foundation, Inc.
;; Author: Oleh Krehel <>
;; 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
;; 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 <>.
;;; 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)))))
(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)))))
(setq bar (+ foo foo))
(setq boo (quote 25)))))
;; something practical
(should (equal (macroexpand
'(let-when-compile ((keywords '("true" "false")))
(format "\\<%s\\>" (regexp-opt keywords)))
0 font-lock-keyword-face)))))
(quote c++-mode)
(cons (quote
(0 font-lock-keyword-face))))))))
(provide 'subr-tests)
;;; subr-tests.el ends here
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment