summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDmitry Gutov <dgutov@yandex.ru>2012-09-07 08:15:56 +0400
committerDmitry Gutov <dgutov@yandex.ru>2012-09-07 08:15:56 +0400
commit0ba2d4b6465b0b66d34e6ef47c151bd5920fbe54 (patch)
treeadb7447fb81dd81374d12a3765716b8d60e01fe6 /test
parent1d43a35f49f7403f7f50f36dddf88167a7c81f11 (diff)
downloademacs-0ba2d4b6465b0b66d34e6ef47c151bd5920fbe54.tar.gz
* 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/ChangeLog4
-rw-r--r--test/automated/ruby-mode-tests.el25
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 @@
+2012-09-07 Dmitry Gutov <dgutov@yandex.ru>
+
+ * automated/ruby-mode-tests.el: New tests (Bug#11613).
+
2012-08-28 Chong Yidong <cyd@gnu.org>
* 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."
(cadr values-plist)))
(setq values-plist (cddr values-plist)))))
+(defun ruby-assert-face (content pos face)
+ (with-temp-buffer
+ (insert content)
+ (ruby-mode)
+ (font-lock-fontify-buffer)
+ (should (eq face (get-text-property pos 'face)))))
+
(ert-deftest ruby-indent-after-symbol-made-from-string-interpolation ()
"It can indent the line after symbol made using string interpolation."
(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."
(ruby-should-indent "foo = {\na: b" ruby-indent-level)
(ruby-should-indent "foo(\na" ruby-indent-level)))
+(ert-deftest ruby-indent-after-keyword-in-a-string ()
+ (ruby-should-indent "a = \"abc\nif\"\n " 0)
+ (ruby-should-indent "a = %w[abc\n def]\n " 0)
+ (ruby-should-indent "a = \"abc\n def\"\n " 0))
+
(ert-deftest ruby-indent-simple ()
(ruby-should-indent-buffer
"if foo
@@ -217,6 +229,19 @@ VALUES-PLIST is a list with alternating index and value elements."
(should (string= "foo {|b|\n}\n" (buffer-substring-no-properties
(point-min) (point-max))))))
+(ert-deftest ruby-recognize-symbols-starting-with-at-character ()
+ (ruby-assert-face ":@abc" 3 'font-lock-constant-face))
+
+(ert-deftest ruby-hash-character-not-interpolation ()
+ (ruby-assert-face "\"This is #{interpolation}\"" 15
+ 'font-lock-variable-name-face)
+ (ruby-assert-face "\"This is \\#{no interpolation} despite the #\""
+ 15 'font-lock-string-face)
+ (ruby-assert-face "#@comment, not ruby code" 3 'font-lock-comment-face)
+ (ruby-assert-state "#@comment, not ruby code" 4 t)
+ (ruby-assert-face "# A comment cannot have #{an interpolation} in it"
+ 30 'font-lock-comment-face))
+
(provide 'ruby-mode-tests)
;;; ruby-mode-tests.el ends here