aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDmitry Gutov2012-09-09 03:32:25 +0400
committerDmitry Gutov2012-09-09 03:32:25 +0400
commitc3268831411fd68ce4f6f84ecda5eda2814a59a8 (patch)
tree73bf19e8bfbead6b975c923d0df4d7d44ae4a7bf /test
parent9d7f18633a3f36de96bb42d856355c5ce12f2b5d (diff)
downloademacs-c3268831411fd68ce4f6f84ecda5eda2814a59a8.tar.gz
emacs-c3268831411fd68ce4f6f84ecda5eda2814a59a8.zip
* lisp/progmodes/ruby-mode.el (ruby-toggle-block): Guess the current block,
not just expect to be at its beginning. Adjust callees. Succeed when do-end block has no space before the pipe character. (ruby-brace-to-do-end): When the original block is one-liner, convert to multiline. Reindent the result. * test/automated/ruby-mode-tests.el: (ruby-toggle-block-to-multiline): New test. (ruby-should-indent-buffer, ruby-toggle-block-to-do-end) (ruby-toggle-block-to-brace): Use buffer-string.
Diffstat (limited to 'test')
-rw-r--r--test/ChangeLog7
-rw-r--r--test/automated/ruby-mode-tests.el25
2 files changed, 22 insertions, 10 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index 541937ec4e7..a7e22aa9ae1 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,10 @@
12012-09-08 Dmitry Gutov <dgutov@yandex.ru>
2
3 * automated/ruby-mode-tests.el:
4 (ruby-toggle-block-to-multiline): New test.
5 (ruby-should-indent-buffer, ruby-toggle-block-to-do-end)
6 (ruby-toggle-block-to-brace): Use buffer-string.
7
12012-09-07 Dmitry Gutov <dgutov@yandex.ru> 82012-09-07 Dmitry Gutov <dgutov@yandex.ru>
2 9
3 * automated/ruby-mode-tests.el: New tests (Bug#11613). 10 * automated/ruby-mode-tests.el: New tests (Bug#11613).
diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el
index 515353bc2d0..e711b52fb9c 100644
--- a/test/automated/ruby-mode-tests.el
+++ b/test/automated/ruby-mode-tests.el
@@ -40,8 +40,7 @@ The whitespace before and including \"|\" on each line is removed."
40 (insert (fix-indent content)) 40 (insert (fix-indent content))
41 (ruby-mode) 41 (ruby-mode)
42 (indent-region (point-min) (point-max)) 42 (indent-region (point-min) (point-max))
43 (should (string= (fix-indent expected) (buffer-substring-no-properties 43 (should (string= (fix-indent expected) (buffer-string))))))
44 (point-min) (point-max)))))))
45 44
46(defun ruby-assert-state (content &rest values-plist) 45(defun ruby-assert-state (content &rest values-plist)
47 "Assert syntax state values at the end of CONTENT. 46 "Assert syntax state values at the end of CONTENT.
@@ -213,21 +212,27 @@ VALUES-PLIST is a list with alternating index and value elements."
213 212
214(ert-deftest ruby-toggle-block-to-do-end () 213(ert-deftest ruby-toggle-block-to-do-end ()
215 (with-temp-buffer 214 (with-temp-buffer
216 (insert "foo {|b|\n}\n") 215 (insert "foo {|b|\n}")
217 (ruby-mode) 216 (ruby-mode)
218 (search-backward "{") 217 (beginning-of-line)
219 (ruby-toggle-block) 218 (ruby-toggle-block)
220 (should (string= "foo do |b|\nend\n" (buffer-substring-no-properties 219 (should (string= "foo do |b|\nend" (buffer-string)))))
221 (point-min) (point-max))))))
222 220
223(ert-deftest ruby-toggle-block-to-brace () 221(ert-deftest ruby-toggle-block-to-brace ()
224 (with-temp-buffer 222 (with-temp-buffer
225 (insert "foo do |b|\nend\n") 223 (insert "foo do |b|\nend")
226 (ruby-mode) 224 (ruby-mode)
227 (search-backward "do") 225 (beginning-of-line)
226 (ruby-toggle-block)
227 (should (string= "foo {|b|\n}" (buffer-string)))))
228
229(ert-deftest ruby-toggle-block-to-multiline ()
230 (with-temp-buffer
231 (insert "foo {|b| b + 1}")
232 (ruby-mode)
233 (beginning-of-line)
228 (ruby-toggle-block) 234 (ruby-toggle-block)
229 (should (string= "foo {|b|\n}\n" (buffer-substring-no-properties 235 (should (string= "foo do |b|\n b + 1\nend" (buffer-string)))))
230 (point-min) (point-max))))))
231 236
232(ert-deftest ruby-recognize-symbols-starting-with-at-character () 237(ert-deftest ruby-recognize-symbols-starting-with-at-character ()
233 (ruby-assert-face ":@abc" 3 'font-lock-constant-face)) 238 (ruby-assert-face ":@abc" 3 'font-lock-constant-face))