branch: elpa/inf-clojure commit 803a419de6cff6515fbb10644dd1e85df801883e Author: Andrea Richiardi <a.richiardi.w...@gmail.com> Commit: Bozhidar Batsov <bozhidar.bat...@gmail.com>
Add test harness (finally?) This patch add ert test harness and some tests around the inf-clojure-completion-bounds-of-expr-at-point function. --- .gitignore | 12 +++++ .travis.yml | 17 +++++++ Cask | 11 +++++ test/inf-clojure-tests.el | 114 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 154 insertions(+) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c724233 --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +*~ +*\#*\# +*.\#* +*.elc +.cask +elpa* +.depend +TAGS +.DS_STORE +dist +.vagrant/ +.dir-locals?.el diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..57ec6dd --- /dev/null +++ b/.travis.yml @@ -0,0 +1,17 @@ +language: generic +sudo: false +before_install: + - curl -fsSkL https://gist.github.com/rejeep/ebcd57c3af83b049833b/raw > x.sh && source ./x.sh + - evm install $EVM_EMACS --use --skip + - cask +env: + - EVM_EMACS=emacs-24.3-travis + - EVM_EMACS=emacs-24.4-travis + - EVM_EMACS=emacs-24.5-travis + - EVM_EMACS=emacs-25.1-travis + - EVM_EMACS=emacs-25.2-travis + - EVM_EMACS=emacs-25.3-travis +script: + - emacs --version + - cask install + - cask exec buttercup -L . diff --git a/Cask b/Cask new file mode 100644 index 0000000..d2a5667 --- /dev/null +++ b/Cask @@ -0,0 +1,11 @@ +(source gnu) +(source melpa) + +(package-file "inf-clojure.el") + +(files "*.el" (:exclude ".dir-locals.el")) + +(development + (depends-on "clojure-mode") + (depends-on "buttercup") + (depends-on "assess")) diff --git a/test/inf-clojure-tests.el b/test/inf-clojure-tests.el new file mode 100644 index 0000000..994801c --- /dev/null +++ b/test/inf-clojure-tests.el @@ -0,0 +1,114 @@ +;;; inf-clojure-tests.el --- Tests for Inf-Clojure -*- lexical-binding: t; -*- +;; +;; Copyright © 2014-2018 Bozhidar Batsov + +;; Authors: Bozhidar Batsov <bozhi...@batsov.com> +;; Andrea Richiardi <a.richiardi.w...@gmail.com> +;; URL: http://github.com/clojure-emacs/inf-clojure +;; Keywords: processes, clojure +;; Package-Requires: ((emacs "24.4") (clojure-mode "5.3")) + +;; This file is part of GNU Emacs. + +;; GNU Emacs 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. + +;; GNU Emacs 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 GNU Emacs. If not, see <http://www.gnu.org/licenses/>. + +;;; Commentary: +;; +;; Code completion using alexander-yakushev/compliment. + +;;; Code: + +;; Tests for inf-clojure.el + +(message "Running tests on Emacs %s" emacs-version) + +(require 'buttercup) +(require 'assess) +(require 'inf-clojure) + +(cl-defmacro ict-with-assess-buffers ((&rest varlist) &body body) + `(assess-with-temp-buffers (,@varlist) + (clojure-mode) + (inf-clojure-minor-mode) + ,@body)) + +(defun ict-bounds-string (bounds) + (buffer-substring (car bounds) (cdr bounds))) + +(describe "inf-clojure--kw-to-symbol" + (it "returns symbol form of the given keyword" + (expect (inf-clojure--kw-to-symbol "symbol") :to-equal "symbol") + (expect (inf-clojure--kw-to-symbol ":clj.core/str") :to-equal "clj.core/str") + (expect (inf-clojure--kw-to-symbol "::keyword") :to-equal "keyword") + (expect (inf-clojure--kw-to-symbol nil) :to-equal nil))) + +(describe "completion bounds at point" () + (it "computes bounds for plain-text" + (ict-with-assess-buffers + ((a (insert "plain-text"))) + (with-current-buffer a + (expect (ict-bounds-string (inf-clojure-completion-bounds-of-expr-at-point)) + :to-equal "plain-text")))) + + (it "computes bounds for @deref" + (ict-with-assess-buffers + ((a (insert "@deref"))) + (with-current-buffer a + (expect (ict-bounds-string (inf-clojure-completion-bounds-of-expr-at-point)) + :to-equal "deref")))) + + (it "computes bounds for ^:keyword" + (ict-with-assess-buffers + ((a (insert "^:keyword"))) + (with-current-buffer a + (expect (ict-bounds-string (inf-clojure-completion-bounds-of-expr-at-point)) + :to-equal ":keyword")))) + + (it "computes bounds for ::keyword" + (ict-with-assess-buffers + ((a (insert "::keyword"))) + (with-current-buffer a + (expect (ict-bounds-string (inf-clojure-completion-bounds-of-expr-at-point)) + :to-equal "::keyword")))) + + (it "computes bounds for [^:keyword (combined break chars and keyword)" + (ict-with-assess-buffers + ((a (insert "[^:keyword"))) + (with-current-buffer a + (expect (ict-bounds-string (inf-clojure-completion-bounds-of-expr-at-point)) + :to-equal ":keyword")))) + + (it "computes no bounds for point directly after a break expression" + (ict-with-assess-buffers + ((a (insert "@"))) + (with-current-buffer a + (expect + (ict-bounds-string (inf-clojure-completion-bounds-of-expr-at-point)) + :not :to-be nil)))) + + (it "computes bounds for [symbol" + (ict-with-assess-buffers + ((a (insert "[symbol"))) + (with-current-buffer a + (expect (ict-bounds-string (inf-clojure-completion-bounds-of-expr-at-point)) + :to-equal "symbol")))) + + (it "computes bounds for (@deref (multiple break chars)" + (ict-with-assess-buffers + ((a (insert "(@deref"))) + (with-current-buffer a + (expect (ict-bounds-string (inf-clojure-completion-bounds-of-expr-at-point)) + :to-equal "deref"))))) + +;;; inf-clojure-tests.el ends here