mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-14 05:23:04 +00:00
add: external test for issue #404
This commit is contained in:
parent
6c3e0294dd
commit
43a484e943
4
Rakefile
4
Rakefile
@ -13,7 +13,9 @@ FileUtils.mkdir_p('pkg')
|
|||||||
|
|
||||||
desc "run tests in batch mode"
|
desc "run tests in batch mode"
|
||||||
task :tests do
|
task :tests do
|
||||||
sh "#{$EMACS} -Q -L . -l yasnippet-tests.el -nw --batch -e yas-batch-run-tests"
|
batch_run_line = "(yas-batch-run-tests t)"
|
||||||
|
sh "#{$EMACS} -Q -L . -l yasnippet-tests.el -nw" +
|
||||||
|
" --batch --eval '#{batch_run_line}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "convert some textmate bundles to yasnippets"
|
desc "convert some textmate bundles to yasnippets"
|
||||||
|
@ -210,9 +210,41 @@
|
|||||||
(yas-minor-mode 1)
|
(yas-minor-mode 1)
|
||||||
(insert "#include <foo>\n")
|
(insert "#include <foo>\n")
|
||||||
(let ((snippet "main"))
|
(let ((snippet "main"))
|
||||||
(yas-expand-snippet snippet)
|
(let ((yas-good-grace nil)) (yas-expand-snippet snippet))
|
||||||
(should (string= (yas--buffer-contents) "#include <foo>\nmain")))))
|
(should (string= (yas--buffer-contents) "#include <foo>\nmain")))))
|
||||||
|
|
||||||
|
(ert-deftest example-for-issue-404-c-mode ()
|
||||||
|
(with-temp-buffer
|
||||||
|
(c-mode)
|
||||||
|
(yas-minor-mode 1)
|
||||||
|
(insert "#include <foo>\n")
|
||||||
|
(let ((snippet "main"))
|
||||||
|
(let ((yas-good-grace nil)) (yas-expand-snippet snippet))
|
||||||
|
(should (string= (yas--buffer-contents) "#include <foo>\nmain")))))
|
||||||
|
|
||||||
|
(ert-deftest example-for-issue-404-external-emacs ()
|
||||||
|
:tags '(:external)
|
||||||
|
(let ((fixture-el-file (make-temp-file "yas-404-fixture" nil ".el")))
|
||||||
|
(with-temp-buffer
|
||||||
|
(insert (pp-to-string
|
||||||
|
`(condition-case _
|
||||||
|
(progn
|
||||||
|
(require 'yasnippet)
|
||||||
|
(yas-global-mode)
|
||||||
|
(switch-to-buffer "foo.c")
|
||||||
|
(c-mode)
|
||||||
|
(insert "#include <iostream>\nmain")
|
||||||
|
(setq yas-good-grace nil)
|
||||||
|
(yas-expand)
|
||||||
|
(kill-emacs 0))
|
||||||
|
(error (kill-emacs -1)))))
|
||||||
|
(write-file fixture-el-file))
|
||||||
|
(should (= 0
|
||||||
|
(call-process (concat invocation-directory invocation-name)
|
||||||
|
nil nil nil
|
||||||
|
"-Q" ;; "--batch"
|
||||||
|
"-L" "." "-l" fixture-el-file)))))
|
||||||
|
|
||||||
(ert-deftest middle-of-buffer-snippet-insertion ()
|
(ert-deftest middle-of-buffer-snippet-insertion ()
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(yas-minor-mode 1)
|
(yas-minor-mode 1)
|
||||||
@ -572,14 +604,14 @@ TODO: be meaner"
|
|||||||
|
|
||||||
;;; Helpers
|
;;; Helpers
|
||||||
;;;
|
;;;
|
||||||
(defun yas-batch-run-tests ()
|
(defun yas-batch-run-tests (&optional also-external)
|
||||||
(interactive)
|
(interactive)
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(yas--with-temporary-redefinitions
|
(yas--with-temporary-redefinitions
|
||||||
((message (&rest _args) nil))
|
((message (&rest _args) nil))
|
||||||
(ert t (buffer-name (current-buffer)))
|
(ert (or (and also-external t)
|
||||||
(princ (buffer-string)))))
|
'(not (tag :external))) (buffer-name (current-buffer)))
|
||||||
|
(princ (buffer-string)))))
|
||||||
|
|
||||||
(defun yas-should-expand (keys-and-expansions)
|
(defun yas-should-expand (keys-and-expansions)
|
||||||
(dolist (key-and-expansion keys-and-expansions)
|
(dolist (key-and-expansion keys-and-expansions)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user