Files
neovim/test/functional/legacy/marks_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

58 lines
1.2 KiB
Lua

local n = require('test.functional.testnvim')()
local t = require('test.testutil')
local describe, it, before_each = t.describe, t.it, t.before_each
local feed, insert, source = n.feed, n.insert, n.source
local clear, feed_command, expect = n.clear, n.feed_command, n.expect
describe('marks', function()
before_each(function()
clear()
end)
-- luacheck: ignore 621 (Indentation)
it('restores a deleted mark after delete-undo-redo-undo', function()
insert([[
textline A
textline B
textline C
Results:]])
feed_command([[:/^\t/+1]])
feed([[maddu<C-R>u]])
source([[
let g:a = string(getpos("'a"))
$put ='Mark after delete-undo-redo-undo: '.g:a
]])
expect([=[
textline A
textline B
textline C
Results:
Mark after delete-undo-redo-undo: [0, 3, 2, 0]]=])
end)
it("CTRL-A and CTRL-X updates last changed mark '[, ']", function()
insert([[
CTRL-A CTRL-X:
123 123 123
123 123 123
123 123 123]])
source([[
/^123/
execute "normal! \<C-A>`[v`]rAjwvjw\<C-X>`[v`]rX"]])
expect([=[
CTRL-A CTRL-X:
AAA 123 123
123 XXXXXXX
XXX 123 123]=])
end)
end)