Skip to content

Commit 587c7ef

Browse files
committed
lispy-test.el: allow for tests that start with "o"
* lispy-test.el (lispy--unalias-key): Improve. Update various tests to the key binding style.
1 parent 69dfe05 commit 587c7ef

File tree

1 file changed

+30
-29
lines changed

1 file changed

+30
-29
lines changed

lispy-test.el

+30-29
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,20 @@
101101
"Emulate pressing keys decoded from SEQ."
102102
(if (vectorp seq)
103103
(lispy--unalias-key seq)
104-
(let ((keys (lispy-decode-keysequence seq))
104+
(let ((lkeys (lispy-decode-keysequence seq))
105105
key)
106-
(while (setq key (pop keys))
106+
(while (setq key (pop lkeys))
107107
(if (numberp key)
108108
(let ((current-prefix-arg (list key)))
109-
(when keys
110-
(lispy--unalias-key (pop keys))))
109+
(when lkeys
110+
(lispy--unalias-key (pop lkeys))))
111111
(lispy--unalias-key key))))))
112112

113113
(defun lispy--unalias-key (key)
114114
"Call command that corresponds to KEY.
115115
Insert KEY if there's no command."
116-
(let ((cmd (cdr (assoc 'lispy-mode (minor-mode-key-binding key)))))
116+
(let ((cmd (cdr (or (assoc 'lispy-mode (minor-mode-key-binding key))
117+
(assoc 'lispy-other-mode (minor-mode-key-binding key))))))
117118
(if (or (and cmd (or (looking-at lispy-left)
118119
(looking-back lispy-right)
119120
(looking-at lispy-outline)
@@ -718,10 +719,10 @@ Insert KEY if there's no command."
718719
"\"a series| of strings\""))
719720
(should (string= (lispy-with "\"a series|\"\n \" of strings\"" (kbd "M-J"))
720721
"\"a series| of strings\""))
721-
(should (string= (lispy-with "\"a s|eries|\"\n \" of strings\"" (kbd "M-J"))
722-
"\"a s|eries| of strings\""))
723-
(should (string= (lispy-with "|\"a s|eries|\"\n \" of strings\"" (kbd "M-J"))
724-
"|\"a s|eries| of strings\"")))
722+
(should (string= (lispy-with "\"a series|\"\n \" of strings\"" (kbd "M-J"))
723+
"\"a series| of strings\""))
724+
(should (string= (lispy-with "|\"a series\"\n \" of strings\"" (kbd "M-J"))
725+
"|\"a series of strings\"")))
725726

726727
(ert-deftest lispy-split ()
727728
(should (string= (lispy-with "(foo |bar)" (kbd "M-j"))
@@ -764,8 +765,8 @@ Insert KEY if there's no command."
764765
(should (string= (lispy-with "((a) |(b) (c))" "mjw")
765766
"((a) ~(c)| (b))"))
766767
(should (string= (lispy-with "(foo b|ar)"
767-
(lispy-mark-symbol)
768-
(lispy-move-up 1))
768+
(kbd "M-m")
769+
"w")
769770
"(~bar| foo)"))
770771
(should (string= (lispy-with "(put :foo 1\n :bar 2\n |:baz '(1 2 3)~)"
771772
(lispy-move-up 2))
@@ -796,8 +797,8 @@ Insert KEY if there's no command."
796797
(should (string= (lispy-with "(|(a) (b) (c))" "m]s")
797798
"((c) ~(a) (b)|)"))
798799
(should (string= (lispy-with "(f|oo bar)"
799-
(lispy-mark-symbol)
800-
(lispy-move-down 1))
800+
(kbd "M-m")
801+
"s")
801802
"(bar ~foo|)"))
802803
(should (string= (lispy-with "(put :foo 1\n ~:baz '(1 2 3)|\n :bar 2)"
803804
(lispy-move-down 2))
@@ -964,19 +965,19 @@ Insert KEY if there's no command."
964965
"(->> [1 2 3 4 5]\n (map sqr)\n (filter odd?))|")))
965966

966967
(ert-deftest lispy-mark ()
967-
(should (string= (lispy-with "|;; abc\n;; def\n;; ghi" (lispy-mark))
968+
(should (string= (lispy-with "|;; abc\n;; def\n;; ghi" (kbd "C-M-,"))
968969
"~;; abc\n;; def\n;; ghi|"))
969-
(should (string= (lispy-with ";; a|bc\n;; def\n;; ghi" (lispy-mark))
970+
(should (string= (lispy-with ";; a|bc\n;; def\n;; ghi" (kbd "C-M-,"))
970971
"~;; abc\n;; def\n;; ghi|"))
971-
(should (string= (lispy-with ";; abc\n|;; def\n;; ghi" (lispy-mark))
972+
(should (string= (lispy-with ";; abc\n|;; def\n;; ghi" (kbd "C-M-,"))
972973
"~;; abc\n;; def\n;; ghi|"))
973-
(should (string= (lispy-with ";; abc\n;; def\n;; ghi|" (lispy-mark))
974+
(should (string= (lispy-with ";; abc\n;; def\n;; ghi|" (kbd "C-M-,"))
974975
"~;; abc\n;; def\n;; ghi|")))
975976

976977
(ert-deftest lispy-mark-symbol ()
977-
(should (string= (lispy-with "(foo |\"bar\")" (lispy-mark-symbol))
978+
(should (string= (lispy-with "(foo |\"bar\")" (kbd "M-m"))
978979
"(foo ~\"bar\"|)"))
979-
(should (string= (lispy-with "(foo \"bar|\")" (lispy-mark-symbol))
980+
(should (string= (lispy-with "(foo \"bar|\")" (kbd "M-m"))
980981
"(foo ~\"bar\"|)"))
981982
(should (string= (lispy-with "(mapc #'ta|unt knights)" (kbd "M-m"))
982983
"(mapc ~#'taunt| knights)")))
@@ -1065,17 +1066,17 @@ Insert KEY if there's no command."
10651066
"(defun foo ()\n |)")))
10661067

10671068
(ert-deftest lispy-up-slurp ()
1068-
(should (string= (lispy-with "(progn\n (foo))\n|(bar)" (lispy-up-slurp))
1069+
(should (string= (lispy-with "(progn\n (foo))\n|(bar)" "ok")
10691070
"(progn\n (foo)\n |(bar))"))
1070-
(should (string= (lispy-with "(progn\n (foo))\n(bar)|" (lispy-up-slurp))
1071+
(should (string= (lispy-with "(progn\n (foo))\n(bar)|" "ok")
10711072
"(progn\n (foo)\n (bar)|)"))
1072-
(should (string= (lispy-with "(progn\n (foo))\n~(bar)|" (lispy-up-slurp))
1073+
(should (string= (lispy-with "(progn\n (foo))\n~(bar)|" "ok")
10731074
"(progn\n (foo)\n ~(bar)|)"))
1074-
(should (string= (lispy-with "(progn\n (foo))\n|(bar)~" (lispy-up-slurp))
1075+
(should (string= (lispy-with "(progn\n (foo))\n|(bar)~" "ok")
10751076
"(progn\n (foo)\n |(bar)~)"))
1076-
(should (string= (lispy-with "(progn\n (foo))\n|(bar)\n(baz)~" (lispy-up-slurp))
1077+
(should (string= (lispy-with "(progn\n (foo))\n|(bar)\n(baz)~" "ok")
10771078
"(progn\n (foo)\n |(bar)\n (baz)~)"))
1078-
(should (string= (lispy-with "(progn\n (foo))\n~(bar)\n(baz)|" (lispy-up-slurp))
1079+
(should (string= (lispy-with "(progn\n (foo))\n~(bar)\n(baz)|" "ok")
10791080
"(progn\n (foo)\n ~(bar)\n (baz)|)")))
10801081

10811082
(ert-deftest lispy-tab ()
@@ -1129,11 +1130,11 @@ Insert KEY if there's no command."
11291130
"(progn ,@(cdr re)|)")))
11301131

11311132
(ert-deftest lispy-mark-car ()
1132-
(should (string= (lispy-with "|\"foo\"~" (lispy-mark-car))
1133+
(should (string= (lispy-with "|\"foo\"~" "i")
11331134
"\"~foo|\""))
1134-
(should (string= (lispy-with "~'(\n foo)|" (lispy-mark-car))
1135+
(should (string= (lispy-with "~'(\n foo)|" "i")
11351136
"'(\n ~foo|)"))
1136-
(should (string= (lispy-with "|'(\n foo)~" (lispy-mark-car))
1137+
(should (string= (lispy-with "|'(\n foo)~" "i")
11371138
"'(\n ~foo|)"))
11381139
(should (string= (lispy-with
11391140
"|(add-to-list 'auto-mode-alist '(\"\\\\.cache\\\\'\" . emacs-lisp-mode))"
@@ -1196,7 +1197,7 @@ Insert KEY if there's no command."
11961197

11971198
(ert-deftest lispy-other-space ()
11981199
(should (string= (lispy-with "(foo (bar (baz)|))"
1199-
(lispy-other-space))
1200+
"o ")
12001201
"(foo (bar (baz |)))")))
12011202

12021203
(ert-deftest lispy-beginning-of-defun ()

0 commit comments

Comments
 (0)