emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master eeb4b62 14/36: Add new tests for multi-line mirror indenta


From: Noam Postavsky
Subject: [elpa] master eeb4b62 14/36: Add new tests for multi-line mirror indentation
Date: Sat, 11 Jun 2016 19:21:10 +0000 (UTC)

branch: master
commit eeb4b62efb636ba7e74d9afdfd14f906b23f9111
Author: João Távora <address@hidden>
Commit: Noam Postavsky <address@hidden>

    Add new tests for multi-line mirror indentation
    
    * yasnippet-tests.el (basic-indentation):
    (navigate-a-snippet-with-multiline-mirrors-issue-665): New tests.
---
 yasnippet-tests.el |   45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/yasnippet-tests.el b/yasnippet-tests.el
index cb5bd47..828d71a 100644
--- a/yasnippet-tests.el
+++ b/yasnippet-tests.el
@@ -193,6 +193,51 @@
     (ert-simulate-command '(yas-prev-field))
     (should (looking-at "little sibling"))))
 
+(ert-deftest basic-indentation ()
+  (with-temp-buffer
+    (ruby-mode)
+    (yas-minor-mode 1)
+    (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")
+    (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")
+    (ert-simulate-command '(yas-next-field))
+    (should (string= "def method(args)
+  class << self
+    
+  end
+end" (buffer-string)))
+    (should (= 4 (current-column)))))
+
+(ert-deftest navigate-a-snippet-with-multiline-mirrors-issue-665 ()
+  "In issue 665, a multi-line mirror is attempted.
+
+Indentation doesn't (yet) happen on these mirrors, but let this
+test guard against any misnavigations that might be introduced by
+an incorrect implementation of mirror auto-indentation"
+  (with-temp-buffer
+    (ruby-mode)
+    (yas-minor-mode 1)
+    (yas-expand-snippet "def initialize(${1:params})\n$2${1:$(
+mapconcat #'(lambda (arg)
+                 (format \"@%s = %s\" arg arg))
+             (split-string yas-text \", \")
+             \"\n\")}\nend")
+    (yas-mock-insert "bla, ble, bli")
+    (ert-simulate-command '(yas-next-field))
+    (let ((expected (mapconcat #'identity
+                               '("@bla = bla"
+                                 "[[:blank:address@hidden = ble"
+                                 "[[:blank:address@hidden = bli")
+                               "\n")))
+      (should (looking-at expected))
+      (yas-mock-insert "blo")
+      (ert-simulate-command '(yas-prev-field))
+      (ert-simulate-command '(yas-next-field))
+      (should (looking-at (concat "blo" expected))))))
+
 
 ;;; Snippet expansion and character escaping
 ;;; Thanks to @zw963 (Billy) for the testing



reply via email to

[Prev in Thread] Current Thread [Next in Thread]