-;; URL: http://github.com/clojure-emacs/inf-clojure
-;; Keywords: processes, clojure
-;; Package-Requires: ((emacs "24.4") (clojure-mode "5.3"))
;; This file is not part of GNU Emacs.
@@ -25,16 +22,14 @@
;;; Commentary:
;;
-;; Code completion using alexander-yakushev/compliment.
+;; Tests for inf-clojure.
;;; Code:
-;; Tests for inf-clojure.el
-
(message "Running tests on Emacs %s" emacs-version)
(require 'buttercup)
-(require 'assess)
+(require 'assess) ;; requires Emacs 26, due to a dependency on seq.el
(require 'inf-clojure)
(cl-defmacro ict-with-assess-buffers ((&rest varlist) &body body)
@@ -53,91 +48,105 @@
(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" ()
+(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"))))
+ (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"))))
+ (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"))))
+ (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"))))
+ (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"))))
+ (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))))
+ (ict-with-assess-buffers
+ ((a (insert "@")))
+ (with-current-buffer a
+ (expect (inf-clojure-completion-bounds-of-expr-at-point)
+ :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"))))
+ (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")))))
+ (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")))))
-(describe "inf-clojure--make-single-line"
- (it "replaces newlines with whitespace"
- (expect (inf-clojure--make-single-line "(do\n(println \"hello world\")\n)") :to-equal "(do (println \"hello world\") )"))
+(describe "inf-clojure--sanitize-command"
+ (it "sanitizes the command correctly"
+ (expect (inf-clojure--sanitize-command "(doc println)") :to-equal "(doc println)\n"))
- (it "does not leave whitespace at the end"
- (expect (inf-clojure--make-single-line "(do\n(println \"hello world\")\n)\n\n") :to-equal "(do (println \"hello world\") )"))
+ (it "trims newline at the right of a command"
+ (expect (inf-clojure--sanitize-command "(doc println)\n\n\n\n") :to-equal "(doc println)\n"))
- (it "returns empty string when the line is only newlines"
- (expect (inf-clojure--make-single-line "\n\n\n\n") :to-equal ""))
+ (it "returns empty string when the command is empty"
+ (expect (inf-clojure--sanitize-command " ") :to-equal ""))
- (it "removes comments when on their own line"
- (expect (inf-clojure--make-single-line "(do\n(println \"hello world\")\n ;; remove me\n)") :to-equal "(do (println \"hello world\") )"))
+ (it "only removes whitespace at the end of the command - fix 152"
+ (expect (inf-clojure--sanitize-command "1 5") :to-equal "1 5\n")))
- (it "preserves newlines of inline comments"
- (expect (inf-clojure--make-single-line "(do\n(println \"hello world\") ;; don't remove this\n)") :to-equal "(do (println \"hello world\") ;; don't remove this\n )"))
+(describe "inf-clojure--forms-without-newlines"
+ (it "removes newlines between toplevel forms"
+ (expect (inf-clojure--forms-without-newlines
+ "(def foo 3)\n\n\n(def bar 4)")
+ :to-equal "(def foo 3)\n(def bar 4)"))
+ (it "doesn't remove newlines inside forms or strings"
+ (expect (inf-clojure--forms-without-newlines
+ "
- )
+(defn foo []
-(describe "inf-clojure--sanitize-command"
- (it "sanitizes the command correctly"
- (expect (inf-clojure--sanitize-command "(doc println)") :to-equal "(doc println)\n"))
+ :foo)
- (it "trims newline at the right of a command"
- (expect (inf-clojure--sanitize-command "(doc println)\n\n\n\n") :to-equal "(doc println)\n"))
- (it "returns empty string when the command is empty"
- (expect (inf-clojure--sanitize-command " ") :to-equal "")))
+(def thing \"this
+
+is a string\")
+
+(defn bar [])")
+ ;; note no leading newline, newlines inside defn remain,
+ ;; newlines inside string remain
+ :to-equal "(defn foo []
+
+ :foo)
+(def thing \"this
+
+is a string\")
+(defn bar [])")))
+
(describe "inf-clojure--update-feature"
(it "updates new forms correctly"
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy