diff options
| author | Dmitry Gutov | 2013-05-19 10:01:23 +0400 |
|---|---|---|
| committer | Dmitry Gutov | 2013-05-19 10:01:23 +0400 |
| commit | 1a0a0a8a6a7c4cb47bb0d9bb5d3efa281cb70546 (patch) | |
| tree | 9b1f66299f4384ac3bca1bc4044a2548077aacbb /test | |
| parent | c1a6c0a42021df3d41ba782460965c5cc0ae902c (diff) | |
| download | emacs-1a0a0a8a6a7c4cb47bb0d9bb5d3efa281cb70546.tar.gz emacs-1a0a0a8a6a7c4cb47bb0d9bb5d3efa281cb70546.zip | |
* lisp/progmodes/ruby-mode.el (ruby-expression-expansion-re): Allow to
start at point, so that expansion starting right after opening
slash in a regexp is recognized.
(ruby-syntax-before-regexp-re): New defvar, extracted from
ruby-syntax-propertize-function. Since the value of this regexp
is looked up at runtime now, we should be able to turn
`ruby-syntax-methods-before-regexp' into a defcustom later.
(ruby-syntax-propertize-function): Split regexp matching into two
parts, for opening and closing slashes. That allows us to skip
over string interpolations and support multiline regexps.
Don't call `ruby-syntax-propertize-expansions', instead use another rule
for them, which calls `ruby-syntax-propertize-expansion'.
(ruby-syntax-propertize-expansions): Move `remove-text-properties'
call to `ruby-syntax-propertize-function'.
(ruby-syntax-propertize-expansion): Extracted from
`ruby-syntax-propertize-expansions'. Handles one expansion.
(ruby-syntax-propertize-heredoc): Explicitly call
`ruby-syntax-propertize-expansions'.
(ruby-syntax-propertize-percent-literal): Leave point right after
the percent symbol, so that the expression expansion rule can
propertize the contents.
* test/automated/ruby-mode-tests.el (ruby-heredoc-highlights-interpolations)
(ruby-regexp-skips-over-interpolation)
(ruby-regexp-continues-till-end-when-unclosed)
(ruby-regexp-can-be-multiline)
(ruby-interpolation-inside-percent-literal): New tests.
* test/indent/ruby.rb: Add multiline regexp example.
Diffstat (limited to 'test')
| -rw-r--r-- | test/ChangeLog | 10 | ||||
| -rw-r--r-- | test/automated/ruby-mode-tests.el | 19 | ||||
| -rw-r--r-- | test/indent/ruby.rb | 7 |
3 files changed, 36 insertions, 0 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index c11d5d26c13..5c17e09e962 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2013-05-19 Dmitry Gutov <dgutov@yandex.ru> | ||
| 2 | |||
| 3 | * indent/ruby.rb: Add multiline regexp example. | ||
| 4 | |||
| 5 | * automated/ruby-mode-tests.el (ruby-heredoc-highlights-interpolations) | ||
| 6 | (ruby-regexp-skips-over-interpolation) | ||
| 7 | (ruby-regexp-continues-till-end-when-unclosed) | ||
| 8 | (ruby-regexp-can-be-multiline) | ||
| 9 | (ruby-interpolation-inside-percent-literal): New tests. | ||
| 10 | |||
| 1 | 2013-05-08 Stefan Monnier <monnier@iro.umontreal.ca> | 11 | 2013-05-08 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 12 | ||
| 3 | * indent/ruby.rb: Fix indentation after =; add more cases. | 13 | * indent/ruby.rb: Fix indentation after =; add more cases. |
diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el index 23dc45ad509..e52927a2968 100644 --- a/test/automated/ruby-mode-tests.el +++ b/test/automated/ruby-mode-tests.el | |||
| @@ -84,6 +84,9 @@ VALUES-PLIST is a list with alternating index and value elements." | |||
| 84 | (ert-deftest ruby-singleton-class-no-heredoc-font-lock () | 84 | (ert-deftest ruby-singleton-class-no-heredoc-font-lock () |
| 85 | (ruby-assert-face "class<<a" 8 nil)) | 85 | (ruby-assert-face "class<<a" 8 nil)) |
| 86 | 86 | ||
| 87 | (ert-deftest ruby-heredoc-highlights-interpolations () | ||
| 88 | (ruby-assert-face "s = <<EOS\n #{foo}\nEOS" 15 font-lock-variable-name-face)) | ||
| 89 | |||
| 87 | (ert-deftest ruby-deep-indent () | 90 | (ert-deftest ruby-deep-indent () |
| 88 | (let ((ruby-deep-arglist nil) | 91 | (let ((ruby-deep-arglist nil) |
| 89 | (ruby-deep-indent-paren '(?\( ?\{ ?\[ ?\] t))) | 92 | (ruby-deep-indent-paren '(?\( ?\{ ?\[ ?\] t))) |
| @@ -109,6 +112,15 @@ VALUES-PLIST is a list with alternating index and value elements." | |||
| 109 | (ert-deftest ruby-regexp-starts-after-string () | 112 | (ert-deftest ruby-regexp-starts-after-string () |
| 110 | (ruby-assert-state "'(/', /\d+/" 3 ?/ 8)) | 113 | (ruby-assert-state "'(/', /\d+/" 3 ?/ 8)) |
| 111 | 114 | ||
| 115 | (ert-deftest ruby-regexp-skips-over-interpolation () | ||
| 116 | (ruby-assert-state "/#{foobs.join('/')}/" 3 nil)) | ||
| 117 | |||
| 118 | (ert-deftest ruby-regexp-continues-till-end-when-unclosed () | ||
| 119 | (ruby-assert-state "/bars" 3 ?/)) | ||
| 120 | |||
| 121 | (ert-deftest ruby-regexp-can-be-multiline () | ||
| 122 | (ruby-assert-state "/bars\ntees # toots \nfoos/" 3 nil)) | ||
| 123 | |||
| 112 | (ert-deftest ruby-indent-simple () | 124 | (ert-deftest ruby-indent-simple () |
| 113 | (ruby-should-indent-buffer | 125 | (ruby-should-indent-buffer |
| 114 | "if foo | 126 | "if foo |
| @@ -325,6 +337,13 @@ VALUES-PLIST is a list with alternating index and value elements." | |||
| 325 | (search-forward "tee") | 337 | (search-forward "tee") |
| 326 | (should (string= (thing-at-point 'symbol) "tee"))))) | 338 | (should (string= (thing-at-point 'symbol) "tee"))))) |
| 327 | 339 | ||
| 340 | (ert-deftest ruby-interpolation-inside-percent-literal () | ||
| 341 | (let ((s "%( #{boo} )")) | ||
| 342 | (ruby-assert-face s 1 font-lock-string-face) | ||
| 343 | (ruby-assert-face s 4 font-lock-variable-name-face) | ||
| 344 | (ruby-assert-face s 10 font-lock-string-face) | ||
| 345 | (ruby-assert-state s 8 nil))) | ||
| 346 | |||
| 328 | (ert-deftest ruby-interpolation-inside-percent-literal-with-paren () | 347 | (ert-deftest ruby-interpolation-inside-percent-literal-with-paren () |
| 329 | :expected-result :failed | 348 | :expected-result :failed |
| 330 | (let ((s "%(^#{\")\"}^)")) | 349 | (let ((s "%(^#{\")\"}^)")) |
diff --git a/test/indent/ruby.rb b/test/indent/ruby.rb index 90c6dcdc65c..853f4dbf992 100644 --- a/test/indent/ruby.rb +++ b/test/indent/ruby.rb | |||
| @@ -21,6 +21,11 @@ a = asub / aslb + bsub / bslb; | |||
| 21 | # Highlight the regexp after "if". | 21 | # Highlight the regexp after "if". |
| 22 | x = toto / foo if /do bar/ =~ "dobar" | 22 | x = toto / foo if /do bar/ =~ "dobar" |
| 23 | 23 | ||
| 24 | # Multiline regexp. | ||
| 25 | /bars | ||
| 26 | tees # toots | ||
| 27 | nfoos/ | ||
| 28 | |||
| 24 | def test1(arg) | 29 | def test1(arg) |
| 25 | puts "hello" | 30 | puts "hello" |
| 26 | end | 31 | end |
| @@ -47,6 +52,8 @@ def test2 (arg) | |||
| 47 | case a | 52 | case a |
| 48 | when "a" | 53 | when "a" |
| 49 | 6 | 54 | 6 |
| 55 | # Support for this syntax was removed in Ruby 1.9, so we | ||
| 56 | # probably don't need to handle it either. | ||
| 50 | # when "b" : | 57 | # when "b" : |
| 51 | # 7 | 58 | # 7 |
| 52 | # when "c" : 2 | 59 | # when "c" : 2 |