summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDmitry Gutov <dgutov@yandex.ru>2012-08-10 16:19:09 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2012-08-10 16:19:09 -0400
commit9cd80478d6b6e8fd0eaac516e2f7bb6a5e0041bf (patch)
tree993bc6d6f79a492ed56c98dcaac4b12d936eaa22 /test
parentd301b4133f855c96f425b4793fa13dae3463f392 (diff)
downloademacs-9cd80478d6b6e8fd0eaac516e2f7bb6a5e0041bf.tar.gz
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/ChangeLog6
-rw-r--r--test/automated/ruby-mode-tests.el41
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 @@
+2012-08-09 Dmitry Gutov <dgutov@yandex.ru>
+
+ * automated/ruby-mode-tests.el (ruby-should-indent)
+ (ruby-assert-state): New functions.
+ Add new tests.
+
2012-07-29 David Engster <deng@randomsample.de>
* 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 @@
(require 'ruby-mode)
-(ert-deftest indent-line-after-symbol-made-from-string-interpolation ()
+(defun ruby-should-indent (content column)
+ (with-temp-buffer
+ (insert content)
+ (ruby-mode)
+ (ruby-indent-line)
+ (should (= (current-column) column))))
+
+(defun ruby-assert-state (content &rest values-plist)
+ "Assert syntax state values at the end of CONTENT.
+
+VALUES-PLIST is a list with alternating index and value elements."
+ (with-temp-buffer
+ (insert content)
+ (ruby-mode)
+ (syntax-propertize (point))
+ (while values-plist
+ (should (eq (nth (car values-plist)
+ (parse-partial-sexp (point-min) (point)))
+ (cadr values-plist)))
+ (setq values-plist (cddr values-plist)))))
+
+(ert-deftest ruby-indent-after-symbol-made-from-string-interpolation ()
"It can indent the line after symbol made using string interpolation."
- (let ((initial-content "def foo(suffix)\n :\"bar#{suffix}\"\n")
- (expected-content "def foo(suffix)\n :\"bar#{suffix}\"\n "))
- (with-temp-buffer
- (insert initial-content)
- (ruby-indent-line) ; Doesn't rely on text properties or the syntax table.
- (let ((buffer-content (buffer-substring-no-properties (point-min)
- (point-max))))
- (should (string= buffer-content expected-content))))))
+ (ruby-should-indent "def foo(suffix)\n :\"bar#{suffix}\"\n"
+ ruby-indent-level))
+
+(ert-deftest ruby-indent-after-js-style-symbol-with-block-beg-name ()
+ "JS-style hash symbol can have keyword name."
+ (ruby-should-indent "link_to \"home\", home_path, class: \"foo\"\n" 0))
+
+(ert-deftest ruby-discern-singleton-class-from-heredoc ()
+ (ruby-assert-state "foo <<asd\n" 3 ?\n)
+ (ruby-assert-state "class <<asd\n" 3 nil))
(provide 'ruby-mode-tests)