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

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

[nongnu] elpa/bind-map 76b8e2ab6c 85/97: Add tests for inheritance


From: ELPA Syncer
Subject: [nongnu] elpa/bind-map 76b8e2ab6c 85/97: Add tests for inheritance
Date: Thu, 20 Jan 2022 07:59:28 -0500 (EST)

branch: elpa/bind-map
commit 76b8e2ab6c5d5e105eb5d83686e0b552fe029550
Author: justbur <justin@burkett.cc>
Commit: justbur <justin@burkett.cc>

    Add tests for inheritance
---
 bind-map-tests.el | 77 +++++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 60 insertions(+), 17 deletions(-)

diff --git a/bind-map-tests.el b/bind-map-tests.el
index c83149cf2d..3736725957 100644
--- a/bind-map-tests.el
+++ b/bind-map-tests.el
@@ -41,30 +41,33 @@
         tmpmap2-active
         tmpmap2-prefix
         bind-map-major-modes-alist
+        minor-mode-alist
         minor-mode-map-alist)
-    (bind-map tmpmap2
-      :major-modes (emacs-lisp-mode)
-      :keys ("C-a")
-      :evil-keys ("a")
-      :evil-states (motion))
-    (evil-normalize-keymaps)
-    (emacs-lisp-mode)
-    (define-key tmpmap2 "a" "b")
-    (message "%s" (pp bind-map-major-modes-alist))
-    (should (equal (cdr (assoc 'tmpmap2-active bind-map-major-modes-alist))
-                   '(emacs-lisp-mode)))
-    (should tmpmap2-active)
-    (should (string= (key-binding "\C-aa") "b"))
-    (should (keymapp (lookup-key (evil-get-auxiliary-keymap tmpmap2-root-map 
'motion) "a")))
-    (should (string= (lookup-key (evil-get-auxiliary-keymap tmpmap2-root-map 
'motion) "aa") "b"))
-    (should (string= "b" (key-binding "\C-aa")))))
+    (with-temp-buffer
+      (bind-map tmpmap2
+        :major-modes (emacs-lisp-mode)
+        :keys ("C-a")
+        :evil-keys ("a")
+        :evil-states (motion))
+      (evil-normalize-keymaps)
+      (emacs-lisp-mode)
+      (define-key tmpmap2 "a" "b")
+      (message "%s" (pp bind-map-major-modes-alist))
+      (should (equal (cdr (assoc 'tmpmap2-active bind-map-major-modes-alist))
+                     '(emacs-lisp-mode)))
+      (should tmpmap2-active)
+      (should (string= (key-binding "\C-aa") "b"))
+      (should (keymapp (lookup-key (evil-get-auxiliary-keymap tmpmap2-root-map 
'motion) "a")))
+      (should (string= (lookup-key (evil-get-auxiliary-keymap tmpmap2-root-map 
'motion) "aa") "b"))
+      (should (string= "b" (key-binding "\C-aa"))))))
 
 (ert-deftest bind-map-test-minor-mode-keys ()
   "Test binding for minor-modes."
   (let ((tmpmap3 (make-sparse-keymap))
         (tmpmap3-root-map (make-sparse-keymap))
         (fake-minor-mode t)
-        minor-mode-map-alist)
+        minor-mode-map-alist
+        minor-mode-alist)
     (bind-map tmpmap3
       :minor-modes (fake-minor-mode)
       :keys ("C-a")
@@ -86,3 +89,43 @@
       :major-modes (mm6))
     (should (equal (cdr (assq 'tmpmap4-active bind-map-major-modes-alist))
                    '(mm1 mm2 mm3 mm4 mm5 mm6)))))
+
+(ert-deftest bind-map-test-minor-mode-inheritance ()
+  (with-temp-buffer
+    (let ((tmpmap5 (make-sparse-keymap))
+          (tmpmap6 (make-sparse-keymap))
+          (fake-minor-mode t)
+          minor-mode-alist
+          minor-mode-map-alist)
+      (bind-map tmpmap5
+        :keys ("C-a")
+        :evil-keys ("a")
+        :evil-states (normal))
+      (bind-map-for-mode-inherit tmpmap6 tmpmap5
+        :minor-modes (fake-minor-mode))
+      (define-key tmpmap6 "a" 'asdf)
+      (should (string= (key-binding "\C-aa") 'asdf))
+      (evil-local-mode 1)
+      (evil-motion-state)
+      (message "%s" evil-state)
+      (should (string= (key-binding "aa") 'asdf)))))
+
+(ert-deftest bind-map-test-major-mode-inheritance ()
+  (with-temp-buffer
+    (let ((tmpmap7 (make-sparse-keymap))
+          (tmpmap8 (make-sparse-keymap))
+          minor-mode-alist
+          minor-mode-map-alist)
+      (bind-map tmpmap7
+        :keys ("C-a")
+        :evil-keys ("a")
+        :evil-states (normal))
+      (bind-map-for-mode-inherit tmpmap8 tmpmap7
+        :major-modes (emacs-lisp-mode))
+      (define-key tmpmap8 "a" 'asdf)
+      (evil-normalize-keymaps)
+      (emacs-lisp-mode)
+      (should (string= (key-binding "\C-aa") 'asdf))
+      (evil-local-mode 1)
+      (evil-motion-state)
+      (should (string= (key-binding "aa") 'asdf)))))



reply via email to

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