test: rename (meths, funcs) -> (api, fn)

This commit is contained in:
Lewis Russell
2024-01-12 17:59:57 +00:00
parent 4f81f506f9
commit 795f896a57
214 changed files with 6443 additions and 6560 deletions

View File

@@ -7,7 +7,7 @@ local eval = helpers.eval
local command = helpers.command
local poke_eventloop = helpers.poke_eventloop
local retry = helpers.retry
local meths = helpers.meths
local api = helpers.api
local feed_data = thelpers.feed_data
local pcall_err = helpers.pcall_err
local exec_lua = helpers.exec_lua
@@ -85,7 +85,7 @@ describe(':terminal scrollback', function()
{1: } |
{3:-- TERMINAL --} |
]])
eq(7, meths.nvim_buf_line_count(0))
eq(7, api.nvim_buf_line_count(0))
end)
describe('and then 3 more lines are printed', function()
@@ -169,7 +169,7 @@ describe(':terminal scrollback', function()
{2:^ } |
|
]])
eq(8, meths.nvim_buf_line_count(0))
eq(8, api.nvim_buf_line_count(0))
feed([[3k]])
screen:expect([[
^line4 |
@@ -203,7 +203,7 @@ describe(':terminal scrollback', function()
|
{3:-- TERMINAL --} |
]])
eq(4, meths.nvim_buf_line_count(0))
eq(4, api.nvim_buf_line_count(0))
end
it('will delete the last two empty lines', will_delete_last_two_lines)
@@ -221,7 +221,7 @@ describe(':terminal scrollback', function()
{1: } |
{3:-- TERMINAL --} |
]])
eq(4, meths.nvim_buf_line_count(0))
eq(4, api.nvim_buf_line_count(0))
feed('<c-\\><c-n>gg')
screen:expect([[
^tty ready |
@@ -260,7 +260,7 @@ describe(':terminal scrollback', function()
{1: } |
{3:-- TERMINAL --} |
]])
eq(7, meths.nvim_buf_line_count(0))
eq(7, api.nvim_buf_line_count(0))
end)
describe('and the height is increased by 1', function()
@@ -286,7 +286,7 @@ describe(':terminal scrollback', function()
describe('and then by 3', function()
before_each(function()
pop_then_push()
eq(8, meths.nvim_buf_line_count(0))
eq(8, api.nvim_buf_line_count(0))
screen:try_resize(screen._width, screen._height + 3)
end)
@@ -301,7 +301,7 @@ describe(':terminal scrollback', function()
{1: } |
{3:-- TERMINAL --} |
]])
eq(9, meths.nvim_buf_line_count(0))
eq(9, api.nvim_buf_line_count(0))
feed('<c-\\><c-n>gg')
screen:expect([[
^tty ready |
@@ -341,7 +341,7 @@ describe(':terminal scrollback', function()
]])
-- since there's an empty line after the cursor, the buffer line
-- count equals the terminal screen height
eq(11, meths.nvim_buf_line_count(0))
eq(11, api.nvim_buf_line_count(0))
end)
end)
end)
@@ -380,7 +380,7 @@ describe("'scrollback' option", function()
end)
local function set_fake_shell()
meths.nvim_set_option_value('shell', string.format('"%s" INTERACT', testprg('shell-test')), {})
api.nvim_set_option_value('shell', string.format('"%s" INTERACT', testprg('shell-test')), {})
end
local function expect_lines(expected, epsilon)
@@ -399,7 +399,7 @@ describe("'scrollback' option", function()
screen = thelpers.screen_setup(nil, { 'sh' }, 30)
end
meths.nvim_set_option_value('scrollback', 0, {})
api.nvim_set_option_value('scrollback', 0, {})
feed_data(('%s REP 31 line%s'):format(testprg('shell-test'), is_os('win') and '\r' or '\n'))
screen:expect { any = '30: line ' }
retry(nil, nil, function()
@@ -417,7 +417,7 @@ describe("'scrollback' option", function()
screen = thelpers.screen_setup(nil, { 'sh' }, 30)
end
meths.nvim_set_option_value('scrollback', 200, {})
api.nvim_set_option_value('scrollback', 200, {})
-- Wait for prompt.
screen:expect { any = '%$' }
@@ -428,12 +428,12 @@ describe("'scrollback' option", function()
retry(nil, nil, function()
expect_lines(33, 2)
end)
meths.nvim_set_option_value('scrollback', 10, {})
api.nvim_set_option_value('scrollback', 10, {})
poke_eventloop()
retry(nil, nil, function()
expect_lines(16)
end)
meths.nvim_set_option_value('scrollback', 10000, {})
api.nvim_set_option_value('scrollback', 10000, {})
retry(nil, nil, function()
expect_lines(16)
end)
@@ -494,18 +494,18 @@ describe("'scrollback' option", function()
]])
local term_height = 6 -- Actual terminal screen height, not the scrollback
-- Initial
local scrollback = meths.nvim_get_option_value('scrollback', {})
local scrollback = api.nvim_get_option_value('scrollback', {})
eq(scrollback + term_height, eval('line("$")'))
-- Reduction
scrollback = scrollback - 2
meths.nvim_set_option_value('scrollback', scrollback, {})
api.nvim_set_option_value('scrollback', scrollback, {})
eq(scrollback + term_height, eval('line("$")'))
end)
it('defaults to 10000 in :terminal buffers', function()
set_fake_shell()
command('terminal')
eq(10000, meths.nvim_get_option_value('scrollback', {}))
eq(10000, api.nvim_get_option_value('scrollback', {}))
end)
it('error if set to invalid value', function()
@@ -518,7 +518,7 @@ describe("'scrollback' option", function()
it('defaults to -1 on normal buffers', function()
command('new')
eq(-1, meths.nvim_get_option_value('scrollback', {}))
eq(-1, api.nvim_get_option_value('scrollback', {}))
end)
it(':setlocal in a :terminal buffer', function()
@@ -527,45 +527,45 @@ describe("'scrollback' option", function()
-- _Global_ scrollback=-1 defaults :terminal to 10_000.
command('setglobal scrollback=-1')
command('terminal')
eq(10000, meths.nvim_get_option_value('scrollback', {}))
eq(10000, api.nvim_get_option_value('scrollback', {}))
-- _Local_ scrollback=-1 in :terminal forces the _maximum_.
command('setlocal scrollback=-1')
retry(nil, nil, function() -- Fixup happens on refresh, not immediately.
eq(100000, meths.nvim_get_option_value('scrollback', {}))
eq(100000, api.nvim_get_option_value('scrollback', {}))
end)
-- _Local_ scrollback=-1 during TermOpen forces the maximum. #9605
command('setglobal scrollback=-1')
command('autocmd TermOpen * setlocal scrollback=-1')
command('terminal')
eq(100000, meths.nvim_get_option_value('scrollback', {}))
eq(100000, api.nvim_get_option_value('scrollback', {}))
end)
it(':setlocal in a normal buffer', function()
command('new')
-- :setlocal to -1.
command('setlocal scrollback=-1')
eq(-1, meths.nvim_get_option_value('scrollback', {}))
eq(-1, api.nvim_get_option_value('scrollback', {}))
-- :setlocal to anything except -1. Currently, this just has no effect.
command('setlocal scrollback=42')
eq(42, meths.nvim_get_option_value('scrollback', {}))
eq(42, api.nvim_get_option_value('scrollback', {}))
end)
it(':set updates local value and global default', function()
set_fake_shell()
command('set scrollback=42') -- set global value
eq(42, meths.nvim_get_option_value('scrollback', {}))
eq(42, api.nvim_get_option_value('scrollback', {}))
command('terminal')
eq(42, meths.nvim_get_option_value('scrollback', {})) -- inherits global default
eq(42, api.nvim_get_option_value('scrollback', {})) -- inherits global default
command('setlocal scrollback=99')
eq(99, meths.nvim_get_option_value('scrollback', {}))
eq(99, api.nvim_get_option_value('scrollback', {}))
command('set scrollback<') -- reset to global default
eq(42, meths.nvim_get_option_value('scrollback', {}))
eq(42, api.nvim_get_option_value('scrollback', {}))
command('setglobal scrollback=734') -- new global default
eq(42, meths.nvim_get_option_value('scrollback', {})) -- local value did not change
eq(42, api.nvim_get_option_value('scrollback', {})) -- local value did not change
command('terminal')
eq(734, meths.nvim_get_option_value('scrollback', {}))
eq(734, api.nvim_get_option_value('scrollback', {}))
end)
end)