Fix remaining failing tests

* yasnippet-tests.el (issue-492-and-494): Make the test a bit less picky.
(test-yas-tab-binding, test-yas-in-org): Test TAB rather than `tab`
because at the level at which we do the test, `tab` is not remapped to TAB.
This commit is contained in:
Stefan Monnier 2024-01-19 08:55:17 -05:00
parent 3e14a8534f
commit d7a79d4a96

View File

@ -1316,7 +1316,7 @@ hello ${1:$(when (stringp yas-text) (funcall func yas-text))} foo${1:$$(concat \
(yas-minor-mode +1) (yas-minor-mode +1)
(should (equal (yas--template-content (yas-lookup-snippet "one")) (should (equal (yas--template-content (yas-lookup-snippet "one"))
"one")) "one"))
(should (eq (yas--key-binding "\C-c1") 'yas-expand-from-keymap)) (should (eq (yas--key-binding "\C-c1") #'yas-expand-from-keymap))
(yas-define-snippets (yas-define-snippets
'text-mode '(("_1" "one!" "won" nil nil nil nil nil "uuid-1"))) 'text-mode '(("_1" "one!" "won" nil nil nil nil nil "uuid-1")))
(should (null (yas-lookup-snippet "one" nil 'noerror))) (should (null (yas-lookup-snippet "one" nil 'noerror)))
@ -1433,6 +1433,7 @@ hello ${1:$(when (stringp yas-text) (funcall func yas-text))} foo${1:$$(concat \
(defalias 'yas--phony-c-mode #'c-mode) (defalias 'yas--phony-c-mode #'c-mode)
(ert-deftest issue-492-and-494 () (ert-deftest issue-492-and-494 ()
"Aliases like `yas--phony-c-mode' should be considered as \"derived\"."
(define-derived-mode yas--test-mode yas--phony-c-mode "Just a test mode") (define-derived-mode yas--test-mode yas--phony-c-mode "Just a test mode")
(yas-with-snippet-dirs '((".emacs.d/snippets" (yas-with-snippet-dirs '((".emacs.d/snippets"
("yas--test-mode"))) ("yas--test-mode")))
@ -1441,12 +1442,14 @@ hello ${1:$(when (stringp yas-text) (funcall func yas-text))} foo${1:$$(concat \
(let* ((major-mode 'yas--test-mode) (let* ((major-mode 'yas--test-mode)
(expected `(fundamental-mode (expected `(fundamental-mode
c-mode c-mode
,@(if (fboundp 'prog-mode)
'(prog-mode))
yas--phony-c-mode yas--phony-c-mode
yas--test-mode)) yas--test-mode))
(observed (yas--modes-to-activate))) ;; The set of mode depends on some external factors:
(should (null (cl-set-exclusive-or expected observed))) ;; `prog-mode': if cc-mode.el has been loaded.
;; `cc-mode': if we added `cc-mode' as yas--parent of `c-mode'.
(observed (cl-set-difference (yas--modes-to-activate)
'(prog-mode cc-mode))))
(should-not (cl-set-exclusive-or expected observed))
(should (= (length expected) (should (= (length expected)
(length observed))))))) (length observed)))))))
@ -1652,14 +1655,14 @@ TODO: be meaner"
(with-temp-buffer (with-temp-buffer
(yas-minor-mode -1) (yas-minor-mode -1)
(insert "foo") (insert "foo")
(should (not (eq (key-binding (yas--read-keybinding "<tab>")) 'yas-expand))) (should-not (eq (key-binding (kbd "TAB")) #'yas-expand))
(yas-minor-mode 1) (yas-minor-mode 1)
(should (eq (key-binding (yas--read-keybinding "<tab>")) 'yas-expand)) (should (eq (key-binding (kbd "TAB")) #'yas-expand))
(yas-expand-snippet "$1 $2 $3") (yas-expand-snippet "$1 $2 $3")
(should (eq (key-binding [(tab)]) 'yas-next-field-or-maybe-expand)) ;; (should (eq (key-binding [tab]) #'yas-next-field-or-maybe-expand))
(should (eq (key-binding (kbd "TAB")) 'yas-next-field-or-maybe-expand)) (should (eq (key-binding (kbd "TAB")) #'yas-next-field-or-maybe-expand))
(should (eq (key-binding [(shift tab)]) 'yas-prev-field)) (should (eq (key-binding [(shift tab)]) #'yas-prev-field))
(should (eq (key-binding [backtab]) 'yas-prev-field)))))) (should (eq (key-binding [backtab]) #'yas-prev-field))))))
(ert-deftest test-rebindings () (ert-deftest test-rebindings ()
(let* ((yas-minor-mode-map (copy-keymap yas-minor-mode-map)) (let* ((yas-minor-mode-map (copy-keymap yas-minor-mode-map))
@ -1673,7 +1676,7 @@ TODO: be meaner"
(with-temp-buffer (with-temp-buffer
(yas-minor-mode 1) (yas-minor-mode 1)
(should-not (eq (key-binding (kbd "TAB")) #'yas-expand)) (should-not (eq (key-binding (kbd "TAB")) #'yas-expand))
(should (eq (key-binding (kbd "SPC")) 'yas-expand)) (should (eq (key-binding (kbd "SPC")) #'yas-expand))
(yas-reload-all) (yas-reload-all)
(should-not (eq (key-binding (kbd "TAB")) #'yas-expand)) (should-not (eq (key-binding (kbd "TAB")) #'yas-expand))
(should (eq (key-binding (kbd "SPC")) #'yas-expand))))) (should (eq (key-binding (kbd "SPC")) #'yas-expand)))))
@ -1689,8 +1692,8 @@ TODO: be meaner"
(org-mode) (org-mode)
(yas-minor-mode 1) (yas-minor-mode 1)
(insert "foo") (insert "foo")
(should (eq (key-binding [(tab)]) 'yas-expand)) ;; (should (eq (key-binding [tab]) #'yas-expand))
(should (eq (key-binding (kbd "TAB")) 'yas-expand)))))) (should (eq (key-binding (kbd "TAB")) #'yas-expand))))))
(ert-deftest yas-org-native-tab-in-source-block-text () (ert-deftest yas-org-native-tab-in-source-block-text ()
"Test expansion of snippets in org source blocks." "Test expansion of snippets in org source blocks."