|
| 1 | +;;; clojure-mode-safe-eval-test.el --- Clojure Mode: safe eval test suite -*- lexical-binding: t; -*- |
| 2 | + |
| 3 | +;; Copyright (C) 2014-2021 Bozhidar Batsov <[email protected]> |
| 4 | +;; Copyright (C) 2021 Rob Browning <[email protected]> |
| 5 | + |
| 6 | +;; This file is not part of GNU Emacs. |
| 7 | + |
| 8 | +;; This program is free software; you can redistribute it and/or modify |
| 9 | +;; it under the terms of the GNU General Public License as published by |
| 10 | +;; the Free Software Foundation, either version 3 of the License, or |
| 11 | +;; (at your option) any later version. |
| 12 | + |
| 13 | +;; This program is distributed in the hope that it will be useful, |
| 14 | +;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | +;; GNU General Public License for more details. |
| 17 | + |
| 18 | +;; You should have received a copy of the GNU General Public License |
| 19 | +;; along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | + |
| 21 | +;;; Commentary: |
| 22 | + |
| 23 | +;; The safe eval test suite of Clojure Mode |
| 24 | + |
| 25 | +;;; Code: |
| 26 | +(require 'clojure-mode) |
| 27 | +(require 'buttercup) |
| 28 | + |
| 29 | +(describe "put-clojure-indent safe-local-eval-function property" |
| 30 | + (it "should be set to clojure--valid-put-clojure-indent-call-p" |
| 31 | + (expect (get 'put-clojure-indent 'safe-local-eval-function) |
| 32 | + :to-be 'clojure--valid-put-clojure-indent-call-p))) |
| 33 | + |
| 34 | +(describe "clojure--valid-put-clojure-indent-call-p" |
| 35 | + (it "should approve valid forms" |
| 36 | + (expect (clojure--valid-put-clojure-indent-call-p |
| 37 | + '(put-clojure-indent 'foo 1))) |
| 38 | + (expect (clojure--valid-put-clojure-indent-call-p |
| 39 | + '(put-clojure-indent 'foo :defn))) |
| 40 | + (expect (clojure--valid-put-clojure-indent-call-p |
| 41 | + '(put-clojure-indent 'foo :form))) |
| 42 | + (expect (clojure--valid-put-clojure-indent-call-p |
| 43 | + '(put-clojure-indent 'foo '(1)))) |
| 44 | + (expect (clojure--valid-put-clojure-indent-call-p |
| 45 | + '(put-clojure-indent 'foo '(:defn)))) |
| 46 | + (expect (clojure--valid-put-clojure-indent-call-p |
| 47 | + '(put-clojure-indent 'foo '(:form)))) |
| 48 | + (expect (clojure--valid-put-clojure-indent-call-p |
| 49 | + '(put-clojure-indent 'foo '(1 1)))) |
| 50 | + (expect (clojure--valid-put-clojure-indent-call-p |
| 51 | + '(put-clojure-indent 'foo '(2 :form :form (1)))))) |
| 52 | + (it "should reject invalid forms" |
| 53 | + (expect (clojure--valid-put-clojure-indent-call-p |
| 54 | + '(put-clojure-indent 1 1)) |
| 55 | + :to-throw 'error) |
| 56 | + (expect (clojure--valid-put-clojure-indent-call-p |
| 57 | + '(put-clojure-indent 'foo :foo)) |
| 58 | + :to-throw 'error) |
| 59 | + (expect (clojure--valid-put-clojure-indent-call-p |
| 60 | + '(put-clojure-indent 'foo (:defn))) |
| 61 | + :to-throw 'error) |
| 62 | + (expect (clojure--valid-put-clojure-indent-call-p |
| 63 | + '(put-clojure-indent 'foo '(:foo))) |
| 64 | + :to-throw 'error) |
| 65 | + (expect (clojure--valid-put-clojure-indent-call-p |
| 66 | + '(put-clojure-indent 'foo '(1 :foo))) |
| 67 | + :to-throw 'error) |
| 68 | + (expect (clojure--valid-put-clojure-indent-call-p |
| 69 | + '(put-clojure-indent 'foo '(1 "foo"))) |
| 70 | + :to-throw 'error))) |
| 71 | + |
| 72 | +(provide 'clojure-mode-safe-eval-test) |
| 73 | + |
| 74 | +;;; clojure-mode-safe-eval-test.el ends here |
0 commit comments