* lisp/progmodes/ruby-mode.el (ruby-calculate-indent): Consider
[bpt/emacs.git] / test / indent / ruby.rb
CommitLineData
f063063a 1# Percent literals.
dfbd787f 2b = %Q{This is a "string"}
f063063a 3c = %w!foo
dfbd787f 4 bar
f063063a
DG
5 baz!
6d = %(hello (nested) world)
7
8# Don't propertize percent literals inside strings.
9"(%s, %s)" % [123, 456]
10
11# Or inside comments.
12x = # "tot %q/to"; =
a9e4425b 13 y = 2 / 3
f063063a
DG
14
15# Regexp after whitelisted method.
16"abc".sub /b/, 'd'
17
18# Don't mis-match "sub" at the end of words.
19a = asub / aslb + bsub / bslb;
dfbd787f 20
f063063a
DG
21# Highlight the regexp after "if".
22x = toto / foo if /do bar/ =~ "dobar"
dfbd787f 23
1a0a0a8a
DG
24# Multiline regexp.
25/bars
26 tees # toots
27 nfoos/
28
a9e4425b
SM
29def test1(arg)
30 puts "hello"
31end
32
33def test2 (arg)
34 a = "apple"
35
36 if a == 2
37 puts "hello"
38 else
39 puts "there"
40 end
41
42 if a == 2 then
43 puts "hello"
44 elsif a == 3
45 puts "hello3"
46 elsif a == 3 then
47 puts "hello3"
48 else
49 puts "there"
50 end
51
52 case a
53 when "a"
54 6
1a0a0a8a
DG
55 # Support for this syntax was removed in Ruby 1.9, so we
56 # probably don't need to handle it either.
a9e4425b
SM
57 # when "b" :
58 # 7
59 # when "c" : 2
60 when "d" then 4
61 else 5
62 end
63end
64
dfbd787f
SM
65# Some Cucumber code:
66Given /toto/ do
67 print "hello"
68end
88527bc0
DG
69
70# Bug#15208
71if something == :==
72 do_something
73end