mirror of
https://github.com/amix/vimrc
synced 2025-07-03 14:14:59 +08:00
Update vim-ruby.
This commit is contained in:
29
sources_non_forked/vim-ruby/spec/indent/case_in_spec.rb
Normal file
29
sources_non_forked/vim-ruby/spec/indent/case_in_spec.rb
Normal file
@ -0,0 +1,29 @@
|
||||
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
|
@ -35,6 +35,19 @@ Vimrunner::RSpec.configure do |config|
|
||||
expect(IO.read(filename)).to eq string
|
||||
end
|
||||
|
||||
def assert_correct_indent_in_insert(extension='rb', content, input, result)
|
||||
filename = "test.#{extension}"
|
||||
|
||||
IO.write filename, content
|
||||
|
||||
vim.edit filename
|
||||
vim.normal 'Go'
|
||||
vim.feedkeys input
|
||||
vim.write
|
||||
|
||||
expect(IO.read(filename)).to eq result
|
||||
end
|
||||
|
||||
def assert_correct_highlighting(extension='rb', string, patterns, group)
|
||||
filename = "test.#{extension}"
|
||||
|
||||
|
@ -33,4 +33,15 @@ describe "Syntax highlighting" do
|
||||
def foo bar:; end
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "endless def does not start a method region" do
|
||||
assert_correct_highlighting <<~'EOF', 'end', ''
|
||||
def foo = bar
|
||||
end
|
||||
EOF
|
||||
assert_correct_highlighting <<~'EOF', 'end', ''
|
||||
def foo (a, b) = bar
|
||||
end
|
||||
EOF
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user