mirror of
https://github.com/neovim/neovim.git
synced 2026-07-31 12:49:11 +00:00
Problem: The magic globals `it`, `describe`, etc., are more trouble than they are worth. - Hooking into `after_each` requires `getfenv()` hacks. - They confuse luals/emmylua, because the top-level `.luarc.json` isn't merged with `test/.luarc.json` (apparently a luals limitation?) - They totally defeat discoverability because the user just has to "know" about the various magic symbols. So they harm DX, which means they serve no purpose at all. Solution: - Expose the test API from `testutil`, so tests can call `t.it()`, `t.describe()`, etc., in the conventional way. - Drop `getfenv()` hacks. - Drop the `setfenv()` injection in `load_chunk`. - Drop `test/_meta.lua`.
102 lines
3.3 KiB
Lua
102 lines
3.3 KiB
Lua
local n = require('test.functional.testnvim')()
|
|
local t = require('test.testutil')
|
|
local Screen = require('test.functional.ui.screen')
|
|
|
|
local describe, it, before_each = t.describe, t.it, t.before_each
|
|
local command = n.command
|
|
local clear, feed, feed_command = n.clear, n.feed, n.feed_command
|
|
local exec = n.exec
|
|
|
|
describe(':drop', function()
|
|
local screen
|
|
|
|
before_each(function()
|
|
clear()
|
|
screen = Screen.new(35, 10)
|
|
screen:set_default_attr_ids({
|
|
[0] = { bold = true, foreground = Screen.colors.Blue },
|
|
[1] = { bold = true, reverse = true },
|
|
[2] = { reverse = true },
|
|
[3] = { bold = true },
|
|
})
|
|
command('set nohidden laststatus=2 shortmess-=F')
|
|
end)
|
|
|
|
it('works like :e when called with only one window open', function()
|
|
feed_command('drop tmp1.vim')
|
|
screen:expect([[
|
|
^ |
|
|
{0:~ }|*7
|
|
{1:tmp1.vim }|
|
|
"tmp1.vim" [New] |
|
|
]])
|
|
end)
|
|
|
|
it('switches to an open window showing the buffer', function()
|
|
feed_command('edit tmp1')
|
|
feed_command('vsplit')
|
|
feed_command('edit tmp2')
|
|
feed_command('drop tmp1')
|
|
screen:expect([[
|
|
│^ |
|
|
{0:~ }│{0:~ }|*7
|
|
{2:tmp2 }{1:tmp1 }|
|
|
"tmp1" [New] |
|
|
]])
|
|
end)
|
|
|
|
it("splits off a new window when a buffer can't be abandoned", function()
|
|
feed_command('edit tmp1')
|
|
feed_command('vsplit')
|
|
feed_command('edit tmp2')
|
|
feed('iABC<esc>')
|
|
feed_command('drop tmp3')
|
|
screen:expect([[
|
|
^ │ |
|
|
{0:~ }│{0:~ }|*3
|
|
{1:tmp3 }│{0:~ }|
|
|
ABC │{0:~ }|
|
|
{0:~ }│{0:~ }|*2
|
|
{2:tmp2 [+] tmp1 }|
|
|
"tmp3" [New] |
|
|
]])
|
|
end)
|
|
|
|
-- oldtest: Test_drop_modified_file()
|
|
it('does not cause E37 with modified same file', function()
|
|
exec([[
|
|
edit Xdrop_modified.txt
|
|
call setline(1, 'The quick brown fox jumped over the lazy dogs')
|
|
]])
|
|
feed_command('drop Xdrop_modified.txt')
|
|
screen:expect([[
|
|
^The quick brown fox jumped over the|
|
|
lazy dogs |
|
|
{0:~ }|*6
|
|
{1:Xdrop_modified.txt [+] }|
|
|
:drop Xdrop_modified.txt |
|
|
]])
|
|
end)
|
|
|
|
it('jumps to line number when passed +line', function()
|
|
exec([[
|
|
edit Xdrop_line.txt
|
|
call append(0, "I just miss doing art. Don't you?")
|
|
call append(1, "It is not so hard as we have supposed.")
|
|
call append(2, "We are propelled by disaster. We are moving swiftly.")
|
|
]])
|
|
feed_command('drop +2 Xdrop_line.txt')
|
|
screen:expect([[
|
|
I just miss doing art. Don't you? |
|
|
^It is not so hard as we have suppos|
|
|
ed. |
|
|
We are propelled by disaster. We ar|
|
|
e moving swiftly. |
|
|
|
|
|
{0:~ }|*2
|
|
{1:Xdrop_line.txt [+] }|
|
|
:drop +2 Xdrop_line.txt |
|
|
]])
|
|
end)
|
|
end)
|