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

79 lines
1.4 KiB
Ruby

require 'spec_helper'
describe "lua" do
let(:filename) { 'test.lua' }
before :each do
vim.set 'expandtab'
vim.set 'shiftwidth', 2
end
specify "functions" do
set_file_contents <<~EOF
function example () print("foo"); print("bar") end
EOF
split
assert_file_contents <<~EOF
function example ()
print("foo")
print("bar")
end
EOF
join
assert_file_contents <<~EOF
function example () print("foo"); print("bar") end
EOF
end
specify "lambda functions" do
set_file_contents <<~EOF
local something = other(function (one, two) print("foo") end)
EOF
split
assert_file_contents <<~EOF
local something = other(function (one, two)
print("foo")
end)
EOF
join
assert_file_contents <<~EOF
local something = other(function (one, two) print("foo") end)
EOF
end
specify "tables" do
set_file_contents <<~EOF
local something = {"a", 'b', 3, foo = bar, ["a-d"] = function() print("foo"); print("bar") end}
EOF
split
assert_file_contents <<~EOF
local something = {
"a",
'b',
3,
foo = bar,
["a-d"] = function()
print("foo")
print("bar")
end,
}
EOF
join
assert_file_contents <<~EOF
local something = { "a", 'b', 3, foo = bar, ["a-d"] = function() print("foo"); print("bar") end }
EOF
end
end