aboutsummaryrefslogtreecommitdiff
path: root/test/functional/options
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-11-25 19:15:05 +0000
committerJosh Rahm <joshuarahm@gmail.com>2024-11-25 19:27:38 +0000
commitc5d770d311841ea5230426cc4c868e8db27300a8 (patch)
treedd21f70127b4b8b5f109baefc8ecc5016f507c91 /test/functional/options
parent9be89f131f87608f224f0ee06d199fcd09d32176 (diff)
parent081beb3659bd6d8efc3e977a160b1e72becbd8a2 (diff)
downloadrneovim-c5d770d311841ea5230426cc4c868e8db27300a8.tar.gz
rneovim-c5d770d311841ea5230426cc4c868e8db27300a8.tar.bz2
rneovim-c5d770d311841ea5230426cc4c868e8db27300a8.zip
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'test/functional/options')
-rw-r--r--test/functional/options/belloff_spec.lua78
-rw-r--r--test/functional/options/chars_spec.lua2
-rw-r--r--test/functional/options/cursorbind_spec.lua1
-rw-r--r--test/functional/options/defaults_spec.lua2
-rw-r--r--test/functional/options/shortmess_spec.lua1
5 files changed, 78 insertions, 6 deletions
diff --git a/test/functional/options/belloff_spec.lua b/test/functional/options/belloff_spec.lua
new file mode 100644
index 0000000000..575e79d1a9
--- /dev/null
+++ b/test/functional/options/belloff_spec.lua
@@ -0,0 +1,78 @@
+local t = require('test.testutil')
+local n = require('test.functional.testnvim')()
+local Screen = require('test.functional.ui.screen')
+
+local clear = n.clear
+local command = n.command
+local api = n.api
+local feed = n.feed
+local poke_eventloop = n.poke_eventloop
+local eq = t.eq
+local retry = t.retry
+
+describe("'belloff'", function()
+ local screen
+
+ before_each(function()
+ clear()
+ screen = Screen.new(42, 5)
+ screen:expect([[
+ ^ |
+ {1:~ }|*3
+ |
+ ]])
+ end)
+
+ it('various flags work properly', function()
+ command('set cpoptions+=E')
+
+ local map = {
+ backspace = 'i<BS><Esc>',
+ cursor = 'i<Up><Esc>',
+ copy = 'i<C-Y><Esc>',
+ ctrlg = 'i<C-G><C-G><Esc>',
+ error = 'J',
+ esc = '<Esc>',
+ operator = 'y0',
+ register = 'i<C-R>@<Esc>',
+ }
+
+ local items = {} ---@type string[]
+ local inputs = {} ---@type string[]
+ for item, input in pairs(map) do
+ table.insert(items, item)
+ table.insert(inputs, input)
+ end
+
+ local values = {} ---@type string[]
+ for i, _ in ipairs(items) do
+ -- each tested 'belloff' value enables at most one item
+ local parts = vim.deepcopy(items)
+ table.remove(parts, i)
+ local value = table.concat(parts, ',')
+ table.insert(values, value)
+ end
+ table.insert(values, 'all')
+
+ for i, value in ipairs(values) do
+ api.nvim_set_option_value('belloff', value, {})
+
+ for j, input in ipairs(inputs) do
+ screen.bell = false
+ local beep = value ~= 'all' and i == j
+ -- Nvim avoids beeping more than 3 times in half a second,
+ -- so retry if beeping is expected but not received.
+ retry(not beep and 1 or nil, 1000, function()
+ feed(input)
+ poke_eventloop()
+ screen:expect({
+ condition = function()
+ eq(beep, screen.bell, ('%s with belloff=%s'):format(items[j], value))
+ end,
+ unchanged = not beep,
+ })
+ end)
+ end
+ end
+ end)
+end)
diff --git a/test/functional/options/chars_spec.lua b/test/functional/options/chars_spec.lua
index 8e63e07e09..42ca41a145 100644
--- a/test/functional/options/chars_spec.lua
+++ b/test/functional/options/chars_spec.lua
@@ -16,7 +16,6 @@ describe("'fillchars'", function()
before_each(function()
clear()
screen = Screen.new(25, 5)
- screen:attach()
end)
describe('"eob" flag', function()
@@ -157,7 +156,6 @@ describe("'listchars'", function()
before_each(function()
clear()
screen = Screen.new(50, 5)
- screen:attach()
end)
it('has global value', function()
diff --git a/test/functional/options/cursorbind_spec.lua b/test/functional/options/cursorbind_spec.lua
index 19551b928f..21e0ba8e75 100644
--- a/test/functional/options/cursorbind_spec.lua
+++ b/test/functional/options/cursorbind_spec.lua
@@ -18,7 +18,6 @@ describe("'cursorbind'", function()
[3] = { reverse = true }, -- StatusLineNC
[4] = { background = Screen.colors.Grey90 }, -- CursorLine, CursorColumn
})
- screen:attach()
exec([[
call setline(1, 'aa bb cc dd ee ff gg hh ii jj kk ll mm' ..
\ ' nn oo pp qq rr ss tt uu vv ww xx yy zz')
diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua
index e3d15fa30f..e7f47ef4e9 100644
--- a/test/functional/options/defaults_spec.lua
+++ b/test/functional/options/defaults_spec.lua
@@ -34,7 +34,6 @@ describe('startup defaults', function()
describe(':filetype', function()
local function expect_filetype(expected)
local screen = Screen.new(50, 4)
- screen:attach()
command('filetype')
screen:expect([[
^ |
@@ -127,7 +126,6 @@ describe('startup defaults', function()
it('vert/fold flags', function()
clear()
local screen = Screen.new(50, 5)
- screen:attach()
command('set laststatus=0')
insert([[
1
diff --git a/test/functional/options/shortmess_spec.lua b/test/functional/options/shortmess_spec.lua
index dcbf9d15e0..04dbada7d8 100644
--- a/test/functional/options/shortmess_spec.lua
+++ b/test/functional/options/shortmess_spec.lua
@@ -14,7 +14,6 @@ describe("'shortmess'", function()
before_each(function()
clear()
screen = Screen.new(42, 5)
- screen:attach()
end)
describe('"F" flag', function()