1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-04 10:00:05 +08:00
SpaceVim/bundle/splitjoin.vim/spec/plugin/sh_spec.rb
2024-06-27 18:10:36 +08:00

102 lines
1.7 KiB
Ruby

require 'spec_helper'
describe "sh" do
let(:filename) { 'test.sh' }
before :each do
vim.set(:expandtab)
vim.set(:shiftwidth, 2)
end
describe "by semicolon" do
specify "simple case" do
set_file_contents <<~EOF
echo "one"; echo "two"
EOF
split
assert_file_contents <<~EOF
echo "one"
echo "two"
EOF
vim.search('one')
join
assert_file_contents <<~EOF
echo "one"; echo "two"
EOF
end
specify "skipping semicolons in strings" do
set_file_contents <<~EOF
echo "one;two"; echo "three"
EOF
split
assert_file_contents <<~EOF
echo "one;two"
echo "three"
EOF
end
specify "skipping semicolons in groups with braces" do
set_file_contents <<~EOF
echo "one"; (echo "two"; echo "three") &; echo "four"
EOF
split
assert_file_contents <<~EOF
echo "one"
(echo "two"; echo "three") &
echo "four"
EOF
end
end
describe "with backslash" do
specify "simple case" do
set_file_contents <<~EOF
echo "one" | wc -c
EOF
vim.search('|')
split
assert_file_contents <<~EOF
echo "one" \\
| wc -c
EOF
join
assert_file_contents <<~EOF
echo "one" | wc -c
EOF
end
specify "between words, finds closest non-whitespace forward" do
set_file_contents <<~EOF
echo "one" | wc -c
EOF
vim.search(' w')
split
assert_file_contents <<~EOF
echo "one" | \\
wc -c
EOF
join
assert_file_contents <<~EOF
echo "one" | wc -c
EOF
end
end
end