FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
vim-ruby/spec/indent/blocks_spec.rb at master · vim-ruby/vim-ruby · GitHub
vim-ruby
/
vim-ruby
Public
Notifications
You must be signed in to change notification settings
Fork
285
Star
2k
Code
Issues
57
Pull requests
6
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
vim-ruby
/
spec
/
indent
/
blocks_spec.rb
Copy path
More file actions
More file actions
Latest commit
History
History
History
164 lines (140 loc) · 2.92 KB
Breadcrumbs
vim-ruby
/
spec
/
indent
/
blocks_spec.rb
Copy path
File metadata and controls
164 lines (140 loc) · 2.92 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
require
'spec_helper'
describe
"Indenting"
do
specify
"indented blocks with expression style"
do
vim
.
command
'let g:ruby_indent_block_style = "expression"'
assert_correct_indenting
<<~EOF
a.
b.
c do |x|
something
end
next_line
EOF
assert_correct_indenting
<<~EOF
a.
b.
c { |x|
something
}
next_line
EOF
end
specify
"indented blocks with do style"
do
vim
.
command
'let g:ruby_indent_block_style = "do"'
assert_correct_indenting
<<~EOF
a.
b.
c do |x|
something
end
next_line
EOF
# Check that "do" style indentation does not mess up indentation
# following the bock.
assert_correct_indenting
<<~EOF
a.
b.
c do |x|
something
end
next_line
EOF
# Check that "do" style indenting works properly for brace blocks.
assert_correct_indenting
<<~EOF
a.
b.
c { |x|
something
}
next_line
EOF
end
specify
"'do' indenting"
do
assert_correct_indenting
<<~EOF
do
something
end
EOF
assert_correct_indenting
<<~EOF
def foo
a_hash = {:do => 'bar'}
end
EOF
assert_correct_indenting
<<~EOF
def foo(job)
job.do!
end
EOF
end
specify
"blocks with assignment on the previous line"
do
assert_correct_indenting
<<~EOF
foo =
something do
"other"
end
EOF
assert_correct_indenting
<<~EOF
@foo ||=
something do
"other"
end
EOF
end
specify
"blocks with multiline parameters"
do
vim
.
command
'let g:ruby_indent_block_style = "expression"'
assert_correct_indenting
<<~EOF
def foo
opts.on('--coordinator host=HOST[,port=PORT]',
'Specify the HOST and the PORT of the coordinator') do |str|
h = sub_opts_to_hash(str)
puts h
end
end
EOF
end
specify
"case-insensitive matching"
do
vim
.
set
'ignorecase'
assert_correct_indenting
<<~EOF
module X
Class.new do
end
end
EOF
vim
.
set
'ignorecase&'
end
specify
"blocks with tuple arguments"
do
assert_correct_indenting
<<~EOF
proc do |(a, b)|
puts a
puts b
end
EOF
assert_correct_indenting
<<~EOF
proc do |foo, (a, b), bar|
puts a
puts b
end
EOF
assert_correct_indenting
<<~EOF
proc do |(a, (b, c)), d|
puts a, b
puts c, d
end
EOF
end
specify
"blocks with default arguments"
do
assert_correct_indenting
<<~EOF
proc do |a = 1|
puts a
end
EOF
# See https://github.com/vim-ruby/vim-ruby/issues/304
assert_correct_indenting
<<~EOF
proc do |a: "asdf", b:|
proc do
puts a, b
end
end
EOF
end
end
Back
|
FazBrowse Home
|
New Git URL