diff options
| author | Dmitry Gutov | 2012-11-13 13:30:16 +0400 |
|---|---|---|
| committer | Dmitry Gutov | 2012-11-13 13:30:16 +0400 |
| commit | 5745cae6984ed60299a89485aaea8f2f3fb67382 (patch) | |
| tree | d2566ee6ff5a0d45607b57f56a287374504ce2d9 /test | |
| parent | 2a14f83bbdb59565f3e4bffa8e583270e10cf92c (diff) | |
| download | emacs-5745cae6984ed60299a89485aaea8f2f3fb67382.tar.gz emacs-5745cae6984ed60299a89485aaea8f2f3fb67382.zip | |
* lisp/progmodes/ruby-mode.el (ruby-add-log-current-method): Print the
period before class method names, not after. Remove handling of
one impossible case. Add comments.
* test/automated/ruby-mode-tests.el
(ruby-add-log-current-method-examples): New test.
(ruby-test-string): Extract from ruby-should-indent-buffer.
Diffstat (limited to 'test')
| -rw-r--r-- | test/ChangeLog | 4 | ||||
| -rw-r--r-- | test/automated/ruby-mode-tests.el | 32 |
2 files changed, 30 insertions, 6 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index ad136117c1d..44c013e9887 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,7 +1,9 @@ | |||
| 1 | 2012-11-13 Dmitry Gutov <dgutov@yandex.ru> | 1 | 2012-11-13 Dmitry Gutov <dgutov@yandex.ru> |
| 2 | 2 | ||
| 3 | * automated/ruby-mode-tests.el (ruby-heredoc-font-lock) | 3 | * automated/ruby-mode-tests.el (ruby-heredoc-font-lock) |
| 4 | (ruby-singleton-class-no-heredoc-font-lock): New tests. | 4 | (ruby-singleton-class-no-heredoc-font-lock) |
| 5 | (ruby-add-log-current-method-examples): New tests. | ||
| 6 | (ruby-test-string): Extract from ruby-should-indent-buffer. | ||
| 5 | 7 | ||
| 6 | 2012-11-12 Stefan Monnier <monnier@iro.umontreal.ca> | 8 | 2012-11-12 Stefan Monnier <monnier@iro.umontreal.ca> |
| 7 | 9 | ||
diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el index 741692a07f7..0e41b2ba1e2 100644 --- a/test/automated/ruby-mode-tests.el +++ b/test/automated/ruby-mode-tests.el | |||
| @@ -36,11 +36,13 @@ | |||
| 36 | 36 | ||
| 37 | The whitespace before and including \"|\" on each line is removed." | 37 | The whitespace before and including \"|\" on each line is removed." |
| 38 | (with-temp-buffer | 38 | (with-temp-buffer |
| 39 | (cl-flet ((fix-indent (s) (replace-regexp-in-string "^[ \t]*|" "" s))) | 39 | (insert (ruby-test-string content)) |
| 40 | (insert (fix-indent content)) | 40 | (ruby-mode) |
| 41 | (ruby-mode) | 41 | (indent-region (point-min) (point-max)) |
| 42 | (indent-region (point-min) (point-max)) | 42 | (should (string= (ruby-test-string expected) (buffer-string))))) |
| 43 | (should (string= (fix-indent expected) (buffer-string)))))) | 43 | |
| 44 | (defun ruby-test-string (s &rest args) | ||
| 45 | (apply 'format (replace-regexp-in-string "^[ \t]*|" "" s) args)) | ||
| 44 | 46 | ||
| 45 | (defun ruby-assert-state (content &rest values-plist) | 47 | (defun ruby-assert-state (content &rest values-plist) |
| 46 | "Assert syntax state values at the end of CONTENT. | 48 | "Assert syntax state values at the end of CONTENT. |
| @@ -261,6 +263,26 @@ VALUES-PLIST is a list with alternating index and value elements." | |||
| 261 | (ruby-assert-face "# #{comment}\n \"#{interpolation}\"" 16 | 263 | (ruby-assert-face "# #{comment}\n \"#{interpolation}\"" 16 |
| 262 | 'font-lock-variable-name-face)) | 264 | 'font-lock-variable-name-face)) |
| 263 | 265 | ||
| 266 | (ert-deftest ruby-add-log-current-method-examples () | ||
| 267 | (let ((pairs '(("foo" . "#foo") | ||
| 268 | ("C.foo" . ".foo") | ||
| 269 | ("self.foo" . ".foo")))) | ||
| 270 | (loop for (name . value) in pairs | ||
| 271 | do (with-temp-buffer | ||
| 272 | (insert (ruby-test-string | ||
| 273 | "module M | ||
| 274 | | class C | ||
| 275 | | def %s | ||
| 276 | | end | ||
| 277 | | end | ||
| 278 | |end" | ||
| 279 | name)) | ||
| 280 | (ruby-mode) | ||
| 281 | (search-backward "def") | ||
| 282 | (forward-line) | ||
| 283 | (should (string= (ruby-add-log-current-method) | ||
| 284 | (format "M::C%s" value))))))) | ||
| 285 | |||
| 264 | (provide 'ruby-mode-tests) | 286 | (provide 'ruby-mode-tests) |
| 265 | 287 | ||
| 266 | ;;; ruby-mode-tests.el ends here | 288 | ;;; ruby-mode-tests.el ends here |