Files
neovim/test/functional/legacy/019_smarttab_expandtab_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
1.6 KiB
Lua
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- Tests for "r<Tab>" with 'smarttab' and 'expandtab' set/not set.
-- Also test that dv_ works correctly
local n = require('test.functional.testnvim')()
local t = require('test.testutil')
local describe, it, setup = t.describe, t.it, t.setup
local feed, insert = n.feed, n.insert
local clear, feed_command, expect = n.clear, n.feed_command, n.expect
describe([[performing "r<Tab>" with 'smarttab' and 'expandtab' set/not set, and "dv_"]], function()
setup(clear)
-- luacheck: ignore 621 (Indentation)
it('is working', function()
insert([[
start text
some test text
test text
other test text
a cde
f ghi
test text
Second line beginning with whitespace]])
feed_command('set smarttab expandtab ts=8 sw=4')
-- Make sure that backspace works, no matter what termcap is used.
feed_command('set t_kD=x7f t_kb=x08')
feed_command('/some')
feed('r ')
feed_command('set noexpandtab')
feed_command('/other')
feed('r <cr>')
-- Test replacing with Tabs and then backspacing to undo it.
feed('0wR <bs><bs><bs><esc><cr>')
-- Test replacing with Tabs.
feed('0wR <esc><cr>')
-- Test that copyindent works with expandtab set.
feed_command('set expandtab smartindent copyindent ts=8 sw=8 sts=8')
feed('o{<cr>x<esc>')
feed_command('set nosol')
feed_command('/Second line/')
-- Test "dv_"
feed('fwdv_')
-- Assert buffer contents.
expect([[
start text
ome test text
test text
ther test text
a cde
hi
test text
{
x
with whitespace]])
end)
end)