From d317a408c3a76c0a2cb473cb6e0b5688f1ee1c44 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Sun, 22 Apr 2012 16:34:12 +0100 Subject: [PATCH] enhancement: test snippet compilation and loading. refactor test helpers --- yasnippet-tests.el | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/yasnippet-tests.el b/yasnippet-tests.el index 3d1830934..157debb82 100755 --- a/yasnippet-tests.el +++ b/yasnippet-tests.el @@ -112,8 +112,31 @@ TODO: correct this bug!" ;;; Loading ;;; -(ert-deftest basic-loading () +(defmacro with-some-interesting-snippet-dirs (&rest body) + `(yas/saving-variables + (with-snippet-dirs + '((".emacs.d/snippets" + ("c-mode" + (".yas-parents" . "cc-mode") + ("printf" . "printf($1);")) + ("emacs-lisp-mode" ("ert-deftest" . "(ert-deftest ${1:name} () $0)")) + ("lisp-interaction-mode" (".yas-parents" . "emacs-lisp-mode"))) + ("library/snippets" + ("c-mode" (".yas-parents" . "c++-mode")) + ("cc-mode" ("def" . "# define")) + ("emacs-lisp-mode" ("dolist" . "(dolist)")) + ("lisp-interaction-mode" ("sc" . "brother from another mother")))) + ,@body))) + +(ert-deftest basic-jit-loading () "Test basic loading and expansion of snippets" + (yas/basic-jit-loading-1)) + +(ert-deftest basic-jit-loading-with-compiled-snippets () + "Test basic loading and expansion of snippets" + (yas/basic-jit-loading-1 'compile)) + +(defun yas/basic-jit-loading-1 (&optional compile) (yas/saving-variables (with-snippet-dirs '((".emacs.d/snippets" @@ -127,7 +150,7 @@ TODO: correct this bug!" ("cc-mode" ("def" . "# define")) ("emacs-lisp-mode" ("dolist" . "(dolist)")) ("lisp-interaction-mode" ("sc" . "brother from another mother")))) - (yas/reload-all 'with-jit) + (yas/reload-all) (with-temp-buffer (should (= 4 (hash-table-count yas/scheduled-jit-loads))) (should (= 0 (hash-table-count yas/tables))) @@ -140,6 +163,7 @@ TODO: correct this bug!" ("dolist" . "(dolist)") ("ert-deftest" . "(ert-deftest name () )"))) (c-mode) + (yas/minor-mode 1) (yas/should-expand '(("printf" . "printf();") ("def" . "# define"))) (yas/should-not-expand '("sc" "dolist" "ert-deftest")))))) -- 2.39.2