1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-21 05:00:47 -08:00
emacs/test/indent/ruby.rb
Dmitry Gutov 1a0a0a8a6a * 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.
2013-05-19 10:01:23 +04:00

68 lines
1,015 B
Ruby

# Percent literals.
b = %Q{This is a "string"}
c = %w!foo
bar
baz!
d = %(hello (nested) world)
# Don't propertize percent literals inside strings.
"(%s, %s)" % [123, 456]
# Or inside comments.
x = # "tot %q/to"; =
y = 2 / 3
# Regexp after whitelisted method.
"abc".sub /b/, 'd'
# Don't mis-match "sub" at the end of words.
a = asub / aslb + bsub / bslb;
# Highlight the regexp after "if".
x = toto / foo if /do bar/ =~ "dobar"
# Multiline regexp.
/bars
tees # toots
nfoos/
def test1(arg)
puts "hello"
end
def test2 (arg)
a = "apple"
if a == 2
puts "hello"
else
puts "there"
end
if a == 2 then
puts "hello"
elsif a == 3
puts "hello3"
elsif a == 3 then
puts "hello3"
else
puts "there"
end
case a
when "a"
6
# Support for this syntax was removed in Ruby 1.9, so we
# probably don't need to handle it either.
# when "b" :
# 7
# when "c" : 2
when "d" then 4
else 5
end
end
# Some Cucumber code:
Given /toto/ do
print "hello"
end