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

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

[nongnu] elpa/with-simulated-input 1006e93000 125/134: Add more tests to


From: ELPA Syncer
Subject: [nongnu] elpa/with-simulated-input 1006e93000 125/134: Add more tests to improve coverage
Date: Mon, 10 Jan 2022 23:00:13 -0500 (EST)

branch: elpa/with-simulated-input
commit 1006e930002aef4635c473dda16905c1e336ff64
Author: Ryan C. Thompson <rct@thompsonclan.org>
Commit: Ryan C. Thompson <rct@thompsonclan.org>

    Add more tests to improve coverage
---
 tests/test-with-simulated-input.el | 37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/tests/test-with-simulated-input.el 
b/tests/test-with-simulated-input.el
index 8d25db21bd..8675c9a686 100644
--- a/tests/test-with-simulated-input.el
+++ b/tests/test-with-simulated-input.el
@@ -28,7 +28,23 @@ from byte-compiled code."
     (expect
      (let ((wsi-last-used-next-action-bind nil))
        (wsi-get-unbound-key "" '("abc" "123")))
-     :to-throw 'error)))
+     :to-throw 'error))
+  (it "should find a new key when its previously chosen key becomes bound"
+    (let ((overriding-terminal-local-map (make-sparse-keymap))
+          (previous-key (wsi-get-unbound-key)))
+      (define-key overriding-terminal-local-map
+        (kbd previous-key) #'ignore)
+      ;; Claim another few unbound keys as well, just for good
+      ;; measure.
+      (define-key overriding-terminal-local-map
+        (kbd (wsi-get-unbound-key)) #'ignore)
+      (define-key overriding-terminal-local-map
+        (kbd (wsi-get-unbound-key)) #'ignore)
+      (define-key overriding-terminal-local-map
+        (kbd (wsi-get-unbound-key)) #'ignore)
+      (expect
+       (wsi-get-unbound-key)
+       :not :to-equal previous-key))))
 
 (defmacro progn-at-runtime (&rest body)
   "Like `progn', but evaluate BODY entirely at runtime.
@@ -434,8 +450,27 @@ during macro expansion will be caught as well."
              :to-be t))
     (expect-warning
      (expect (with-simulated-input "Is SPC anybody SPC listening? RET" 1 2 3)
+             :to-equal 3))
+    (expect-warning
+     (expect (let ((x (+ 1 2)))
+               (with-simulated-input "Is SPC anybody SPC listening? RET" x))
              :to-equal 3)))
 
+  (it "should work when `overriding-terminal-local-map' is bound"
+    (let ((overriding-terminal-local-map (make-sparse-keymap)))
+      ;; Claim the first few unbound keys to force
+      ;; `with-simulated-input' to find a new one.
+      (define-key overriding-terminal-local-map
+        (kbd (wsi-get-unbound-key)) #'ignore)
+      (define-key overriding-terminal-local-map
+        (kbd (wsi-get-unbound-key)) #'ignore)
+      (define-key overriding-terminal-local-map
+        (kbd (wsi-get-unbound-key)) #'ignore)
+      (expect
+       (with-simulated-input "hello RET"
+         (read-string "Enter a string: "))
+       :to-equal "hello")))
+
   (describe "used with `completing-read'"
 
     :var (completing-read-function)



reply via email to

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