|
| 1 | +;;; clojure-mode-util-test.el --- Clojure Mode: util test suite -*- lexical-binding: t; -*- |
| 2 | + |
| 3 | +;; Copyright (C) 2014-2015 Bozhidar Batsov <bozhidar@batsov.com> |
| 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 | +(require 'clojure-mode) |
| 26 | +(require 'cl-lib) |
| 27 | +(require 'ert) |
| 28 | + |
| 29 | +(let ((project-dir "/home/user/projects/my-project/") |
| 30 | + (clj-file-path "/home/user/projects/my-project/src/clj/my_project/my_ns/my_file.clj") |
| 31 | + (project-relative-clj-file-path "src/clj/my_project/my_ns/my_file.clj") |
| 32 | + (clj-file-ns "my-project.my-ns.my-file")) |
| 33 | + |
| 34 | + (ert-deftest project-relative-path () |
| 35 | + :tags '(utils) |
| 36 | + (cl-letf (((symbol-function 'clojure-project-dir) (lambda () project-dir))) |
| 37 | + (should (string= (clojure-project-relative-path clj-file-path) |
| 38 | + project-relative-clj-file-path)))) |
| 39 | + |
| 40 | + (ert-deftest expected-ns () |
| 41 | + :tags '(utils) |
| 42 | + (cl-letf (((symbol-function 'clojure-project-relative-path) |
| 43 | + (lambda (&optional current-buffer-file-name) |
| 44 | + project-relative-clj-file-path))) |
| 45 | + (should (string= (clojure-expected-ns clj-file-path) clj-file-ns))))) |
| 46 | + |
| 47 | +(provide 'clojure-mode-util-test) |
| 48 | + |
| 49 | +;; Local Variables: |
| 50 | +;; indent-tabs-mode: nil |
| 51 | +;; End: |
| 52 | + |
| 53 | +;;; clojure-mode-util-test.el ends here |
0 commit comments