summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDmitry Gutov <dgutov@yandex.ru>2012-11-13 22:57:26 +0400
committerDmitry Gutov <dgutov@yandex.ru>2012-11-13 22:57:26 +0400
commit5e9419e849410373473691611778572622ea490a (patch)
tree88032e7ebb0ae6815a9e2bda2637e37c153f54ff /test
parenta77b8d5eb0ac3ea68f8a6e647677b1286ab47d30 (diff)
downloademacs-5e9419e849410373473691611778572622ea490a.tar.gz
* lisp/progmodes/ruby-mode.el (ruby-move-to-block): Looks for a block
start/end keyword a bit harder. Works with different values of N. Add more comments. (ruby-end-of-block): Update accordingly. * test/automated/ruby-mode-tests.el (ruby-heredoc-font-lock) (ruby-singleton-class-no-heredoc-font-lock) (ruby-add-log-current-method-examples): New tests. (ruby-test-string): Extract from ruby-should-indent-buffer. (ruby-deftest-move-to-block): New macro. Add several move-to-block tests.
Diffstat (limited to 'test')
-rw-r--r--test/ChangeLog2
-rw-r--r--test/automated/ruby-mode-tests.el48
2 files changed, 50 insertions, 0 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index 44c013e9887..8973a0f1d4f 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -4,6 +4,8 @@
(ruby-singleton-class-no-heredoc-font-lock)
(ruby-add-log-current-method-examples): New tests.
(ruby-test-string): Extract from ruby-should-indent-buffer.
+ (ruby-deftest-move-to-block): New macro.
+ Add several move-to-block tests.
2012-11-12 Stefan Monnier <monnier@iro.umontreal.ca>
diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el
index 0e41b2ba1e2..a8cdd2f3f28 100644
--- a/test/automated/ruby-mode-tests.el
+++ b/test/automated/ruby-mode-tests.el
@@ -283,6 +283,54 @@ VALUES-PLIST is a list with alternating index and value elements."
(should (string= (ruby-add-log-current-method)
(format "M::C%s" value)))))))
+(defvar ruby-block-test-example
+ (ruby-test-string
+ "class C
+ | def foo
+ | 1
+ | end
+ |
+ | def bar
+ | 2
+ | end
+ |
+ | def baz
+ | some do
+ | end
+ | end
+ |end"))
+
+(defmacro ruby-deftest-move-to-block (name &rest body)
+ `(ert-deftest ,(intern (format "ruby-move-to-block-%s" name)) ()
+ (with-temp-buffer
+ (insert ruby-block-test-example)
+ (ruby-mode)
+ ,@body)))
+
+(put 'ruby-deftest-move-to-block 'lisp-indent-function 'defun)
+
+(ruby-deftest-move-to-block works-on-do
+ (goto-line 11)
+ (ruby-end-of-block)
+ (should (= 12 (line-number-at-pos)))
+ (ruby-beginning-of-block)
+ (should (= 11 (line-number-at-pos))))
+
+(ruby-deftest-move-to-block zero-is-noop
+ (goto-line 5)
+ (ruby-move-to-block 0)
+ (should (= 5 (line-number-at-pos))))
+
+(ruby-deftest-move-to-block ok-with-three
+ (goto-line 2)
+ (ruby-move-to-block 3)
+ (should (= 13 (line-number-at-pos))))
+
+(ruby-deftest-move-to-block ok-with-minus-two
+ (goto-line 10)
+ (ruby-move-to-block -2)
+ (should (= 2 (line-number-at-pos))))
+
(provide 'ruby-mode-tests)
;;; ruby-mode-tests.el ends here