diff options
| author | Justin Burkett <justin@burkett.cc> | 2018-01-25 08:02:27 -0500 |
|---|---|---|
| committer | Justin Burkett <justin@burkett.cc> | 2018-01-25 08:08:50 -0500 |
| commit | f59b56ec48460b8d1479076dbc809db02b6fa9da (patch) | |
| tree | 80b343ea55c346ba4e0798068101a4a57338a691 | |
| parent | d2d4748daa65f97b918522e76d15dcebccc2691b (diff) | |
Add tests for evil-initial-state
| -rw-r--r-- | evil-tests.el | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/evil-tests.el b/evil-tests.el index 75b28b4..50edebd 100644 --- a/evil-tests.el +++ b/evil-tests.el @@ -8257,6 +8257,48 @@ when an error stops the execution of the macro" ; should not raise an "Selecting deleted buffer" error (evil-visual-update-x-selection buf)))) +;;; Core + +(ert-deftest evil-test-initial-state () + "Test `evil-initial-state'" + :tags '(evil core) + (define-derived-mode test-1-mode prog-mode "Test1") + (define-derived-mode test-2-mode test-1-mode "Test2") + (evil-set-initial-state 'test-1-mode 'insert) + (ert-info ("Check default state") + (should (eq (evil-initial-state 'prog-mode 'normal) 'normal))) + (ert-info ("Basic functionality 1") + (should (eq (evil-initial-state 'test-1-mode) 'insert))) + (ert-info ("Basic functionality 2") + (evil-test-buffer + "abc\ndef\n" + (test-1-mode) + (should (eq evil-state 'insert)))) + (ert-info ("Inherit initial state from a parent") + (evil-test-buffer + "abc\ndef\n" + (test-2-mode) + (should (eq evil-state 'insert)))) + (evil-set-initial-state 'test-1-mode nil) + (ert-info ("Check for inheritance loops") + (evil-test-buffer + "abc\ndef\n" + (unwind-protect + (let ((major-mode 'test-2-mode)) + (put 'test-1-mode 'derived-mode-parent 'test-2-mode) + ;; avoid triggering all of the hooks here, some of which might get + ;; caught in loops depending on the environment. settings major-mode + ;; is sufficient for `evil-initial-state-for-buffer' to work. + (should-error (evil-initial-state-for-buffer))) + (put 'test-1-mode 'derived-mode-parent 'prog-mode)))) + (defalias 'test-1-alias-mode 'test-1-mode) + (define-derived-mode test-3-mode test-1-alias-mode "Test3") + (evil-set-initial-state 'test-1-mode 'insert) + (ert-info ("Check inheritance from major mode aliases") + "abc\ndef\n" + (test-3-mode) + (should (eq evil-state 'insert)))) + (provide 'evil-tests) ;;; evil-tests.el ends here |
