|
| 1 | +;;; clojure-mode-syntax-test.el --- Clojure Mode: syntax related tests -*- lexical-binding: t; -*- |
| 2 | + |
| 3 | +;; Copyright (C) 2015-2016 Bozhidar Batsov <[email protected]> |
| 4 | + |
| 5 | +;; This file is not part of GNU Emacs. |
| 6 | + |
| 7 | +;; This program 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 | +;; This program 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 this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | + |
| 20 | +;;; Commentary: |
| 21 | + |
| 22 | +;; The unit test suite of Clojure Mode |
| 23 | + |
| 24 | +;;; Code: |
| 25 | + |
| 26 | +(require 'clojure-mode) |
| 27 | +(require 'ert) |
| 28 | + |
| 29 | +(defun non-func (form-a form-b) |
| 30 | + (with-temp-buffer |
| 31 | + (clojure-mode) |
| 32 | + (insert form-a) |
| 33 | + (save-excursion (insert form-b)) |
| 34 | + (clojure--not-function-form-p))) |
| 35 | + |
| 36 | +(ert-deftest non-function-form () |
| 37 | + (dolist (form '(("#?@ " "(c d)") |
| 38 | + ("#?@" "(c d)") |
| 39 | + ("#? " "(c d)") |
| 40 | + ("#?" "(c d)") |
| 41 | + ("" "[asda]") |
| 42 | + ("" "{a b}") |
| 43 | + ("#" "{a b}") |
| 44 | + ("" "(~)"))) |
| 45 | + (should (apply #'non-func form))) |
| 46 | + (dolist (form '("(c d)" |
| 47 | + "(.c d)" |
| 48 | + "(:c d)" |
| 49 | + "(c/a d)" |
| 50 | + "(.c/a d)" |
| 51 | + "(:c/a d)" |
| 52 | + "(c/a)" |
| 53 | + "(:c/a)" |
| 54 | + "(.c/a)")) |
| 55 | + (should-not (non-func "" form)) |
| 56 | + (should-not (non-func "^hint" form)) |
| 57 | + (should-not (non-func "#macro" form)) |
| 58 | + (should-not (non-func "^hint " form)) |
| 59 | + (should-not (non-func "#macro " form)))) |
| 60 | + |
| 61 | +(ert-deftest clojure-syntax-prefixed-symbols () |
| 62 | + (dolist (form '(("#?@aaa" . "aaa") |
| 63 | + ("#?aaa" . "?aaa") |
| 64 | + ("#aaa" . "aaa") |
| 65 | + ("'aaa" . "aaa"))) |
| 66 | + (with-temp-buffer |
| 67 | + (clojure-mode) |
| 68 | + (insert (car form)) |
| 69 | + (equal (symbol-name (symbol-at-point)) (cdr form))))) |
| 70 | + |
| 71 | +(ert-deftest clojure-syntax-skip-prefixes () |
| 72 | + (dolist (form '("#?@aaa" "#?aaa" "#aaa" "'aaa")) |
| 73 | + (with-temp-buffer |
| 74 | + (clojure-mode) |
| 75 | + (insert form) |
| 76 | + (backward-word) |
| 77 | + (backward-prefix-chars) |
| 78 | + (should (bobp))))) |
| 79 | + |
| 80 | +(provide 'clojure-mode-syntax-test) |
0 commit comments