mirror of
https://github.com/neovim/neovim.git
synced 2026-07-31 20:59: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`.
59 lines
1.3 KiB
Lua
59 lines
1.3 KiB
Lua
-- Test for sourcing a file with CTRL-V's at the end of the line
|
||
|
||
local n = require('test.functional.testnvim')()
|
||
local t = require('test.testutil')
|
||
|
||
local describe, it, before_each, teardown = t.describe, t.it, t.before_each, t.teardown
|
||
local clear, feed, insert = n.clear, n.feed, n.insert
|
||
local feed_command, expect = n.feed_command, n.expect
|
||
|
||
describe('028', function()
|
||
before_each(clear)
|
||
|
||
it('CTRL-V at the end of the line is working', function()
|
||
insert([[
|
||
firstline
|
||
map __1 afirst
|
||
map __2 asecond
|
||
map __3 athird
|
||
map __4 afourth
|
||
map __5 afifth
|
||
map __1 asdX
|
||
map __2 asdXX
|
||
map __3 asdXX
|
||
map __4 asdXXX
|
||
map __5 asdXXX
|
||
lastline]])
|
||
|
||
feed(':%s/X/<C-v><C-v>/g<cr>')
|
||
feed(':/firstline/+1,/lastline/-1w! Xtestfile<cr>')
|
||
feed_command('so Xtestfile')
|
||
feed_command('%d')
|
||
feed('Gmm__1<Esc><Esc>__2<Esc>__3<Esc><Esc>__4<Esc>__5<Esc>')
|
||
feed(":'m,$s/<C-v><C-@>/0/g<cr>")
|
||
|
||
expect([[
|
||
sd
|
||
map __2 asdsecondsdsd0map __5 asd0fifth]])
|
||
end)
|
||
|
||
it('CTRL-X/CTRL-A is working', function()
|
||
insert([[
|
||
12352
|
||
|
||
12354]])
|
||
feed_command('/12352')
|
||
feed('<C-A>')
|
||
feed_command('/12354')
|
||
feed('<C-X>')
|
||
expect([[
|
||
12353
|
||
|
||
12353]])
|
||
end)
|
||
|
||
teardown(function()
|
||
os.remove('Xtestfile')
|
||
end)
|
||
end)
|