aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDmitry Gutov2022-12-19 21:01:27 +0200
committerDmitry Gutov2022-12-19 21:06:07 +0200
commit2b1fdbffcb595bcd72fa9aa3db674c6985042bcb (patch)
treed096889d882ed2d06cf548bbadb4bdea294440f4 /test
parentb9e813f79f2d7afb5f14caad17a865e66af17f15 (diff)
downloademacs-2b1fdbffcb595bcd72fa9aa3db674c6985042bcb.tar.gz
emacs-2b1fdbffcb595bcd72fa9aa3db674c6985042bcb.zip
ruby-method-params-indent: New user option
* lisp/progmodes/ruby-mode.el (ruby-method-params-indent): New option (bug#60110). (ruby-smie-rules): Use it. * etc/NEWS: Mention it. * test/lisp/progmodes/ruby-mode-resources/ruby.rb: Ensure the var's value is default. * test/lisp/progmodes/ruby-mode-resources/ruby-method-params-indent.rb: New file. * test/lisp/progmodes/ruby-mode-tests.el (ruby-deftest-indent): New macro, use it to run the indentation test using the new file. Disable the :expensive-test tag, because neither runs for "longer than some few seconds", both take significantly below 1s.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/progmodes/ruby-mode-resources/ruby-method-params-indent.rb18
-rw-r--r--test/lisp/progmodes/ruby-mode-resources/ruby.rb4
-rw-r--r--test/lisp/progmodes/ruby-mode-tests.el24
3 files changed, 36 insertions, 10 deletions
diff --git a/test/lisp/progmodes/ruby-mode-resources/ruby-method-params-indent.rb b/test/lisp/progmodes/ruby-mode-resources/ruby-method-params-indent.rb
new file mode 100644
index 00000000000..2b665797397
--- /dev/null
+++ b/test/lisp/progmodes/ruby-mode-resources/ruby-method-params-indent.rb
@@ -0,0 +1,18 @@
1class C
2 def self.foo(
3 baz,
4 bar
5 ) =
6 what
7
8 def foo=(
9 baz,
10 bar
11 )
12 hello
13 end
14end
15
16# Local Variables:
17# ruby-method-params-indent: 0
18# End:
diff --git a/test/lisp/progmodes/ruby-mode-resources/ruby.rb b/test/lisp/progmodes/ruby-mode-resources/ruby.rb
index 2451edaee22..6a69d9db78a 100644
--- a/test/lisp/progmodes/ruby-mode-resources/ruby.rb
+++ b/test/lisp/progmodes/ruby-mode-resources/ruby.rb
@@ -538,3 +538,7 @@ class Bar
538 baz 538 baz
539 end 539 end
540end 540end
541
542# Local Variables:
543# ruby-method-params-indent: t
544# End:
diff --git a/test/lisp/progmodes/ruby-mode-tests.el b/test/lisp/progmodes/ruby-mode-tests.el
index 9be01dc78f9..560f780285a 100644
--- a/test/lisp/progmodes/ruby-mode-tests.el
+++ b/test/lisp/progmodes/ruby-mode-tests.el
@@ -943,16 +943,20 @@ VALUES-PLIST is a list with alternating index and value elements."
943 "Blub#bye" 943 "Blub#bye"
944 "Blub#hiding"))))) 944 "Blub#hiding")))))
945 945
946(ert-deftest ruby--indent/converted-from-manual-test () 946(defmacro ruby-deftest-indent (file)
947 :tags '(:expensive-test) 947 `(ert-deftest ,(intern (format "ruby-indent-test/%s" file)) ()
948 ;; Converted from manual test. 948 ;; :tags '(:expensive-test)
949 (let ((buf (find-file-noselect (ert-resource-file "ruby.rb")))) 949 (let ((buf (find-file-noselect (ert-resource-file ,file))))
950 (unwind-protect 950 (unwind-protect
951 (with-current-buffer buf 951 (with-current-buffer buf
952 (let ((orig (buffer-string))) 952 (let ((orig (buffer-string)))
953 (indent-region (point-min) (point-max)) 953 ;; Indent and check that we get the original text.
954 (should (equal (buffer-string) orig)))) 954 (indent-region (point-min) (point-max))
955 (kill-buffer buf)))) 955 (should (equal (buffer-string) orig))))
956 (kill-buffer buf)))))
957
958(ruby-deftest-indent "ruby.rb")
959(ruby-deftest-indent "ruby-method-params-indent.rb")
956 960
957(ert-deftest ruby--test-chained-indentation () 961(ert-deftest ruby--test-chained-indentation ()
958 (with-temp-buffer 962 (with-temp-buffer