diff options
| author | Dmitry Gutov | 2012-11-13 22:57:26 +0400 |
|---|---|---|
| committer | Dmitry Gutov | 2012-11-13 22:57:26 +0400 |
| commit | 5e9419e849410373473691611778572622ea490a (patch) | |
| tree | 88032e7ebb0ae6815a9e2bda2637e37c153f54ff /test | |
| parent | a77b8d5eb0ac3ea68f8a6e647677b1286ab47d30 (diff) | |
| download | emacs-5e9419e849410373473691611778572622ea490a.tar.gz emacs-5e9419e849410373473691611778572622ea490a.zip | |
* 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/ChangeLog | 2 | ||||
| -rw-r--r-- | test/automated/ruby-mode-tests.el | 48 |
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 @@ | |||
| 4 | (ruby-singleton-class-no-heredoc-font-lock) | 4 | (ruby-singleton-class-no-heredoc-font-lock) |
| 5 | (ruby-add-log-current-method-examples): New tests. | 5 | (ruby-add-log-current-method-examples): New tests. |
| 6 | (ruby-test-string): Extract from ruby-should-indent-buffer. | 6 | (ruby-test-string): Extract from ruby-should-indent-buffer. |
| 7 | (ruby-deftest-move-to-block): New macro. | ||
| 8 | Add several move-to-block tests. | ||
| 7 | 9 | ||
| 8 | 2012-11-12 Stefan Monnier <monnier@iro.umontreal.ca> | 10 | 2012-11-12 Stefan Monnier <monnier@iro.umontreal.ca> |
| 9 | 11 | ||
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." | |||
| 283 | (should (string= (ruby-add-log-current-method) | 283 | (should (string= (ruby-add-log-current-method) |
| 284 | (format "M::C%s" value))))))) | 284 | (format "M::C%s" value))))))) |
| 285 | 285 | ||
| 286 | (defvar ruby-block-test-example | ||
| 287 | (ruby-test-string | ||
| 288 | "class C | ||
| 289 | | def foo | ||
| 290 | | 1 | ||
| 291 | | end | ||
| 292 | | | ||
| 293 | | def bar | ||
| 294 | | 2 | ||
| 295 | | end | ||
| 296 | | | ||
| 297 | | def baz | ||
| 298 | | some do | ||
| 299 | | end | ||
| 300 | | end | ||
| 301 | |end")) | ||
| 302 | |||
| 303 | (defmacro ruby-deftest-move-to-block (name &rest body) | ||
| 304 | `(ert-deftest ,(intern (format "ruby-move-to-block-%s" name)) () | ||
| 305 | (with-temp-buffer | ||
| 306 | (insert ruby-block-test-example) | ||
| 307 | (ruby-mode) | ||
| 308 | ,@body))) | ||
| 309 | |||
| 310 | (put 'ruby-deftest-move-to-block 'lisp-indent-function 'defun) | ||
| 311 | |||
| 312 | (ruby-deftest-move-to-block works-on-do | ||
| 313 | (goto-line 11) | ||
| 314 | (ruby-end-of-block) | ||
| 315 | (should (= 12 (line-number-at-pos))) | ||
| 316 | (ruby-beginning-of-block) | ||
| 317 | (should (= 11 (line-number-at-pos)))) | ||
| 318 | |||
| 319 | (ruby-deftest-move-to-block zero-is-noop | ||
| 320 | (goto-line 5) | ||
| 321 | (ruby-move-to-block 0) | ||
| 322 | (should (= 5 (line-number-at-pos)))) | ||
| 323 | |||
| 324 | (ruby-deftest-move-to-block ok-with-three | ||
| 325 | (goto-line 2) | ||
| 326 | (ruby-move-to-block 3) | ||
| 327 | (should (= 13 (line-number-at-pos)))) | ||
| 328 | |||
| 329 | (ruby-deftest-move-to-block ok-with-minus-two | ||
| 330 | (goto-line 10) | ||
| 331 | (ruby-move-to-block -2) | ||
| 332 | (should (= 2 (line-number-at-pos)))) | ||
| 333 | |||
| 286 | (provide 'ruby-mode-tests) | 334 | (provide 'ruby-mode-tests) |
| 287 | 335 | ||
| 288 | ;;; ruby-mode-tests.el ends here | 336 | ;;; ruby-mode-tests.el ends here |