2012-08-14 08:38:11 -04:00
|
|
|
# Percent literals.
|
2012-04-24 13:06:12 -04:00
|
|
|
b = %Q{This is a "string"}
|
2012-08-14 08:38:11 -04:00
|
|
|
c = %w!foo
|
2012-04-24 13:06:12 -04:00
|
|
|
bar
|
2012-08-14 08:38:11 -04:00
|
|
|
baz!
|
|
|
|
d = %(hello (nested) world)
|
|
|
|
|
|
|
|
# Don't propertize percent literals inside strings.
|
|
|
|
"(%s, %s)" % [123, 456]
|
|
|
|
|
|
|
|
# Or inside comments.
|
|
|
|
x = # "tot %q/to"; =
|
2013-05-08 16:25:57 -04:00
|
|
|
y = 2 / 3
|
2012-08-14 08:38:11 -04:00
|
|
|
|
|
|
|
# Regexp after whitelisted method.
|
|
|
|
"abc".sub /b/, 'd'
|
|
|
|
|
|
|
|
# Don't mis-match "sub" at the end of words.
|
|
|
|
a = asub / aslb + bsub / bslb;
|
2012-04-24 13:06:12 -04:00
|
|
|
|
2012-08-14 08:38:11 -04:00
|
|
|
# Highlight the regexp after "if".
|
|
|
|
x = toto / foo if /do bar/ =~ "dobar"
|
2012-04-24 13:06:12 -04:00
|
|
|
|
2013-05-19 10:01:23 +04:00
|
|
|
# Multiline regexp.
|
|
|
|
/bars
|
|
|
|
tees # toots
|
|
|
|
nfoos/
|
|
|
|
|
2013-05-08 16:25:57 -04:00
|
|
|
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
|
2013-05-19 10:01:23 +04:00
|
|
|
# Support for this syntax was removed in Ruby 1.9, so we
|
|
|
|
# probably don't need to handle it either.
|
2013-05-08 16:25:57 -04:00
|
|
|
# when "b" :
|
|
|
|
# 7
|
|
|
|
# when "c" : 2
|
|
|
|
when "d" then 4
|
|
|
|
else 5
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-04-24 13:06:12 -04:00
|
|
|
# Some Cucumber code:
|
|
|
|
Given /toto/ do
|
|
|
|
print "hello"
|
|
|
|
end
|
2013-09-03 03:29:10 +03:00
|
|
|
|
|
|
|
# Bug#15208
|
|
|
|
if something == :==
|
|
|
|
do_something
|
|
|
|
end
|