(ert-simulate-command `(yas-mock-insert "abc"))
(should (string= (yas--buffer-contents) "abcabcabcabc"))))
+(ert-deftest delete-numberless-inner-snippet-issue-562 ()
+ (with-temp-buffer
+ (yas-minor-mode 1)
+ (yas-expand-snippet "${3:${test}bla}$0${2:ble}")
+ (ert-simulate-command '(yas-next-field-or-maybe-expand))
+ (should (looking-at "testblable"))
+ (ert-simulate-command '(yas-next-field-or-maybe-expand))
+ (ert-simulate-command '(yas-skip-and-clear-or-delete-char))
+ (should (looking-at "ble"))
+ (should (null (yas--snippets-at-point)))))
+
;; (ert-deftest in-snippet-undo ()
;; (with-temp-buffer
;; (yas-minor-mode 1)
(ert-deftest be-careful-when-escaping-in-yas-selected-text-2 ()
(with-temp-buffer
+ (yas-minor-mode 1)
(let ((yas-selected-text "He)}o world!"))
(yas-expand-snippet "Look ma! ${1:`(yas-selected-text)`} OK?")
(should (string= (yas--buffer-contents) "Look ma! He)}o world! OK?")))))
(yas-saving-variables
(yas-with-snippet-dirs
'((".emacs.d/snippets"
- ("text-mode"
+ ("emacs-lisp-mode"
("foo-barbaz" . "# condition: yas--foobarbaz\n# --\nOKfoo-barbazOK")
("barbaz" . "# condition: yas--barbaz\n# --\nOKbarbazOK")
- ("baz" . "OKbazOK"))))
+ ("baz" . "OKbazOK")
+ ("'quote" . "OKquoteOK"))))
(yas-reload-all)
- (text-mode)
+ (emacs-lisp-mode)
(yas-minor-mode-on)
(let ((yas-key-syntaxes '("w" "w_")))
(let ((yas--barbaz t))
(let ((yas--foobarbaz t))
(yas-should-expand '(("foo-barbaz" . "OKfoo-barbazOK"))))
(let ((yas-key-syntaxes
- (cons #'(lambda ()
+ (cons #'(lambda (_start-point)
(unless (looking-back "-")
(backward-char)
'again))
yas-key-syntaxes))
(yas--foobarbaz t))
- (yas-should-expand '(("foo-barbaz" . "foo-barOKbazOK")))))))))
+ (yas-should-expand '(("foo-barbaz" . "foo-barOKbazOK")))))
+ (let ((yas-key-syntaxes '(yas-try-key-from-whitespace)))
+ (yas-should-expand '(("xxx\n'quote" . "xxx\nOKquoteOK")
+ ("xxx 'quote" . "xxx OKquoteOK"))))
+ (let ((yas-key-syntaxes '(yas-shortest-key-until-whitespace))
+ (yas--foobarbaz t) (yas--barbaz t))
+ (yas-should-expand '(("foo-barbaz" . "foo-barOKbazOK")))
+ (setq yas-key-syntaxes '(yas-longest-key-from-whitespace))
+ (yas-should-expand '(("foo-barbaz" . "OKfoo-barbazOK")
+ ("foo " . "foo "))))))))
\f
;;; Loading
(should (= (length expected)
(length observed)))))))
+(ert-deftest issue-504-tricky-jit ()
+ (define-derived-mode yas--test-mode c-mode "Just a test mode")
+ (define-derived-mode yas--another-test-mode c-mode "Another test mode")
+ (yas-with-snippet-dirs
+ '((".emacs.d/snippets"
+ ("yas--another-test-mode"
+ (".yas-parents" . "yas--test-mode"))
+ ("yas--test-mode")))
+ (let ((b (with-current-buffer (generate-new-buffer "*yas-test*")
+ (yas--another-test-mode)
+ (current-buffer))))
+ (unwind-protect
+ (progn
+ (yas-reload-all)
+ (should (= 0 (hash-table-count yas--scheduled-jit-loads))))
+ (kill-buffer b)))))
+
(defun yas--basic-jit-loading-1 ()
(with-temp-buffer
(should (= 4 (hash-table-count yas--scheduled-jit-loads)))
(provide 'yasnippet-tests)
-;;; yasnippet-tests.el ends here
;; Local Variables:
+;; indent-tabs-mode: nil
;; lexical-binding: t
;; byte-compile-warnings: (not cl-functions)
;; End:
+;;; yasnippet-tests.el ends here