]> code.delx.au - gnu-emacs-elpa/blobdiff - yasnippet-tests.el
Avoid bug in insert-file-contents with REPLACE=t
[gnu-emacs-elpa] / yasnippet-tests.el
index 828d71a968597a3d1e30b3133a1d1f90deb9739b..9d2074aa4f0b6a102e55adf9de9eebf126a5f09d 100644 (file)
     (set (make-local-variable 'yas-indent-line) 'auto)
     (set (make-local-variable 'yas-also-auto-indent-first-line) t)
     (yas-expand-snippet "def ${1:method}${2:(${3:args})}\n$0\nend")
+    ;; Note that empty line is not indented.
+    (should (string= "def method(args)
+
+end" (buffer-string)))
     (cl-loop repeat 3 do (ert-simulate-command '(yas-next-field)))
     (yas-mock-insert (make-string (random 5) ?\ )) ; purposedly mess up indentation
-    (yas-expand-snippet "class << ${self}\n$0\nend")
+    (yas-expand-snippet "class << ${self}\n  $0\nend")
     (ert-simulate-command '(yas-next-field))
     (should (string= "def method(args)
   class << self
 end" (buffer-string)))
     (should (= 4 (current-column)))))
 
+(ert-deftest indentation-markers ()
+  "Test a snippet with indentation markers (`$<')."
+  (with-temp-buffer
+    (ruby-mode)
+    (yas-minor-mode 1)
+    (set (make-local-variable 'yas-indent-line) nil)
+    (yas-expand-snippet "def ${1:method}${2:(${3:args})}\n$>Indent\nNo indent\\$>\nend")
+    (should (string= "def method(args)
+  Indent
+No indent$>
+end" (buffer-string)))))
+
+
 (ert-deftest navigate-a-snippet-with-multiline-mirrors-issue-665 ()
   "In issue 665, a multi-line mirror is attempted.