mirror of
https://github.com/amix/vimrc
synced 2025-07-07 08:45:00 +08:00
Use sources_non_forked folder for pathogen path, with sources_non_forked_fallback folder as fallback.
This commit is contained in:
@ -1,24 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "Indenting" do
|
||||
specify "multi-line arguments" do
|
||||
assert_correct_indenting <<~EOF
|
||||
User.new(
|
||||
:first_name => 'Some',
|
||||
:second_name => 'Guy'
|
||||
)
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
User.new(:first_name => 'Some',
|
||||
:second_name => 'Guy')
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
User.new(
|
||||
:first_name => 'Some',
|
||||
:second_name => 'Guy'
|
||||
)
|
||||
EOF
|
||||
end
|
||||
end
|
@ -1,73 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "Indenting" do
|
||||
specify "if-clauses" do
|
||||
assert_correct_indenting <<~EOF
|
||||
if foo
|
||||
bar
|
||||
end
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
if foo
|
||||
bar
|
||||
else
|
||||
baz
|
||||
end
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
bar if foo
|
||||
something_else
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "heredocs" do
|
||||
assert_correct_indenting <<~EOF
|
||||
def one
|
||||
two = <<-THREE
|
||||
four
|
||||
THREE
|
||||
end
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
def one
|
||||
two = <<THREE
|
||||
four
|
||||
THREE
|
||||
end
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
def one
|
||||
two = <<~THREE
|
||||
four
|
||||
THREE
|
||||
end
|
||||
EOF
|
||||
|
||||
# See https://github.com/vim-ruby/vim-ruby/issues/318 for details
|
||||
assert_correct_indenting <<~EOF
|
||||
def foo
|
||||
<<-EOS
|
||||
one
|
||||
\#{two} three
|
||||
four
|
||||
EOS
|
||||
end
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "comments" do
|
||||
assert_correct_indenting <<~EOF
|
||||
def one
|
||||
example do |something|
|
||||
=begin
|
||||
something that is ignored
|
||||
=end
|
||||
end
|
||||
end
|
||||
EOF
|
||||
end
|
||||
end
|
@ -1,164 +0,0 @@
|
||||
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
|
@ -1,29 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "Indenting" do
|
||||
# Reference: https://docs.ruby-lang.org/en/master/doc/syntax/pattern_matching_rdoc.html
|
||||
specify "pattern-matching with case-in" do
|
||||
assert_correct_indenting 'rb', <<~EOF
|
||||
case {a: a}
|
||||
in {a:}
|
||||
p a
|
||||
end
|
||||
EOF
|
||||
|
||||
assert_correct_indenting 'rb', <<~EOF
|
||||
users = [{name: "Alice", age: 12}, {name: "Bob", age: 23}]
|
||||
users.any? do |user|
|
||||
user in {name: /B/, in: 20..}
|
||||
end #=> true
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "does not deindent while typing" do
|
||||
assert_correct_indent_in_insert 'rb', <<~EOF, "index = 0", <<~RESULT
|
||||
def foo
|
||||
EOF
|
||||
def foo
|
||||
index = 0
|
||||
RESULT
|
||||
end
|
||||
end
|
@ -1,323 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "Indenting" do
|
||||
specify "method chaining" do
|
||||
assert_correct_indenting <<~EOF
|
||||
some_object.
|
||||
method_one.
|
||||
method_two.
|
||||
method_three
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
some_object
|
||||
.method_one
|
||||
.method_two
|
||||
.method_three
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
some_object&.
|
||||
method_one&.
|
||||
method_two&.
|
||||
method_three
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
some_object
|
||||
&.method_one
|
||||
&.method_two
|
||||
&.method_three
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "arrays" do
|
||||
assert_correct_indenting <<~EOF
|
||||
foo = [one,
|
||||
two,
|
||||
three]
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "tricky string interpolation" do
|
||||
# See https://github.com/vim-ruby/vim-ruby/issues/75 for details
|
||||
assert_correct_indenting <<~EOF
|
||||
puts %{\#{}}
|
||||
puts "OK"
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
while true
|
||||
begin
|
||||
puts %{\#{x}}
|
||||
rescue ArgumentError
|
||||
end
|
||||
end
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "continuations after round braces" do
|
||||
vim.command 'let g:ruby_indent_block_style = "expression"'
|
||||
assert_correct_indenting <<~EOF
|
||||
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
|
||||
EOF
|
||||
end
|
||||
|
||||
describe "assignments" do
|
||||
specify "continuations after assignment" do
|
||||
assert_correct_indenting <<~EOF
|
||||
variable =
|
||||
if condition?
|
||||
1
|
||||
else
|
||||
2
|
||||
end
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
variable = # evil comment
|
||||
case something
|
||||
when 'something'
|
||||
something_else
|
||||
else
|
||||
other
|
||||
end
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
variable = case something
|
||||
when 'something'
|
||||
something_else
|
||||
else
|
||||
other
|
||||
end
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
variable = if something == something_else
|
||||
something_else
|
||||
elsif other == none
|
||||
none
|
||||
else
|
||||
other
|
||||
end
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
variable = while
|
||||
break something
|
||||
end
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
variable = if [].
|
||||
map { |x| x * 2 }.
|
||||
filter { |x| x % 3 == 0 }.
|
||||
empty?
|
||||
something
|
||||
end
|
||||
EOF
|
||||
|
||||
vim.command 'let g:ruby_indent_assignment_style = "variable"'
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
variable = case something # evil comment
|
||||
when 'something'
|
||||
something_else
|
||||
else
|
||||
other
|
||||
end
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
variable = if something == something_else
|
||||
something_else
|
||||
elsif other == none
|
||||
none
|
||||
else
|
||||
other
|
||||
end
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
variable = while
|
||||
break something
|
||||
end
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
variable = if [].
|
||||
map { |x| x * 2 }.
|
||||
filter { |x| x % 3 == 0 }.
|
||||
empty?
|
||||
something
|
||||
end
|
||||
EOF
|
||||
end
|
||||
end
|
||||
|
||||
specify "continuations after hanging comma" do
|
||||
assert_correct_indenting <<~EOF
|
||||
array = [
|
||||
:one,
|
||||
].each do |x|
|
||||
puts x.to_s
|
||||
end
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "string interpolation" do
|
||||
# For details, see:
|
||||
#
|
||||
# https://github.com/vim-ruby/vim-ruby/issues/93
|
||||
# https://github.com/vim-ruby/vim-ruby/issues/160
|
||||
#
|
||||
assert_correct_indenting <<~EOF
|
||||
command = %|\#{file}|
|
||||
settings.log.info("Returning: \#{command}")
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
{
|
||||
thing: "[\#{}]",
|
||||
thong: "b"
|
||||
}
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
{
|
||||
a: "(\#{a})",
|
||||
b: "(\#{b})",
|
||||
c: "(c)",
|
||||
d: "(d)",
|
||||
e: "(e)",
|
||||
}
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "closing bracket not on its own line" do
|
||||
# See https://github.com/vim-ruby/vim-ruby/issues/81 for details
|
||||
assert_correct_indenting <<~EOF
|
||||
one { two >>
|
||||
three }
|
||||
four
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "lonesome single parenthesis in a method definition" do
|
||||
# See https://github.com/vim-ruby/vim-ruby/issues/130 for details
|
||||
assert_correct_indenting <<~EOF
|
||||
def bar(
|
||||
baz
|
||||
)
|
||||
return baz+1
|
||||
end
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "brackets on their own line, followed by a comma" do
|
||||
# See https://github.com/vim-ruby/vim-ruby/issues/124 for details
|
||||
assert_correct_indenting <<~EOF
|
||||
bla = {
|
||||
:one => [
|
||||
{:bla => :blub}
|
||||
],
|
||||
:two => (
|
||||
{:blub => :abc}
|
||||
),
|
||||
:three => {
|
||||
:blub => :abc
|
||||
},
|
||||
:four => 'five'
|
||||
}
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "string with an and#" do
|
||||
# See https://github.com/vim-ruby/vim-ruby/issues/108 for details
|
||||
assert_correct_indenting <<~EOF
|
||||
outside_block "and#" do
|
||||
inside_block do
|
||||
end
|
||||
end
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "continuation with a symbol at the end" do
|
||||
# See https://github.com/vim-ruby/vim-ruby/issues/132 for details
|
||||
assert_correct_indenting <<~EOF
|
||||
foo = :+
|
||||
# Next indents correctly
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "continuation with a hanging comma" do
|
||||
# See https://github.com/vim-ruby/vim-ruby/issues/139 for details
|
||||
assert_correct_indenting <<~EOF
|
||||
thing :foo
|
||||
thing 'a',
|
||||
'b'
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "continuations in an if-clause condition" do
|
||||
# See https://github.com/vim-ruby/vim-ruby/issues/215 for details
|
||||
assert_correct_indenting <<~EOF
|
||||
if foo || bar ||
|
||||
bong &&
|
||||
baz || bing
|
||||
puts "foo"
|
||||
end
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "continuations with round brackets" do
|
||||
# See https://github.com/vim-ruby/vim-ruby/issues/17 for details
|
||||
assert_correct_indenting <<~EOF
|
||||
foo and
|
||||
(bar and
|
||||
baz) and
|
||||
bing
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "block within an argument list" do
|
||||
# See https://github.com/vim-ruby/vim-ruby/issues/312 for details
|
||||
assert_correct_indenting <<~EOF
|
||||
foo(
|
||||
x: 1,
|
||||
y: [1, 2, 3].map { |i|
|
||||
i + 1
|
||||
}
|
||||
)
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "backslashes" do
|
||||
# See https://github.com/vim-ruby/vim-ruby/issues/311 for details
|
||||
assert_correct_indenting <<~EOF
|
||||
def foo
|
||||
x = 1
|
||||
|
||||
string = ". \#{x}" \\
|
||||
"xyz"
|
||||
|
||||
puts string
|
||||
puts string
|
||||
end
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "wrong continuation within regex character class" do
|
||||
# See https://github.com/vim-ruby/vim-ruby/issues/405 for details
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
extname = file.extname(url).split(/[?#]/).first
|
||||
target_file = tempfile.new()
|
||||
EOF
|
||||
end
|
||||
end
|
@ -1,46 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "Indenting" do
|
||||
specify "end constructs" do
|
||||
assert_correct_indenting <<~EOF
|
||||
f do
|
||||
g { def h; end }
|
||||
end
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
if foo
|
||||
bar ; end
|
||||
something_else
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
if bar ; end
|
||||
something_else
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
foo do
|
||||
foo = 3 . class
|
||||
foo = lambda { class One; end }
|
||||
foo = lambda { |args| class One; end }
|
||||
foo = bar; class One; end
|
||||
end
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
nested do
|
||||
while true do
|
||||
def foo
|
||||
if bar
|
||||
for i in collection
|
||||
def baz
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
EOF
|
||||
end
|
||||
end
|
@ -1,18 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "Indenting" do
|
||||
specify "closing html tag after multiline eruby tag" do
|
||||
assert_correct_indenting 'erb', <<~EOF
|
||||
<form>
|
||||
<div>
|
||||
<%= text_field_tag :email, nil,
|
||||
placeholder: "email" %>
|
||||
text
|
||||
<%= text_field_tag :password, nil,
|
||||
placeholder: "password" %>
|
||||
</div>
|
||||
</form>
|
||||
EOF
|
||||
end
|
||||
end
|
||||
|
@ -1,78 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'Indenting' do
|
||||
|
||||
specify 'method args' do
|
||||
assert_correct_indenting <<~EOF
|
||||
render('product/show',
|
||||
product: product,
|
||||
on_sale: true,
|
||||
)
|
||||
EOF
|
||||
|
||||
vim.command 'let g:ruby_indent_hanging_elements = 0'
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
render('product/show',
|
||||
product: product,
|
||||
on_sale: true,
|
||||
)
|
||||
EOF
|
||||
end
|
||||
|
||||
specify 'method args with block' do
|
||||
assert_correct_indenting <<~EOF
|
||||
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
|
||||
EOF
|
||||
|
||||
vim.command 'let g:ruby_indent_hanging_elements = 0'
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
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
|
||||
EOF
|
||||
end
|
||||
|
||||
specify 'arrays' do
|
||||
assert_correct_indenting <<~EOF
|
||||
x = [1,
|
||||
2,
|
||||
3,
|
||||
]
|
||||
EOF
|
||||
|
||||
vim.command 'let g:ruby_indent_hanging_elements = 0'
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
x = [1,
|
||||
2,
|
||||
3,
|
||||
]
|
||||
EOF
|
||||
end
|
||||
|
||||
specify 'hashes' do
|
||||
assert_correct_indenting <<~EOF
|
||||
x = { a: 1,
|
||||
b: 2,
|
||||
c: 3,
|
||||
}
|
||||
EOF
|
||||
|
||||
vim.command 'let g:ruby_indent_hanging_elements = 0'
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
x = { a: 1,
|
||||
b: 2,
|
||||
c: 3,
|
||||
}
|
||||
EOF
|
||||
end
|
||||
end
|
@ -1,10 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "Indenting" do
|
||||
specify "identifiers containing keyword substrings" do
|
||||
assert_correct_indenting <<~EOF
|
||||
foo_def
|
||||
42
|
||||
EOF
|
||||
end
|
||||
end
|
@ -1,133 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "Indenting" do
|
||||
specify "default indented access modifiers" do
|
||||
assert_correct_indenting <<~EOF
|
||||
class OuterClass
|
||||
|
||||
private :method
|
||||
protected :method
|
||||
def method; end
|
||||
protected
|
||||
def method; end
|
||||
private
|
||||
def method; end
|
||||
public
|
||||
def method; end
|
||||
|
||||
class InnerClass
|
||||
|
||||
private :method
|
||||
protected :method
|
||||
def method; end
|
||||
protected
|
||||
def method; end
|
||||
private
|
||||
def method; end
|
||||
public
|
||||
def method; end
|
||||
|
||||
end
|
||||
|
||||
private :method
|
||||
protected :method
|
||||
def method; end
|
||||
protected
|
||||
def method; end
|
||||
private
|
||||
def method; end
|
||||
public
|
||||
def method; end
|
||||
|
||||
end
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "indented access modifiers" do
|
||||
vim.command 'let g:ruby_indent_access_modifier_style = "indent"'
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
class OuterClass
|
||||
|
||||
private :method
|
||||
protected :method
|
||||
def method; end
|
||||
protected
|
||||
def method; end
|
||||
private
|
||||
def method; end
|
||||
public
|
||||
def method; end
|
||||
|
||||
class InnerClass
|
||||
|
||||
private :method
|
||||
protected :method
|
||||
def method; end
|
||||
protected
|
||||
def method; end
|
||||
private
|
||||
def method; end
|
||||
public
|
||||
def method; end
|
||||
|
||||
end
|
||||
|
||||
private :method
|
||||
protected :method
|
||||
def method; end
|
||||
protected
|
||||
def method; end
|
||||
private
|
||||
def method; end
|
||||
public
|
||||
def method; end
|
||||
|
||||
end
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "outdented access modifiers" do
|
||||
vim.command 'let g:ruby_indent_access_modifier_style = "outdent"'
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
class OuterClass
|
||||
|
||||
private :method
|
||||
protected :method
|
||||
def method; end
|
||||
protected
|
||||
def method; end
|
||||
private
|
||||
def method; end
|
||||
public
|
||||
def method; end
|
||||
|
||||
class InnerClass
|
||||
|
||||
private :method
|
||||
protected :method
|
||||
def method; end
|
||||
protected
|
||||
def method; end
|
||||
private
|
||||
def method; end
|
||||
public
|
||||
def method; end
|
||||
|
||||
end
|
||||
|
||||
private :method
|
||||
protected :method
|
||||
def method; end
|
||||
protected
|
||||
def method; end
|
||||
private
|
||||
def method; end
|
||||
public
|
||||
def method; end
|
||||
|
||||
end
|
||||
EOF
|
||||
end
|
||||
end
|
@ -1,80 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "Indenting" do
|
||||
specify "method definitions prefixed with access modifiers" do
|
||||
assert_correct_indenting <<~EOF
|
||||
class Foo
|
||||
public def one(x)
|
||||
end
|
||||
|
||||
private def two(y)
|
||||
code
|
||||
end
|
||||
end
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "method definitions prefixed with any method call" do
|
||||
assert_correct_indenting <<~EOF
|
||||
class Foo
|
||||
foobar def one(x)
|
||||
end
|
||||
foobar? def one(x)
|
||||
end
|
||||
foobar! def one(x)
|
||||
end
|
||||
|
||||
фубар def one(x)
|
||||
end
|
||||
|
||||
foobar
|
||||
def one(x)
|
||||
end
|
||||
|
||||
FooBar1 def two(y)
|
||||
code
|
||||
end
|
||||
end
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "endless methods" do
|
||||
# Note: A case that doesn't work at this time:
|
||||
#
|
||||
# def foo()
|
||||
# = 42
|
||||
#
|
||||
assert_correct_indenting <<~EOF
|
||||
indented_block do
|
||||
def foo(bar) = puts(bar)
|
||||
def foo!(bar) = puts(bar)
|
||||
def foo?(bar) = puts(bar)
|
||||
|
||||
def foo(bar)=puts(bar)
|
||||
|
||||
def foo(bar) = bar + 1
|
||||
|
||||
def foo() = 1 + 1
|
||||
def foo = 1 + 1
|
||||
|
||||
private def foo(bar) = bar + 1
|
||||
|
||||
def foo(bar) =
|
||||
bar + 1
|
||||
|
||||
def foo(bar = default_function()) = puts(bar)
|
||||
|
||||
def foo(bar = default_function()) =
|
||||
puts(bar)
|
||||
|
||||
def foo(
|
||||
bar
|
||||
) = puts(bar)
|
||||
|
||||
# Reference: https://github.com/vim-ruby/vim-ruby/issues/450
|
||||
def self.foo = puts(bar)
|
||||
def bar.foo = puts(baz)
|
||||
end
|
||||
EOF
|
||||
end
|
||||
end
|
@ -1,69 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "Indenting" do
|
||||
specify "nested blocks" do
|
||||
assert_correct_indenting <<~EOF
|
||||
var.func1(:param => 'value') do
|
||||
var.func2(:param => 'value') do
|
||||
puts "test"
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
var.func1(:param => 'value') {
|
||||
var.func2(:param => 'value') {
|
||||
foo({ bar => baz })
|
||||
puts "test one"
|
||||
puts "test two"
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
vim.command 'let g:ruby_indent_block_style = "expression"'
|
||||
assert_correct_indenting <<~EOF
|
||||
var.
|
||||
func1(:param => 'value') {
|
||||
var.func2(:param => 'value') {
|
||||
puts "test"
|
||||
}
|
||||
}
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "nested hashes" do
|
||||
assert_correct_indenting <<~EOF
|
||||
foo, bar = {
|
||||
:bar => {
|
||||
:one => 'two',
|
||||
:five => 'six'
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
vim.command 'let g:ruby_indent_block_style = "expression"'
|
||||
assert_correct_indenting <<~EOF
|
||||
foo,
|
||||
bar = {
|
||||
:bar => {
|
||||
:foo => { 'bar' => 'baz' },
|
||||
:one => 'two',
|
||||
:three => 'four'
|
||||
}
|
||||
}
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "nested blocks with a continuation and function call inbetween" do
|
||||
vim.command 'let g:ruby_indent_block_style = "expression"'
|
||||
assert_correct_indenting <<~EOF
|
||||
var.
|
||||
func1(:param => 'value') {
|
||||
func1_5(:param => 'value')
|
||||
var.func2(:param => 'value') {
|
||||
puts "test"
|
||||
}
|
||||
}
|
||||
EOF
|
||||
end
|
||||
end
|
@ -1,47 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "Indenting" do
|
||||
specify "splats with blocks in square brackets" do
|
||||
assert_correct_indenting <<~EOF
|
||||
x = Foo[*
|
||||
y do
|
||||
z
|
||||
end
|
||||
]
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
x = Foo[* # with a comment
|
||||
y do
|
||||
z
|
||||
end
|
||||
]
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "splats with blocks in assignment" do
|
||||
vim.command 'let g:ruby_indent_block_style = "expression"'
|
||||
assert_correct_indenting <<~EOF
|
||||
x = *
|
||||
array.map do
|
||||
3
|
||||
end
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "splats with blocks in round brackets" do
|
||||
assert_correct_indenting <<~EOF
|
||||
x = Foo(*y do
|
||||
z
|
||||
end)
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<~EOF
|
||||
x = Foo(
|
||||
*y do
|
||||
z
|
||||
end
|
||||
)
|
||||
EOF
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user