Files
neovim/test/functional/legacy/put_spec.lua
Justin M. Keyes 6d8c8b18d5 test(harness): migrate away from magic globals
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`.
2026-07-21 13:22:39 +02:00

61 lines
2.6 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 clear = n.clear
local source = n.source
describe('put', function()
before_each(clear)
-- oldtest: Test_put_other_window()
it('above topline in buffer in two splits', function()
local screen = Screen.new(80, 10)
source([[
40vsplit
0put ='some text at the top'
put =' one more text'
put =' two more text'
put =' three more text'
put =' four more text'
]])
screen:expect([[
some text at the top │some text at the top |
one more text │ one more text |
two more text │ two more text |
three more text │ three more text |
^four more text │ four more text |
│ |
{1:~ }│{1:~ }|*2
{3:[No Name] [+] }{2:[No Name] [+] }|
|
]])
end)
-- oldtest: Test_put_in_last_displayed_line()
it('in last displayed line', function()
local screen = Screen.new(75, 10)
source([[
autocmd CursorMoved * eval line('w$')
let @a = 'x'->repeat(&columns * 2 - 2)
eval range(&lines)->setline(1)
call feedkeys('G"ap')
]])
screen:expect([[
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx^x |
|
]])
end)
end)