diff options
| author | Dmitry Gutov | 2012-09-07 08:15:56 +0400 |
|---|---|---|
| committer | Dmitry Gutov | 2012-09-07 08:15:56 +0400 |
| commit | 0ba2d4b6465b0b66d34e6ef47c151bd5920fbe54 (patch) | |
| tree | adb7447fb81dd81374d12a3765716b8d60e01fe6 /test | |
| parent | 1d43a35f49f7403f7f50f36dddf88167a7c81f11 (diff) | |
| download | emacs-0ba2d4b6465b0b66d34e6ef47c151bd5920fbe54.tar.gz emacs-0ba2d4b6465b0b66d34e6ef47c151bd5920fbe54.zip | |
* lisp/progmodes/ruby-mode.el (ruby-indent-beg-re): Add pieces from
ruby-beginning-of-indent, simplify, allow all keywords to have
indentation before them.
(ruby-beginning-of-indent): Adjust for above. Search until the
found point is not inside a string or comment.
(ruby-font-lock-keywords): Allow symbols to start with "@"
character, give them higher priority than variables.
(ruby-syntax-propertize-function)
(ruby-font-lock-syntactic-keywords): Remove the "not comments"
matchers. Expression expansions are not comments when inside a
string, and there comment syntax status is irrelevant.
(ruby-match-expression-expansion): New function. Check that
expression expansion is inside a string, and it's not escaped.
(ruby-font-lock-keywords): Use it.
* test/automated/ruby-mode-tests.el: New tests (Bug#11613).
Diffstat (limited to 'test')
| -rw-r--r-- | test/ChangeLog | 4 | ||||
| -rw-r--r-- | test/automated/ruby-mode-tests.el | 25 |
2 files changed, 29 insertions, 0 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index f523f6f59a9..541937ec4e7 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2012-09-07 Dmitry Gutov <dgutov@yandex.ru> | ||
| 2 | |||
| 3 | * automated/ruby-mode-tests.el: New tests (Bug#11613). | ||
| 4 | |||
| 1 | 2012-08-28 Chong Yidong <cyd@gnu.org> | 5 | 2012-08-28 Chong Yidong <cyd@gnu.org> |
| 2 | 6 | ||
| 3 | * automated/files.el: Test every combination of values for | 7 | * automated/files.el: Test every combination of values for |
diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el index df51aa0d15a..1adc4acdfa0 100644 --- a/test/automated/ruby-mode-tests.el +++ b/test/automated/ruby-mode-tests.el | |||
| @@ -57,6 +57,13 @@ VALUES-PLIST is a list with alternating index and value elements." | |||
| 57 | (cadr values-plist))) | 57 | (cadr values-plist))) |
| 58 | (setq values-plist (cddr values-plist))))) | 58 | (setq values-plist (cddr values-plist))))) |
| 59 | 59 | ||
| 60 | (defun ruby-assert-face (content pos face) | ||
| 61 | (with-temp-buffer | ||
| 62 | (insert content) | ||
| 63 | (ruby-mode) | ||
| 64 | (font-lock-fontify-buffer) | ||
| 65 | (should (eq face (get-text-property pos 'face))))) | ||
| 66 | |||
| 60 | (ert-deftest ruby-indent-after-symbol-made-from-string-interpolation () | 67 | (ert-deftest ruby-indent-after-symbol-made-from-string-interpolation () |
| 61 | "It can indent the line after symbol made using string interpolation." | 68 | "It can indent the line after symbol made using string interpolation." |
| 62 | (ruby-should-indent "def foo(suffix)\n :\"bar#{suffix}\"\n" | 69 | (ruby-should-indent "def foo(suffix)\n :\"bar#{suffix}\"\n" |
| @@ -84,6 +91,11 @@ VALUES-PLIST is a list with alternating index and value elements." | |||
| 84 | (ruby-should-indent "foo = {\na: b" ruby-indent-level) | 91 | (ruby-should-indent "foo = {\na: b" ruby-indent-level) |
| 85 | (ruby-should-indent "foo(\na" ruby-indent-level))) | 92 | (ruby-should-indent "foo(\na" ruby-indent-level))) |
| 86 | 93 | ||
| 94 | (ert-deftest ruby-indent-after-keyword-in-a-string () | ||
| 95 | (ruby-should-indent "a = \"abc\nif\"\n " 0) | ||
| 96 | (ruby-should-indent "a = %w[abc\n def]\n " 0) | ||
| 97 | (ruby-should-indent "a = \"abc\n def\"\n " 0)) | ||
| 98 | |||
| 87 | (ert-deftest ruby-indent-simple () | 99 | (ert-deftest ruby-indent-simple () |
| 88 | (ruby-should-indent-buffer | 100 | (ruby-should-indent-buffer |
| 89 | "if foo | 101 | "if foo |
| @@ -217,6 +229,19 @@ VALUES-PLIST is a list with alternating index and value elements." | |||
| 217 | (should (string= "foo {|b|\n}\n" (buffer-substring-no-properties | 229 | (should (string= "foo {|b|\n}\n" (buffer-substring-no-properties |
| 218 | (point-min) (point-max)))))) | 230 | (point-min) (point-max)))))) |
| 219 | 231 | ||
| 232 | (ert-deftest ruby-recognize-symbols-starting-with-at-character () | ||
| 233 | (ruby-assert-face ":@abc" 3 'font-lock-constant-face)) | ||
| 234 | |||
| 235 | (ert-deftest ruby-hash-character-not-interpolation () | ||
| 236 | (ruby-assert-face "\"This is #{interpolation}\"" 15 | ||
| 237 | 'font-lock-variable-name-face) | ||
| 238 | (ruby-assert-face "\"This is \\#{no interpolation} despite the #\"" | ||
| 239 | 15 'font-lock-string-face) | ||
| 240 | (ruby-assert-face "#@comment, not ruby code" 3 'font-lock-comment-face) | ||
| 241 | (ruby-assert-state "#@comment, not ruby code" 4 t) | ||
| 242 | (ruby-assert-face "# A comment cannot have #{an interpolation} in it" | ||
| 243 | 30 'font-lock-comment-face)) | ||
| 244 | |||
| 220 | (provide 'ruby-mode-tests) | 245 | (provide 'ruby-mode-tests) |
| 221 | 246 | ||
| 222 | ;;; ruby-mode-tests.el ends here | 247 | ;;; ruby-mode-tests.el ends here |