2015-09-26 04:26:16 +00:00
|
|
|
;;; core-evilified-state-ftest.el --- Spacemacs Functional Test File
|
2015-06-30 04:06:39 +00:00
|
|
|
;;
|
2021-03-22 20:11:29 +00:00
|
|
|
;; Copyright (c) 2012-2021 Sylvain Benner & Contributors
|
2015-06-30 04:06:39 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
2021-04-09 20:52:24 +00:00
|
|
|
;; This program is free software; you can redistribute it and/or modify
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
;;
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
;;
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2015-09-26 04:26:16 +00:00
|
|
|
(require 'mocker)
|
2015-11-19 05:24:27 +00:00
|
|
|
(require 'evil-evilified-state)
|
2015-09-25 04:27:11 +00:00
|
|
|
|
2015-06-30 04:06:39 +00:00
|
|
|
;; ---------------------------------------------------------------------------
|
2015-11-19 05:24:27 +00:00
|
|
|
;; evilified-state-evilify-map
|
2015-06-30 04:06:39 +00:00
|
|
|
;; ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
;; commands
|
|
|
|
|
|
|
|
(ert-deftest test-evilify-map--s ()
|
2018-06-07 03:54:17 +00:00
|
|
|
(let* ((evil-evilified-state-map (let ((evil-map (make-sparse-keymap)))
|
|
|
|
(define-key evil-map "s" 'evil-func)
|
|
|
|
evil-map))
|
|
|
|
(evil-evilified-state-map-original (copy-keymap
|
|
|
|
evil-evilified-state-map))
|
|
|
|
(input-map (make-sparse-keymap)))
|
2015-06-30 04:06:39 +00:00
|
|
|
(define-key input-map "s" 'func)
|
2015-11-05 13:09:00 +00:00
|
|
|
(evilified-state-evilify-map input-map)
|
2018-06-07 03:54:17 +00:00
|
|
|
(message "%s" input-map)
|
2015-09-26 04:11:34 +00:00
|
|
|
(should (equal '((115 . func)
|
|
|
|
(evilified-state
|
2015-09-26 04:26:16 +00:00
|
|
|
keymap "Auxiliary keymap for Evilified state"
|
2015-09-26 04:11:34 +00:00
|
|
|
(83 . func)
|
|
|
|
(115 . evil-func)))
|
2015-11-19 05:24:27 +00:00
|
|
|
(evilified-state--sort-keymap input-map)))))
|
2015-06-30 04:06:39 +00:00
|
|
|
|
|
|
|
(ert-deftest test-evilify-map--s-2-evilified ()
|
2018-06-07 03:54:17 +00:00
|
|
|
(let* ((evil-evilified-state-map (let ((evil-map (make-sparse-keymap)))
|
|
|
|
(define-key evil-map "s" 'evil-func)
|
|
|
|
(define-key evil-map "S" 'evil-func2)
|
|
|
|
evil-map))
|
|
|
|
(evil-evilified-state-map-original (copy-keymap
|
|
|
|
evil-evilified-state-map))
|
|
|
|
(input-map (make-sparse-keymap)))
|
2015-06-30 04:06:39 +00:00
|
|
|
(define-key input-map "s" 'func)
|
2015-11-05 13:09:00 +00:00
|
|
|
(evilified-state-evilify-map input-map)
|
2015-09-26 04:11:34 +00:00
|
|
|
(should (equal '((115 . func)
|
|
|
|
(evilified-state
|
2015-09-26 04:26:16 +00:00
|
|
|
keymap "Auxiliary keymap for Evilified state"
|
2015-09-26 04:11:34 +00:00
|
|
|
(19 . func)
|
|
|
|
(83 . evil-func2)
|
|
|
|
(115 . evil-func)))
|
2015-11-19 05:24:27 +00:00
|
|
|
(evilified-state--sort-keymap input-map)))))
|
2015-06-30 04:06:39 +00:00
|
|
|
|
|
|
|
(ert-deftest test-evilify-map--s-S ()
|
2018-06-07 03:54:17 +00:00
|
|
|
(let* ((evil-evilified-state-map (let ((evil-map (make-sparse-keymap)))
|
|
|
|
(define-key evil-map "s" 'evil-func)
|
|
|
|
evil-map))
|
|
|
|
(evil-evilified-state-map-original (copy-keymap
|
|
|
|
evil-evilified-state-map))
|
|
|
|
(input-map (make-sparse-keymap)))
|
2015-06-30 04:06:39 +00:00
|
|
|
(define-key input-map "s" 'func1)
|
|
|
|
(define-key input-map "S" 'func2)
|
2015-11-05 13:09:00 +00:00
|
|
|
(evilified-state-evilify-map input-map)
|
2015-09-26 04:11:34 +00:00
|
|
|
(should (equal '((115 . func1)
|
|
|
|
(83 . func2)
|
|
|
|
(evilified-state
|
2015-09-26 04:26:16 +00:00
|
|
|
keymap "Auxiliary keymap for Evilified state"
|
2015-09-26 04:11:34 +00:00
|
|
|
(19 . func2)
|
|
|
|
(83 . func1)
|
|
|
|
(115 . evil-func)))
|
2015-11-19 05:24:27 +00:00
|
|
|
(evilified-state--sort-keymap input-map)))))
|
2015-06-30 04:06:39 +00:00
|
|
|
|
|
|
|
(ert-deftest test-evilify-map--s-S-reversed-order ()
|
2018-06-07 03:54:17 +00:00
|
|
|
(let* ((evil-evilified-state-map (let ((evil-map (make-sparse-keymap)))
|
|
|
|
(define-key evil-map "s" 'evil-func)
|
|
|
|
evil-map))
|
|
|
|
(evil-evilified-state-map-original (copy-keymap
|
|
|
|
evil-evilified-state-map))
|
|
|
|
(input-map (make-sparse-keymap)))
|
2015-06-30 04:06:39 +00:00
|
|
|
(define-key input-map "S" 'func2)
|
|
|
|
(define-key input-map "s" 'func1)
|
2015-11-05 13:09:00 +00:00
|
|
|
(evilified-state-evilify-map input-map)
|
2015-09-26 04:11:34 +00:00
|
|
|
(should (equal '((115 . func1)
|
|
|
|
(83 . func2)
|
|
|
|
(evilified-state
|
2015-09-26 04:26:16 +00:00
|
|
|
keymap "Auxiliary keymap for Evilified state"
|
2015-09-26 04:11:34 +00:00
|
|
|
(19 . func2)
|
|
|
|
(83 . func1)
|
|
|
|
(115 . evil-func)))
|
2015-11-19 05:24:27 +00:00
|
|
|
(evilified-state--sort-keymap input-map)))))
|
2015-06-30 04:06:39 +00:00
|
|
|
|
|
|
|
(ert-deftest test-evilify-map--s-S-2-evilified ()
|
2018-06-07 03:54:17 +00:00
|
|
|
(let* ((evil-evilified-state-map (let ((evil-map (make-sparse-keymap)))
|
|
|
|
(define-key evil-map "s" 'evil-func1)
|
|
|
|
(define-key evil-map "S" 'evil-func2)
|
|
|
|
evil-map))
|
|
|
|
(evil-evilified-state-map-original (copy-keymap
|
|
|
|
evil-evilified-state-map))
|
|
|
|
(input-map (make-sparse-keymap)))
|
2015-06-30 04:06:39 +00:00
|
|
|
(define-key input-map "s" 'func1)
|
|
|
|
(define-key input-map "S" 'func2)
|
2015-11-05 13:09:00 +00:00
|
|
|
(evilified-state-evilify-map input-map)
|
2015-09-26 04:11:34 +00:00
|
|
|
(should (equal '((115 . func1)
|
|
|
|
(83 . func2)
|
|
|
|
(evilified-state
|
2015-09-26 04:26:16 +00:00
|
|
|
keymap "Auxiliary keymap for Evilified state"
|
2015-09-26 04:11:34 +00:00
|
|
|
(33554451 . func2)
|
|
|
|
(19 . func1)
|
|
|
|
(83 . evil-func2)
|
|
|
|
(115 . evil-func1)))
|
2015-11-19 05:24:27 +00:00
|
|
|
(evilified-state--sort-keymap input-map)))))
|
2015-06-30 04:06:39 +00:00
|
|
|
|
|
|
|
(ert-deftest test-evilify-map--s-S-2-evilified-reversed-order ()
|
2018-06-07 03:54:17 +00:00
|
|
|
(let* ((evil-evilified-state-map (let ((evil-map (make-sparse-keymap)))
|
|
|
|
(define-key evil-map "S" 'evil-func2)
|
|
|
|
(define-key evil-map "s" 'evil-func1)
|
|
|
|
evil-map))
|
|
|
|
(evil-evilified-state-map-original (copy-keymap
|
|
|
|
evil-evilified-state-map))
|
|
|
|
(input-map (make-sparse-keymap)))
|
2015-06-30 04:06:39 +00:00
|
|
|
(define-key input-map "S" 'func2)
|
|
|
|
(define-key input-map "s" 'func1)
|
2015-11-05 13:09:00 +00:00
|
|
|
(evilified-state-evilify-map input-map)
|
2015-09-26 04:11:34 +00:00
|
|
|
(should (equal '((115 . func1)
|
|
|
|
(83 . func2)
|
|
|
|
(evilified-state
|
2015-09-26 04:26:16 +00:00
|
|
|
keymap "Auxiliary keymap for Evilified state"
|
2015-09-26 04:11:34 +00:00
|
|
|
(33554451 . func2)
|
|
|
|
(19 . func1)
|
|
|
|
(83 . evil-func2)
|
|
|
|
(115 . evil-func1)))
|
2015-11-19 05:24:27 +00:00
|
|
|
(evilified-state--sort-keymap input-map)))))
|
2015-06-30 04:06:39 +00:00
|
|
|
|
|
|
|
(ert-deftest test-evilify-map--s-S-C-s ()
|
2018-06-07 03:54:17 +00:00
|
|
|
(let* ((evil-evilified-state-map (let ((evil-map (make-sparse-keymap)))
|
|
|
|
(define-key evil-map "s" 'evil-func)
|
|
|
|
evil-map))
|
|
|
|
(evil-evilified-state-map-original (copy-keymap
|
|
|
|
evil-evilified-state-map))
|
|
|
|
(input-map (make-sparse-keymap)))
|
2015-06-30 04:06:39 +00:00
|
|
|
(define-key input-map "s" 'func1)
|
|
|
|
(define-key input-map "S" 'func2)
|
|
|
|
(define-key input-map (kbd "C-s") 'func3)
|
2015-11-05 13:09:00 +00:00
|
|
|
(evilified-state-evilify-map input-map)
|
2015-09-26 04:11:34 +00:00
|
|
|
(should (equal '((115 . func1)
|
|
|
|
(83 . func2)
|
|
|
|
(19 . func3)
|
|
|
|
(evilified-state
|
2015-09-26 04:26:16 +00:00
|
|
|
keymap "Auxiliary keymap for Evilified state"
|
2015-09-26 04:11:34 +00:00
|
|
|
(33554451 . func3)
|
|
|
|
(19 . func2)
|
|
|
|
(83 . func1)
|
|
|
|
(115 . evil-func)))
|
2015-11-19 05:24:27 +00:00
|
|
|
(evilified-state--sort-keymap input-map)))))
|
2015-06-30 04:06:39 +00:00
|
|
|
|
|
|
|
(ert-deftest test-evilify-map--s-S-C-s-shuffled ()
|
2018-06-07 03:54:17 +00:00
|
|
|
(let* ((evil-evilified-state-map (let ((evil-map (make-sparse-keymap)))
|
|
|
|
(define-key evil-map "s" 'evil-func)
|
|
|
|
evil-map))
|
|
|
|
(evil-evilified-state-map-original (copy-keymap
|
|
|
|
evil-evilified-state-map))
|
|
|
|
(input-map (make-sparse-keymap)))
|
2015-06-30 04:06:39 +00:00
|
|
|
(define-key input-map "s" 'func1)
|
|
|
|
(define-key input-map (kbd "C-s") 'func3)
|
|
|
|
(define-key input-map "S" 'func2)
|
2015-11-05 13:09:00 +00:00
|
|
|
(evilified-state-evilify-map input-map)
|
2015-09-26 04:11:34 +00:00
|
|
|
(should (equal '((115 . func1)
|
|
|
|
(83 . func2)
|
|
|
|
(19 . func3)
|
|
|
|
(evilified-state
|
2015-09-26 04:26:16 +00:00
|
|
|
keymap "Auxiliary keymap for Evilified state"
|
2015-09-26 04:11:34 +00:00
|
|
|
(33554451 . func3)
|
|
|
|
(19 . func2)
|
|
|
|
(83 . func1)
|
|
|
|
(115 . evil-func)))
|
2015-11-19 05:24:27 +00:00
|
|
|
(evilified-state--sort-keymap input-map)))))
|
2015-06-30 04:06:39 +00:00
|
|
|
|
|
|
|
(ert-deftest test-evilify-map--s-S-C-s-2-evilified ()
|
2018-06-07 03:54:17 +00:00
|
|
|
(let* ((evil-evilified-state-map (let ((evil-map (make-sparse-keymap)))
|
|
|
|
(define-key evil-map "s" 'evil-func1)
|
|
|
|
(define-key evil-map "S" 'evil-func2)
|
|
|
|
evil-map))
|
|
|
|
(evil-evilified-state-map-original (copy-keymap
|
|
|
|
evil-evilified-state-map))
|
|
|
|
(input-map (make-sparse-keymap)))
|
2015-06-30 04:06:39 +00:00
|
|
|
(define-key input-map "s" 'func1)
|
|
|
|
(define-key input-map "S" 'func2)
|
|
|
|
(define-key input-map (kbd "C-s") 'func3)
|
|
|
|
(mocker-let
|
2018-06-07 03:54:17 +00:00
|
|
|
((message (msg &rest args)
|
|
|
|
((:record-cls 'mocker-stub-record
|
|
|
|
:output nil :occur 1))))
|
2015-11-05 13:09:00 +00:00
|
|
|
(evilified-state-evilify-map input-map)
|
2015-09-26 04:11:34 +00:00
|
|
|
(should (equal '((115 . func1)
|
|
|
|
(83 . func2)
|
|
|
|
(19 . func3)
|
|
|
|
(evilified-state
|
2015-09-26 04:26:16 +00:00
|
|
|
keymap "Auxiliary keymap for Evilified state"
|
2015-09-26 04:11:34 +00:00
|
|
|
(33554451 . func2)
|
|
|
|
(19 . func1)
|
|
|
|
(83 . evil-func2)
|
|
|
|
(115 . evil-func1)))
|
2015-11-19 05:24:27 +00:00
|
|
|
(evilified-state--sort-keymap input-map))))))
|
2015-06-30 04:06:39 +00:00
|
|
|
|
|
|
|
(ert-deftest test-evilify-map--s-C-s-S-2-evilified-shuffled ()
|
2018-06-07 03:54:17 +00:00
|
|
|
(let* ((evil-evilified-state-map (let ((evil-map (make-sparse-keymap)))
|
|
|
|
(define-key evil-map "s" 'evil-func1)
|
|
|
|
(define-key evil-map "S" 'evil-func2)
|
|
|
|
evil-map))
|
|
|
|
(evil-evilified-state-map-original (copy-keymap
|
|
|
|
evil-evilified-state-map))
|
|
|
|
(input-map (make-sparse-keymap)))
|
2015-06-30 04:06:39 +00:00
|
|
|
(define-key input-map "s" 'func1)
|
|
|
|
(define-key input-map (kbd "C-s") 'func3)
|
|
|
|
(define-key input-map "S" 'func2)
|
|
|
|
(mocker-let
|
2018-06-07 03:54:17 +00:00
|
|
|
((message (msg &rest args)
|
|
|
|
((:record-cls 'mocker-stub-record
|
|
|
|
:output nil :occur 1))))
|
2015-11-05 13:09:00 +00:00
|
|
|
(evilified-state-evilify-map input-map)
|
2015-09-26 04:11:34 +00:00
|
|
|
(should (equal '((115 . func1)
|
|
|
|
(83 . func2)
|
|
|
|
(19 . func3)
|
|
|
|
(evilified-state
|
2015-09-26 04:26:16 +00:00
|
|
|
keymap "Auxiliary keymap for Evilified state"
|
2015-09-26 04:11:34 +00:00
|
|
|
(33554451 . func2)
|
|
|
|
(19 . func1)
|
|
|
|
(83 . evil-func2)
|
|
|
|
(115 . evil-func1)))
|
2015-11-19 05:24:27 +00:00
|
|
|
(evilified-state--sort-keymap input-map))))))
|
2015-06-30 04:06:39 +00:00
|
|
|
|
|
|
|
;; keymaps
|
|
|
|
|
|
|
|
(ert-deftest test-evilify-map--s-keymap ()
|
2018-06-07 03:54:17 +00:00
|
|
|
(let* ((evil-evilified-state-map (let ((evil-map (make-sparse-keymap)))
|
|
|
|
(define-key evil-map "s" 'evil-func)
|
|
|
|
evil-map))
|
|
|
|
(evil-evilified-state-map-original (copy-keymap
|
|
|
|
evil-evilified-state-map))
|
|
|
|
(input-map (make-sparse-keymap))
|
|
|
|
(submap (make-sparse-keymap)))
|
2015-06-30 04:06:39 +00:00
|
|
|
(define-key input-map "s" submap)
|
|
|
|
(define-key submap "t" 'func)
|
2015-11-05 13:09:00 +00:00
|
|
|
(evilified-state-evilify-map input-map)
|
2015-09-26 04:11:34 +00:00
|
|
|
(should (equal '((115 keymap (116 . func))
|
|
|
|
(evilified-state
|
2015-09-26 04:26:16 +00:00
|
|
|
keymap "Auxiliary keymap for Evilified state"
|
2015-09-26 04:11:34 +00:00
|
|
|
(83 keymap (116 . func))
|
|
|
|
(115 . evil-func)))
|
2015-11-19 05:24:27 +00:00
|
|
|
(evilified-state--sort-keymap input-map)))))
|
2015-06-30 04:06:39 +00:00
|
|
|
|
|
|
|
(ert-deftest test-evilify-map--s-keymap-2-evilified ()
|
2018-06-07 03:54:17 +00:00
|
|
|
(let* ((evil-evilified-state-map (let ((evil-map (make-sparse-keymap)))
|
|
|
|
(define-key evil-map "s" 'evil-func1)
|
|
|
|
(define-key evil-map "S" 'evil-func2)
|
|
|
|
evil-map))
|
|
|
|
(evil-evilified-state-map-original (copy-keymap
|
|
|
|
evil-evilified-state-map))
|
|
|
|
(input-map (make-sparse-keymap))
|
|
|
|
(submap (make-sparse-keymap)))
|
2015-06-30 04:06:39 +00:00
|
|
|
(define-key input-map "s" submap)
|
|
|
|
(define-key submap "t" 'func)
|
2015-11-05 13:09:00 +00:00
|
|
|
(evilified-state-evilify-map input-map)
|
2015-09-26 04:11:34 +00:00
|
|
|
(should (equal '((115 keymap (116 . func))
|
|
|
|
(evilified-state
|
2015-09-26 04:26:16 +00:00
|
|
|
keymap "Auxiliary keymap for Evilified state"
|
2015-09-26 04:11:34 +00:00
|
|
|
(19 keymap (116 . func))
|
|
|
|
(83 . evil-func2)
|
|
|
|
(115 . evil-func1)))
|
2015-11-19 05:24:27 +00:00
|
|
|
(evilified-state--sort-keymap input-map)))))
|
2015-06-30 04:06:39 +00:00
|
|
|
|
|
|
|
(ert-deftest test-evilify-map--s-S-keymaps ()
|
2018-06-07 03:54:17 +00:00
|
|
|
(let* ((evil-evilified-state-map (let ((evil-map (make-sparse-keymap)))
|
|
|
|
(define-key evil-map "s" 'evil-func)
|
|
|
|
evil-map))
|
|
|
|
(evil-evilified-state-map-original (copy-keymap
|
|
|
|
evil-evilified-state-map))
|
|
|
|
(input-map (make-sparse-keymap))
|
|
|
|
(submap (make-sparse-keymap)))
|
2015-06-30 04:06:39 +00:00
|
|
|
(define-key input-map "s" submap)
|
|
|
|
(define-key input-map "S" submap)
|
|
|
|
(define-key submap "t" 'func)
|
2015-11-05 13:09:00 +00:00
|
|
|
(evilified-state-evilify-map input-map)
|
2015-09-26 04:11:34 +00:00
|
|
|
(should (equal '((115 keymap (116 . func))
|
|
|
|
(83 keymap (116 . func))
|
|
|
|
(evilified-state
|
2015-09-26 04:26:16 +00:00
|
|
|
keymap "Auxiliary keymap for Evilified state"
|
2015-09-26 04:11:34 +00:00
|
|
|
(19 keymap (116 . func))
|
|
|
|
(83 keymap (116 . func))
|
|
|
|
(115 . evil-func)))
|
2015-11-19 05:24:27 +00:00
|
|
|
(evilified-state--sort-keymap input-map)))))
|
2015-06-30 04:06:39 +00:00
|
|
|
|
|
|
|
(ert-deftest test-evilify-map--s-S-keymaps-2-evilified ()
|
2018-06-07 03:54:17 +00:00
|
|
|
(let* ((evil-evilified-state-map (let ((evil-map (make-sparse-keymap)))
|
|
|
|
(define-key evil-map "s" 'evil-func1)
|
|
|
|
(define-key evil-map "S" 'evil-func2)
|
|
|
|
evil-map))
|
|
|
|
(evil-evilified-state-map-original (copy-keymap
|
|
|
|
evil-evilified-state-map))
|
|
|
|
(input-map (make-sparse-keymap))
|
|
|
|
(submap (make-sparse-keymap)))
|
2015-06-30 04:06:39 +00:00
|
|
|
(define-key input-map "s" submap)
|
|
|
|
(define-key input-map "S" submap)
|
|
|
|
(define-key submap "t" 'func)
|
2015-11-05 13:09:00 +00:00
|
|
|
(evilified-state-evilify-map input-map)
|
2015-09-26 04:11:34 +00:00
|
|
|
(should (equal '((115 keymap (116 . func))
|
|
|
|
(83 keymap (116 . func))
|
|
|
|
(evilified-state
|
2015-09-26 04:26:16 +00:00
|
|
|
keymap "Auxiliary keymap for Evilified state"
|
2015-09-26 04:11:34 +00:00
|
|
|
(33554451 keymap (116 . func))
|
|
|
|
(19 keymap (116 . func))
|
|
|
|
(83 . evil-func2)
|
|
|
|
(115 . evil-func1)))
|
2015-11-19 05:24:27 +00:00
|
|
|
(evilified-state--sort-keymap input-map)))))
|
2015-06-30 04:06:39 +00:00
|
|
|
|
|
|
|
(ert-deftest test-evilify-map--s-S-C-s-keymaps ()
|
2018-06-07 03:54:17 +00:00
|
|
|
(let* ((evil-evilified-state-map (let ((evil-map (make-sparse-keymap)))
|
|
|
|
(define-key evil-map "s" 'evil-func)
|
|
|
|
evil-map))
|
|
|
|
(evil-evilified-state-map-original (copy-keymap
|
|
|
|
evil-evilified-state-map))
|
|
|
|
(input-map (make-sparse-keymap))
|
|
|
|
(submap (make-sparse-keymap)))
|
2015-06-30 04:06:39 +00:00
|
|
|
(define-key input-map "s" submap)
|
|
|
|
(define-key input-map "S" submap)
|
|
|
|
(define-key input-map (kbd "C-s") submap)
|
|
|
|
(define-key submap "t" 'func)
|
2015-11-05 13:09:00 +00:00
|
|
|
(evilified-state-evilify-map input-map)
|
2015-09-26 04:11:34 +00:00
|
|
|
(should (equal '((115 keymap (116 . func))
|
|
|
|
(83 keymap (116 . func))
|
|
|
|
(19 keymap (116 . func))
|
|
|
|
(evilified-state
|
2015-09-26 04:26:16 +00:00
|
|
|
keymap "Auxiliary keymap for Evilified state"
|
2015-09-26 04:11:34 +00:00
|
|
|
(33554451 keymap (116 . func))
|
|
|
|
(19 keymap (116 . func))
|
|
|
|
(83 keymap (116 . func))
|
|
|
|
(115 . evil-func)))
|
2015-11-19 05:24:27 +00:00
|
|
|
(evilified-state--sort-keymap input-map)))))
|
2015-06-30 04:06:39 +00:00
|
|
|
|
|
|
|
(ert-deftest test-evilify-map--s-S-C-s-keymaps-2-evilified ()
|
2018-06-07 03:54:17 +00:00
|
|
|
(let* ((evil-evilified-state-map (let ((evil-map (make-sparse-keymap)))
|
|
|
|
(define-key evil-map "s" 'evil-func1)
|
|
|
|
(define-key evil-map "S" 'evil-func2)
|
|
|
|
evil-map))
|
|
|
|
(evil-evilified-state-map-original (copy-keymap
|
|
|
|
evil-evilified-state-map))
|
|
|
|
(input-map (make-sparse-keymap))
|
|
|
|
(submap (make-sparse-keymap)))
|
2015-06-30 04:06:39 +00:00
|
|
|
(define-key input-map "s" submap)
|
|
|
|
(define-key input-map "S" submap)
|
|
|
|
(define-key input-map (kbd "C-s") submap)
|
|
|
|
(define-key submap "t" 'func)
|
|
|
|
(mocker-let
|
2018-06-07 03:54:17 +00:00
|
|
|
((message (msg &rest args)
|
|
|
|
((:record-cls 'mocker-stub-record
|
|
|
|
:output nil :occur 1))))
|
2015-11-05 13:09:00 +00:00
|
|
|
(evilified-state-evilify-map input-map)
|
2015-09-26 04:11:34 +00:00
|
|
|
(should (equal '((115 keymap (116 . func))
|
|
|
|
(83 keymap (116 . func))
|
|
|
|
(19 keymap (116 . func))
|
|
|
|
(evilified-state
|
2015-09-26 04:26:16 +00:00
|
|
|
keymap "Auxiliary keymap for Evilified state"
|
2015-09-26 04:11:34 +00:00
|
|
|
(33554451 keymap (116 . func))
|
|
|
|
(19 keymap (116 . func))
|
|
|
|
(83 . evil-func2)
|
|
|
|
(115 . evil-func1)))
|
2015-11-19 05:24:27 +00:00
|
|
|
(evilified-state--sort-keymap input-map))))))
|
2015-06-30 04:06:39 +00:00
|
|
|
|
2018-06-07 03:54:17 +00:00
|
|
|
;; ;; commands and keymaps
|
2015-06-30 04:06:39 +00:00
|
|
|
|
|
|
|
(ert-deftest test-evilify-map--s-command-and-keymap ()
|
2018-06-07 03:54:17 +00:00
|
|
|
(let* ((evil-evilified-state-map (let ((evil-map (make-sparse-keymap)))
|
|
|
|
(define-key evil-map "s" 'evil-func)
|
|
|
|
evil-map))
|
|
|
|
(evil-evilified-state-map-original (copy-keymap
|
|
|
|
evil-evilified-state-map))
|
|
|
|
(input-map (make-sparse-keymap))
|
|
|
|
(submap (make-sparse-keymap)))
|
2015-06-30 04:06:39 +00:00
|
|
|
(define-key input-map "s" 'func)
|
|
|
|
(define-key input-map "S" submap)
|
|
|
|
(define-key submap "t" 'func)
|
2015-11-05 13:09:00 +00:00
|
|
|
(evilified-state-evilify-map input-map)
|
2015-09-26 04:11:34 +00:00
|
|
|
(should (equal '((115 . func)
|
|
|
|
(83 keymap (116 . func))
|
|
|
|
(evilified-state
|
2015-09-26 04:26:16 +00:00
|
|
|
keymap "Auxiliary keymap for Evilified state"
|
2015-09-26 04:11:34 +00:00
|
|
|
(19 keymap (116 . func))
|
|
|
|
(83 . func)
|
|
|
|
(115 . evil-func)))
|
2015-11-19 05:24:27 +00:00
|
|
|
(evilified-state--sort-keymap input-map)))))
|
2015-06-30 04:06:39 +00:00
|
|
|
|
2018-06-07 03:54:17 +00:00
|
|
|
;; ;; idem-potency
|
2015-06-30 04:06:39 +00:00
|
|
|
|
|
|
|
(ert-deftest test-evilify-map--idem-potent ()
|
2018-06-07 03:54:17 +00:00
|
|
|
(let* ((evil-evilified-state-map (let ((evil-map (make-sparse-keymap)))
|
|
|
|
(define-key evil-map "s" 'evil-func)
|
|
|
|
evil-map))
|
|
|
|
(evil-evilified-state-map-original (copy-keymap
|
|
|
|
evil-evilified-state-map))
|
|
|
|
(input-map (make-sparse-keymap))
|
|
|
|
(submap (make-sparse-keymap)))
|
2015-06-30 04:06:39 +00:00
|
|
|
(define-key input-map "e" 'func1)
|
|
|
|
(define-key input-map (kbd "C-c C-x") 'func3)
|
|
|
|
(define-key input-map "s" 'func2)
|
|
|
|
(define-key input-map "S" submap)
|
|
|
|
(define-key submap "t" 'func)
|
|
|
|
(dotimes (_ 10)
|
2015-11-05 13:09:00 +00:00
|
|
|
(evilified-state-evilify-map input-map))
|
2015-09-26 04:11:34 +00:00
|
|
|
(should (equal '((115 . func2)
|
2015-06-30 04:06:39 +00:00
|
|
|
(101 . func1)
|
2015-09-26 04:11:34 +00:00
|
|
|
(83 keymap (116 . func))
|
|
|
|
(3 keymap (24 . func3))
|
|
|
|
(evilified-state
|
2015-09-26 04:26:16 +00:00
|
|
|
keymap "Auxiliary keymap for Evilified state"
|
2015-09-26 04:11:34 +00:00
|
|
|
(19 keymap (116 . func))
|
|
|
|
(83 . func2)
|
|
|
|
(115 . evil-func)))
|
2015-11-19 05:24:27 +00:00
|
|
|
(evilified-state--sort-keymap input-map)))))
|
2015-06-30 04:06:39 +00:00
|
|
|
|
2015-08-04 03:00:49 +00:00
|
|
|
;; eval-after-load
|
|
|
|
|
|
|
|
(ert-deftest test-evilify-map--eval-after-load-already-loaded ()
|
2018-06-07 03:54:17 +00:00
|
|
|
(let* ((evil-evilified-state-map (let ((evil-map (make-sparse-keymap)))
|
|
|
|
(define-key evil-map "s" 'evil-func)
|
|
|
|
evil-map))
|
|
|
|
(evil-evilified-state-map-original (copy-keymap
|
|
|
|
evil-evilified-state-map))
|
|
|
|
(input-map (make-sparse-keymap)))
|
2015-08-04 03:00:49 +00:00
|
|
|
(define-key input-map "s" 'func)
|
|
|
|
;; pass a feature already loaded at the time of calling
|
2015-11-05 13:09:00 +00:00
|
|
|
(evilified-state-evilify-map input-map :eval-after-load core-funcs)
|
2015-09-26 04:11:34 +00:00
|
|
|
(should (equal '((115 . func)
|
|
|
|
(evilified-state
|
2015-09-26 04:26:16 +00:00
|
|
|
keymap "Auxiliary keymap for Evilified state"
|
2015-09-26 04:11:34 +00:00
|
|
|
(83 . func)
|
|
|
|
(115 . evil-func)))
|
2015-11-19 05:24:27 +00:00
|
|
|
(evilified-state--sort-keymap input-map)))))
|
2015-08-04 03:00:49 +00:00
|
|
|
|
|
|
|
(ert-deftest test-evilify-map--eval-after-load-not-loaded ()
|
2018-06-07 03:54:17 +00:00
|
|
|
(let* ((evil-evilified-state-map (let ((evil-map (make-sparse-keymap)))
|
|
|
|
(define-key evil-map "s" 'evil-func)
|
|
|
|
evil-map))
|
|
|
|
(evil-evilified-state-map-original (copy-keymap
|
|
|
|
evil-evilified-state-map))
|
|
|
|
(input-map (make-sparse-keymap)))
|
2015-08-04 03:00:49 +00:00
|
|
|
(define-key input-map "s" 'func)
|
2015-11-05 13:09:00 +00:00
|
|
|
(evilified-state-evilify-map input-map :eval-after-load dummy-feature)
|
2015-08-04 03:00:49 +00:00
|
|
|
;; unmodified keymap since `dummy-feature' is not loaded
|
|
|
|
(should (equal '((115 . func))
|
2015-11-19 05:24:27 +00:00
|
|
|
(evilified-state--sort-keymap input-map)))))
|