From: Dmitry Gutov Date: Fri, 10 Aug 2012 20:25:43 +0000 (-0400) Subject: * test/automated/ruby-mode-tests.el (ruby-should-indent): X-Git-Tag: emacs-24.2.90~730 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9d2ed8a27e459dd09cf3f770bae5127f21debc34;p=emacs.git * test/automated/ruby-mode-tests.el (ruby-should-indent): Add docstring, check (current-indentation) instead of (current-column). (ruby-should-indent-buffer): New function. Add tests for `ruby-deep-indent-paren' behavior. Port all tests from test/misc/test_ruby_mode.rb in Ruby repo. Fixes: debbugs:12169 --- diff --git a/test/ChangeLog b/test/ChangeLog index 86f3019cb08..d5bed2c8dfc 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,11 @@ +2012-08-10 Dmitry Gutov + + * automated/ruby-mode-tests.el (ruby-should-indent): + Add docstring, check (current-indentation) instead of (current-column). + (ruby-should-indent-buffer): New function. + Add tests for `ruby-deep-indent-paren' behavior. + Port all tests from test/misc/test_ruby_mode.rb in Ruby repo. + 2012-08-09 Dmitry Gutov * automated/ruby-mode-tests.el (ruby-should-indent) @@ -6,8 +14,8 @@ 2012-07-29 David Engster - * automated/xml-parse-tests.el (xml-parse-tests--qnames): New - variable to hold test data for name expansion. + * automated/xml-parse-tests.el (xml-parse-tests--qnames): + New variable to hold test data for name expansion. (xml-parse-tests): Test the two different types of name expansion. 2012-07-29 Juri Linkov diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el index fbe1b8de9ae..f91b6e44b22 100644 --- a/test/automated/ruby-mode-tests.el +++ b/test/automated/ruby-mode-tests.el @@ -24,11 +24,24 @@ (require 'ruby-mode) (defun ruby-should-indent (content column) + "Assert indentation COLUMN on the last line of CONTENT." (with-temp-buffer (insert content) (ruby-mode) (ruby-indent-line) - (should (= (current-column) column)))) + (should (= (current-indentation) column)))) + +(defun ruby-should-indent-buffer (expected content) + "Assert that CONTENT turns into EXPECTED after the buffer is re-indented. + +The whitespace before and including \"|\" on each line is removed." + (with-temp-buffer + (cl-flet ((fix-indent (s) (replace-regexp-in-string "^[ \t]*|" "" s))) + (insert (fix-indent content)) + (ruby-mode) + (indent-region (point-min) (point-max)) + (should (string= (fix-indent expected) (buffer-substring-no-properties + (point-min) (point-max))))))) (defun ruby-assert-state (content &rest values-plist) "Assert syntax state values at the end of CONTENT. @@ -57,6 +70,127 @@ VALUES-PLIST is a list with alternating index and value elements." (ruby-assert-state "foo <