mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-14 05:23:04 +00:00
Improve test simulatulation of self-insert
* yasnippet-tests.el (yas-mock-insert): Use `ert-simulate-command' to simulate n self-insert-commands. (simple-mirror, mirror-with-transformation): (primary-field-transformation, nested-placeholders-kill-superfield): (nested-placeholders-use-subfield): (mirrors-adjacent-to-fields-with-nested-mirrors): (deep-nested-mirroring-issue-351, example-for-issue-271): (string-match-with-subregexp-in-mirror-transformations): Call `yas-mock-insert' directly instead of with `ert-simulate-command'.
This commit is contained in:
parent
c80fbf2c0b
commit
71f0142eda
@ -53,7 +53,7 @@
|
|||||||
(yas-expand-snippet "${1:brother} from another $1")
|
(yas-expand-snippet "${1:brother} from another $1")
|
||||||
(should (string= (yas--buffer-contents)
|
(should (string= (yas--buffer-contents)
|
||||||
"brother from another brother"))
|
"brother from another brother"))
|
||||||
(ert-simulate-command `(yas-mock-insert "bla"))
|
(yas-mock-insert "bla")
|
||||||
(should (string= (yas--buffer-contents)
|
(should (string= (yas--buffer-contents)
|
||||||
"bla from another bla"))))
|
"bla from another bla"))))
|
||||||
|
|
||||||
@ -63,7 +63,7 @@
|
|||||||
(yas-expand-snippet "${1:brother} from another ${1:$(upcase yas-text)}")
|
(yas-expand-snippet "${1:brother} from another ${1:$(upcase yas-text)}")
|
||||||
(should (string= (yas--buffer-contents)
|
(should (string= (yas--buffer-contents)
|
||||||
"brother from another BROTHER"))
|
"brother from another BROTHER"))
|
||||||
(ert-simulate-command `(yas-mock-insert "bla"))
|
(yas-mock-insert "bla")
|
||||||
(should (string= (yas--buffer-contents)
|
(should (string= (yas--buffer-contents)
|
||||||
"bla from another BLA"))))
|
"bla from another BLA"))))
|
||||||
|
|
||||||
@ -73,7 +73,7 @@
|
|||||||
(let ((snippet "${1:$$(upcase yas-text)}${1:$(concat \"bar\" yas-text)}"))
|
(let ((snippet "${1:$$(upcase yas-text)}${1:$(concat \"bar\" yas-text)}"))
|
||||||
(yas-expand-snippet snippet)
|
(yas-expand-snippet snippet)
|
||||||
(should (string= (yas--buffer-contents) "bar"))
|
(should (string= (yas--buffer-contents) "bar"))
|
||||||
(ert-simulate-command `(yas-mock-insert "foo"))
|
(yas-mock-insert "foo")
|
||||||
(should (string= (yas--buffer-contents) "FOObarFOO")))))
|
(should (string= (yas--buffer-contents) "FOObarFOO")))))
|
||||||
|
|
||||||
(ert-deftest nested-placeholders-kill-superfield ()
|
(ert-deftest nested-placeholders-kill-superfield ()
|
||||||
@ -82,7 +82,7 @@
|
|||||||
(yas-expand-snippet "brother from ${2:another ${3:mother}}!")
|
(yas-expand-snippet "brother from ${2:another ${3:mother}}!")
|
||||||
(should (string= (yas--buffer-contents)
|
(should (string= (yas--buffer-contents)
|
||||||
"brother from another mother!"))
|
"brother from another mother!"))
|
||||||
(ert-simulate-command `(yas-mock-insert "bla"))
|
(yas-mock-insert "bla")
|
||||||
(should (string= (yas--buffer-contents)
|
(should (string= (yas--buffer-contents)
|
||||||
"brother from bla!"))))
|
"brother from bla!"))))
|
||||||
|
|
||||||
@ -91,7 +91,7 @@
|
|||||||
(yas-minor-mode 1)
|
(yas-minor-mode 1)
|
||||||
(yas-expand-snippet "brother from ${2:another ${3:mother}}!")
|
(yas-expand-snippet "brother from ${2:another ${3:mother}}!")
|
||||||
(ert-simulate-command '(yas-next-field-or-maybe-expand))
|
(ert-simulate-command '(yas-next-field-or-maybe-expand))
|
||||||
(ert-simulate-command `(yas-mock-insert "bla"))
|
(yas-mock-insert "bla")
|
||||||
(should (string= (yas--buffer-contents)
|
(should (string= (yas--buffer-contents)
|
||||||
"brother from another bla!"))))
|
"brother from another bla!"))))
|
||||||
|
|
||||||
@ -101,7 +101,7 @@
|
|||||||
(yas-expand-snippet "<%= f.submit \"${1:Submit}\"${2:$(and (yas-text) \", :disable_with => '\")}${2:$1ing...}${2:$(and (yas-text) \"'\")} %>")
|
(yas-expand-snippet "<%= f.submit \"${1:Submit}\"${2:$(and (yas-text) \", :disable_with => '\")}${2:$1ing...}${2:$(and (yas-text) \"'\")} %>")
|
||||||
(should (string= (yas--buffer-contents)
|
(should (string= (yas--buffer-contents)
|
||||||
"<%= f.submit \"Submit\", :disable_with => 'Submiting...' %>"))
|
"<%= f.submit \"Submit\", :disable_with => 'Submiting...' %>"))
|
||||||
(ert-simulate-command `(yas-mock-insert "Send"))
|
(yas-mock-insert "Send")
|
||||||
(should (string= (yas--buffer-contents)
|
(should (string= (yas--buffer-contents)
|
||||||
"<%= f.submit \"Send\", :disable_with => 'Sending...' %>"))))
|
"<%= f.submit \"Send\", :disable_with => 'Sending...' %>"))))
|
||||||
|
|
||||||
@ -109,7 +109,7 @@
|
|||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(yas-minor-mode 1)
|
(yas-minor-mode 1)
|
||||||
(yas-expand-snippet "${1:FOOOOOOO}${2:$1}${3:$2}${4:$3}")
|
(yas-expand-snippet "${1:FOOOOOOO}${2:$1}${3:$2}${4:$3}")
|
||||||
(ert-simulate-command `(yas-mock-insert "abc"))
|
(yas-mock-insert "abc")
|
||||||
(should (string= (yas--buffer-contents) "abcabcabcabc"))))
|
(should (string= (yas--buffer-contents) "abcabcabcabc"))))
|
||||||
|
|
||||||
(ert-deftest delete-numberless-inner-snippet-issue-562 ()
|
(ert-deftest delete-numberless-inner-snippet-issue-562 ()
|
||||||
@ -137,7 +137,7 @@
|
|||||||
;; (yas-minor-mode 1)
|
;; (yas-minor-mode 1)
|
||||||
;; (yas-expand-snippet "brother from ${2:another ${3:mother}}!")
|
;; (yas-expand-snippet "brother from ${2:another ${3:mother}}!")
|
||||||
;; (ert-simulate-command '(yas-next-field-or-maybe-expand))
|
;; (ert-simulate-command '(yas-next-field-or-maybe-expand))
|
||||||
;; (ert-simulate-command `(yas-mock-insert "bla"))
|
;; (yas-mock-insert "bla")
|
||||||
;; (ert-simulate-command '(undo))
|
;; (ert-simulate-command '(undo))
|
||||||
;; (should (string= (yas--buffer-contents)
|
;; (should (string= (yas--buffer-contents)
|
||||||
;; "brother from another mother!"))))
|
;; "brother from another mother!"))))
|
||||||
@ -222,7 +222,7 @@
|
|||||||
(snippet "if ${1:condition}\n`yas-selected-text`\nelse\n$3\nend"))
|
(snippet "if ${1:condition}\n`yas-selected-text`\nelse\n$3\nend"))
|
||||||
(yas-expand-snippet snippet)
|
(yas-expand-snippet snippet)
|
||||||
(yas-next-field)
|
(yas-next-field)
|
||||||
(ert-simulate-command `(yas-mock-insert "bbb"))
|
(yas-mock-insert "bbb")
|
||||||
(should (string= (yas--buffer-contents) "if condition\naaa\nelse\nbbb\nend")))))
|
(should (string= (yas--buffer-contents) "if condition\naaa\nelse\nbbb\nend")))))
|
||||||
|
|
||||||
(defmacro yas--with-font-locked-temp-buffer (&rest body)
|
(defmacro yas--with-font-locked-temp-buffer (&rest body)
|
||||||
@ -314,9 +314,9 @@
|
|||||||
\"fail\")}"))
|
\"fail\")}"))
|
||||||
(yas-expand-snippet snippet)
|
(yas-expand-snippet snippet)
|
||||||
(should (string= (yas--buffer-contents) "fail"))
|
(should (string= (yas--buffer-contents) "fail"))
|
||||||
(ert-simulate-command `(yas-mock-insert "foobaaar"))
|
(yas-mock-insert "foobaaar")
|
||||||
(should (string= (yas--buffer-contents) "foobaaarfail"))
|
(should (string= (yas--buffer-contents) "foobaaarfail"))
|
||||||
(ert-simulate-command `(yas-mock-insert "baz"))
|
(yas-mock-insert "baz")
|
||||||
(should (string= (yas--buffer-contents) "foobaaarbazok")))))
|
(should (string= (yas--buffer-contents) "foobaaarbazok")))))
|
||||||
|
|
||||||
|
|
||||||
@ -810,10 +810,9 @@ add the snippets associated with the given mode."
|
|||||||
(yas--buffer-contents))))))
|
(yas--buffer-contents))))))
|
||||||
|
|
||||||
(defun yas-mock-insert (string)
|
(defun yas-mock-insert (string)
|
||||||
(interactive)
|
(dotimes (i (length string))
|
||||||
(do ((i 0 (1+ i)))
|
(let ((last-command-event (aref string i)))
|
||||||
((= i (length string)))
|
(ert-simulate-command '(self-insert-command 1)))))
|
||||||
(insert (aref string i))))
|
|
||||||
|
|
||||||
(defun yas-make-file-or-dirs (ass)
|
(defun yas-make-file-or-dirs (ass)
|
||||||
(let ((file-or-dir-name (car ass))
|
(let ((file-or-dir-name (car ass))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user