ruby.rb 1.15 KB
Newer Older
1
# Percent literals.
2
b = %Q{This is a "string"}
3
c = %w!foo
4
 bar
5 6 7 8 9 10 11 12
 baz!
d = %(hello (nested) world)

# Don't propertize percent literals inside strings.
"(%s, %s)" % [123, 456]

# Or inside comments.
x = # "tot %q/to"; =
13
  y = 2 / 3
14 15 16 17 18 19

# Regexp after whitelisted method.
"abc".sub /b/, 'd'

# Don't mis-match "sub" at the end of words.
a = asub / aslb + bsub / bslb;
20

21 22
# Highlight the regexp after "if".
x = toto / foo if /do bar/ =~ "dobar"
23

24 25 26 27 28
# Multiline regexp.
/bars
 tees # toots
 nfoos/

29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
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
55 56
  # Support for this syntax was removed in Ruby 1.9, so we
  # probably don't need to handle it either.
57 58 59 60 61 62 63 64
  # when "b" :
  #   7
  # when "c" : 2
  when "d"  then 4
  else 5
  end
end

65 66 67 68
# Some Cucumber code:
Given /toto/ do
  print "hello"
end
69 70 71 72 73

# Bug#15208
if something == :==
  do_something
end
74 75 76 77

# Bug#15369
MSG = 'Separate every 3 digits in the integer portion of a number' \
  'with underscores(_).'