diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/ChangeLog | 6 | ||||
| -rw-r--r-- | test/automated/ruby-mode-tests.el | 41 |
2 files changed, 38 insertions, 9 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index 03d43d72b54..86f3019cb08 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2012-08-09 Dmitry Gutov <dgutov@yandex.ru> | ||
| 2 | |||
| 3 | * automated/ruby-mode-tests.el (ruby-should-indent) | ||
| 4 | (ruby-assert-state): New functions. | ||
| 5 | Add new tests. | ||
| 6 | |||
| 1 | 2012-07-29 David Engster <deng@randomsample.de> | 7 | 2012-07-29 David Engster <deng@randomsample.de> |
| 2 | 8 | ||
| 3 | * automated/xml-parse-tests.el (xml-parse-tests--qnames): New | 9 | * automated/xml-parse-tests.el (xml-parse-tests--qnames): New |
diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el index 1a91f518b92..fbe1b8de9ae 100644 --- a/test/automated/ruby-mode-tests.el +++ b/test/automated/ruby-mode-tests.el | |||
| @@ -23,16 +23,39 @@ | |||
| 23 | 23 | ||
| 24 | (require 'ruby-mode) | 24 | (require 'ruby-mode) |
| 25 | 25 | ||
| 26 | (ert-deftest indent-line-after-symbol-made-from-string-interpolation () | 26 | (defun ruby-should-indent (content column) |
| 27 | (with-temp-buffer | ||
| 28 | (insert content) | ||
| 29 | (ruby-mode) | ||
| 30 | (ruby-indent-line) | ||
| 31 | (should (= (current-column) column)))) | ||
| 32 | |||
| 33 | (defun ruby-assert-state (content &rest values-plist) | ||
| 34 | "Assert syntax state values at the end of CONTENT. | ||
| 35 | |||
| 36 | VALUES-PLIST is a list with alternating index and value elements." | ||
| 37 | (with-temp-buffer | ||
| 38 | (insert content) | ||
| 39 | (ruby-mode) | ||
| 40 | (syntax-propertize (point)) | ||
| 41 | (while values-plist | ||
| 42 | (should (eq (nth (car values-plist) | ||
| 43 | (parse-partial-sexp (point-min) (point))) | ||
| 44 | (cadr values-plist))) | ||
| 45 | (setq values-plist (cddr values-plist))))) | ||
| 46 | |||
| 47 | (ert-deftest ruby-indent-after-symbol-made-from-string-interpolation () | ||
| 27 | "It can indent the line after symbol made using string interpolation." | 48 | "It can indent the line after symbol made using string interpolation." |
| 28 | (let ((initial-content "def foo(suffix)\n :\"bar#{suffix}\"\n") | 49 | (ruby-should-indent "def foo(suffix)\n :\"bar#{suffix}\"\n" |
| 29 | (expected-content "def foo(suffix)\n :\"bar#{suffix}\"\n ")) | 50 | ruby-indent-level)) |
| 30 | (with-temp-buffer | 51 | |
| 31 | (insert initial-content) | 52 | (ert-deftest ruby-indent-after-js-style-symbol-with-block-beg-name () |
| 32 | (ruby-indent-line) ; Doesn't rely on text properties or the syntax table. | 53 | "JS-style hash symbol can have keyword name." |
| 33 | (let ((buffer-content (buffer-substring-no-properties (point-min) | 54 | (ruby-should-indent "link_to \"home\", home_path, class: \"foo\"\n" 0)) |
| 34 | (point-max)))) | 55 | |
| 35 | (should (string= buffer-content expected-content)))))) | 56 | (ert-deftest ruby-discern-singleton-class-from-heredoc () |
| 57 | (ruby-assert-state "foo <<asd\n" 3 ?\n) | ||
| 58 | (ruby-assert-state "class <<asd\n" 3 nil)) | ||
| 36 | 59 | ||
| 37 | (provide 'ruby-mode-tests) | 60 | (provide 'ruby-mode-tests) |
| 38 | 61 | ||