emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/smartparens 6a1d93d717 3/3: test: refactor clojure tests t


From: ELPA Syncer
Subject: [nongnu] elpa/smartparens 6a1d93d717 3/3: test: refactor clojure tests to have one assert per test
Date: Tue, 2 Apr 2024 16:00:49 -0400 (EDT)

branch: elpa/smartparens
commit 6a1d93d7170c8f35803cca3ea7b44dc5b2f30ecb
Author: Matus Goljer <matus.goljer@gmail.com>
Commit: Matus Goljer <matus.goljer@gmail.com>

    test: refactor clojure tests to have one assert per test
---
 test/smarparents-clojure-test.el  | 140 +++++++-------------------------------
 test/smartparens-commands-test.el |  28 +++++++-
 2 files changed, 50 insertions(+), 118 deletions(-)

diff --git a/test/smarparents-clojure-test.el b/test/smarparents-clojure-test.el
index ae30e6e7f1..f142ebef65 100644
--- a/test/smarparents-clojure-test.el
+++ b/test/smarparents-clojure-test.el
@@ -2,124 +2,30 @@
 (require 'smartparens-clojure)
 (require 'clojure-mode)
 
-(ert-deftest sp-test-clojure-slurp-with-prefix ()
-  "Ensure we correctly slurp over prefixed expressions."
-  (let ((before "(do|
-  (foo) #{...}
-  (foo) ^{:a 1}
-  (foo) #(xyzzy 1 2 %)
-  (foo) #_(comment reader macro)
-  (foo) ~unquote-me
-  (foo) `~'unquote-me
-  (foo) ~@(splice-me)
-  (foo) `(quote-me)
-  (foo) @(deref-me)
-  (foo) @deref-me
-  (foo) #?@(:clj [3 4] :cljs [5 6])
-  (foo) #?(:clj     Double/NaN
-           :cljs    js/NaN
-           :default nil))")
-        (after "(do
-  (foo #{...})
-  (foo ^{:a 1})
-  (foo #(xyzzy 1 2 %))
-  (foo #_(comment reader macro))
-  (foo ~unquote-me)
-  (foo `~'unquote-me)
-  (foo ~@(splice-me))
-  (foo `(quote-me))
-  (foo @(deref-me))
-  (foo @deref-me)
-  (foo #?@(:clj [3 4] :cljs [5 6]))
-  (foo #?(:clj     Double/NaN
-          :cljs    js/NaN
-          :default nil)))"))
-    (sp-test-with-temp-buffer before (clojure-mode)
-      (while (re-search-forward "(foo" nil t)
-        (sp-forward-slurp-sexp)
-        (forward-line))
-      (should (equal (buffer-string) after)))))
-
-(ert-deftest sp-test-clojure-wrap-with-prefix ()
+(sp-ert-deftest sp-test-clojure-wrap-with-prefix
+  :let ((sp-pairs sp--test-basic-pairs))
+  :mode 'clojure-mode
   "Ensure correct wrap-pair over prefixed expressions."
-  (let ((before "(do
-  |#{...}
-  ^{:a 1}
-  #(xyzzy 1 2 %)
-  #_(comment reader macro)
-  ~unquote-me
-  `~'unquote-me
-  ~@(splice-me)
-  `(quote-me)
-  @(deref-me)
-  @deref-me
-  #?@(:clj [3 4] :cljs [5 6])
-  #?(:clj     Double/NaN
+  (sp-test-kbd-macro "|#{...}M" "(" "(|#{...}M)")
+  (sp-test-kbd-macro "|^{:a 1}M" "(" "(|^{:a 1}M)")
+  (sp-test-kbd-macro "|#(xyzzy 1 2 %)M" "(" "(|#(xyzzy 1 2 %)M)")
+  (sp-test-kbd-macro "|#_(comment reader macro)M" "(" "(|#_(comment reader 
macro)M)")
+  (sp-test-kbd-macro "|~unquote-meM" "(" "(|~unquote-meM)")
+  (sp-test-kbd-macro "|`~'unquote-meM" "(" "(|`~'unquote-meM)")
+  (sp-test-kbd-macro "|~@(splice-me)M" "(" "(|~@(splice-me)M)")
+  (sp-test-kbd-macro "|`(quote-me)M" "(" "(|`(quote-me)M)")
+  (sp-test-kbd-macro "|@(deref-me)M" "(" "(|@(deref-me)M)")
+  (sp-test-kbd-macro "|@deref-meM" "(" "(|@deref-meM)")
+  (sp-test-kbd-macro "|#?@(:clj [3 4] :cljs [5 6])M" "(" "(|#?@(:clj [3 4] 
:cljs [5 6])M)")
+  (sp-test-kbd-macro "|#?(:clj     Double/NaN
+     :cljs    js/NaN
+     :default nil)M" "(" "(|#?(:clj     Double/NaN
      :cljs    js/NaN
-     :default nil))")
-        (after "(do
-  (#{...})
-  (^{:a 1})
-  (#(xyzzy 1 2 %))
-  (#_(comment reader macro))
-  (~unquote-me)
-  (`~'unquote-me)
-  (~@(splice-me))
-  (`(quote-me))
-  (@(deref-me))
-  (@deref-me)
-  (#?@(:clj [3 4] :cljs [5 6]))
-  (#?(:clj     Double/NaN
-      :cljs    js/NaN
-      :default nil)))"))
-    (sp-test-with-temp-buffer before (clojure-mode)
-      (while (< (current-column) 3)
-        (sp-wrap-with-pair "(")
-        (forward-line)
-        ;; FIXME: sp-wrap-with-pair keeps region active for no clear reason
-        (deactivate-mark)
-        (back-to-indentation))
-      (should (equal (buffer-string) after)))))
+     :default nil)M)"))
 
-(ert-deftest sp-test-clojure-wrap-with-fence-prefix ()
+(sp-ert-deftest sp-test-clojure-wrap-with-fence-prefix
+    :let ((sp-pairs sp--test-basic-pairs))
+  :mode 'clojure-mode
   "Ensure correct wrap-pair over #-prefixed expressions."
-  (let ((before "(do
-  |#\"...\"
-  #~xyzzy)")
-        (after "(do
-  (#\"...\")
-  (#~xyzzy))"))
-    (sp-test-with-temp-buffer before (clojure-mode)
-      (while (not (eobp))
-        (back-to-indentation)
-        (sp-wrap-with-pair "(")
-        (forward-line)
-        ;; FIXME: sp-wrap-with-pair keeps region active
-        (deactivate-mark))
-      (should (equal (buffer-string) after)))))
-
-;; FIXME: fails
-;; (ert-deftest sp-test-clojure-barf-with-fence-prefix ()
-;;   "Ensure correct forward-barf over #-prefixed expressions."
-;;   (let ((before "(do|
-;;   (#{...})
-;;   (#(xyzzy 1 2 %))
-;;   (#_(comment reader macro))
-;;   (#?@(:clj [3 4] :cljs [5 6]))
-;;   (#?(:clj     Double/NaN
-;;       :cljs    js/NaN
-;;       :default nil)))")
-;;         (after "(do
-;;   ()#{...}
-;;   ()#(xyzzy 1 2 %)
-;;   ()#_(comment reader macro)
-;;   ()#?@(:clj [3 4] :cljs [5 6])
-;;   ()#?(:clj     Double/NaN
-;;       :cljs    js/NaN
-;;       :default nil))"))
-;;     (sp-test-with-temp-buffer before (clojure-mode)
-;;       (while (re-search-forward "(#" nil t)
-;;         (backward-char)
-;;         (sp-forward-barf-sexp)
-;;         (forward-line))
-;;       (should (equal (buffer-string) after)))))
+  (sp-test-kbd-macro "|#\"...\"M" "(" "(#\"...\")")
+  (sp-test-kbd-macro "|#~xyzzyM" "(" "(#~xyzzy)"))
diff --git a/test/smartparens-commands-test.el 
b/test/smartparens-commands-test.el
index e9040707ac..3e43b7f72a 100644
--- a/test/smartparens-commands-test.el
+++ b/test/smartparens-commands-test.el
@@ -276,7 +276,23 @@ be."
     ("(f|oo)  #'(bar)" "(f|oo  #'(bar))"))
    (((sp-sexp-prefix '((emacs-lisp-mode regexp "\\(?:['`]*,@?\\|[',`]\\)"))))
     ("(fo|o) `',(bar)" "(fo|o `',(bar))")
-    ("(fo|o) ,@(bar)" "(fo|o ,@(bar))"))))
+    ("(fo|o) ,@(bar)" "(fo|o ,@(bar))"))
+   (((mode 'clojure))
+    ;; was sp-test-clojure-slurp-with-prefix
+    ("(foo|) #{...}" "(foo| #{...})")
+    ("(foo|) ^{:a 1}" "(foo| ^{:a 1})")
+    ("(foo|) #(xyzzy 1 2 %)" "(foo| #(xyzzy 1 2 %))")
+    ("(foo|) #_(comment reader macro)" "(foo| #_(comment reader macro))")
+    ("(foo|) ~unquote-me" "(foo| ~unquote-me)")
+    ("(foo|) `~'unquote-me" "(foo| `~'unquote-me)")
+    ("(foo|) ~@(splice-me)" "(foo| ~@(splice-me))")
+    ("(foo|) `(quote-me)" "(foo| `(quote-me))")
+    ("(foo|) @(deref-me)" "(foo| @(deref-me))")
+    ("(foo|) @deref-me" "(foo| @deref-me)")
+    ("(foo|) #?@(:clj [3 4] :cljs [5 6])" "(foo| #?@(:clj [3 4] :cljs [5 6]))")
+    ("(foo|) #?(:clj Double/NaN\n :cljs js/NaN\n :default nil)"
+     ;; longer because slurp causes "autoformat"
+     "(foo| #?(:clj Double/NaN\n        :cljs js/NaN\n        :default 
nil))"))))
 
 (sp-test-command sp-backward-slurp-sexp
   ((nil
@@ -307,6 +323,16 @@ be."
     ("(foo)\nbar ;; baz (f|oo baz)\n(quux)"
      "(foo)\nbar ;; baz (f|oo) baz\n(quux)"))
 
+   (((mode 'clojure))
+    ("(|#{...})" "(|)#{...}")
+    ("(|#(xyzzy 1 2 %))" "(|)#(xyzzy 1 2 %)")
+    ("(|#_(comment reader macro))" "(|)#_(comment reader macro)")
+    ("(|#?@(:clj [3 4] :cljs [5 6]))" "(|)#?@(:clj [3 4] :cljs [5 6])")
+    ("(|#?(:clj     Double/NaN
+      :cljs    js/NaN
+      :default nil))"
+     "(|)#?(:clj     Double/NaN\n     :cljs    js/NaN\n     :default nil)"))
+
    (((mode 'racket)
      (sp-sexp-prefix '((racket-mode regexp "#?['`,]@?"))))
     ("(f|oo  #'(bar))" "(f|oo)  #'(bar)"))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]