diff options
| author | Dmitry Gutov | 2012-08-10 16:19:09 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2012-08-10 16:19:09 -0400 |
| commit | 9cd80478d6b6e8fd0eaac516e2f7bb6a5e0041bf (patch) | |
| tree | 993bc6d6f79a492ed56c98dcaac4b12d936eaa22 /test | |
| parent | d301b4133f855c96f425b4793fa13dae3463f392 (diff) | |
| download | emacs-9cd80478d6b6e8fd0eaac516e2f7bb6a5e0041bf.tar.gz emacs-9cd80478d6b6e8fd0eaac516e2f7bb6a5e0041bf.zip | |
Merge stuff from upsteam ruby-mode, part 1.
* lisp/progmodes/ruby-mode.el (ruby-mode-map): Remove deprecated
binding (use `M-;' instead).
(ruby-expr-beg, ruby-parse-partial): ?, _, and : are symbol
constituents, ! is not (but kinda should be).
(ruby-singleton-class-p): New function.
(ruby-expr-beg, ruby-in-here-doc-p)
(ruby-syntax-propertize-heredoc): Use it.
(ruby-syntax-propertize-function): Adjust for changes in
`ruby-syntax-propertize-heredoc'.
* test/automated/ruby-mode-tests.el (ruby-should-indent)
(ruby-assert-state): New functions.
Add new tests.
Fixes: debbugs:12169
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 | ||