aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ex_cmds
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/ex_cmds')
-rw-r--r--test/functional/ex_cmds/encoding_spec.lua23
-rw-r--r--test/functional/ex_cmds/global_spec.lua74
2 files changed, 85 insertions, 12 deletions
diff --git a/test/functional/ex_cmds/encoding_spec.lua b/test/functional/ex_cmds/encoding_spec.lua
index e2b3e7e31d..87ed7a2d0a 100644
--- a/test/functional/ex_cmds/encoding_spec.lua
+++ b/test/functional/ex_cmds/encoding_spec.lua
@@ -15,27 +15,26 @@ describe('&encoding', function()
execute('set encoding=latin1')
-- error message expected
feed('<cr>')
- neq(nil, string.find(eval('v:errmsg'), '^E905:'))
+ neq(nil, string.find(eval('v:errmsg'), '^E474:'))
eq('utf-8', eval('&encoding'))
-- check nvim is still in utf-8 mode
eq(3, eval('strwidth("Bär")'))
end)
- it('can be changed before startup', function()
+ it('cannot be changed before startup', function()
clear('--cmd', 'set enc=latin1')
- execute('set encoding=utf-8')
-- error message expected
feed('<cr>')
- eq('latin1', eval('&encoding'))
- eq(4, eval('strwidth("Bär")'))
+ neq(nil, string.find(eval('v:errmsg'), '^E474:'))
+ eq('utf-8', eval('&encoding'))
+ eq(3, eval('strwidth("Bär")'))
end)
- it('is not changed by `set all&`', function()
- -- we need to set &encoding to something non-default. Use 'latin1'
- clear('--cmd', 'set enc=latin1')
- execute('set all&')
- eq('latin1', eval('&encoding'))
- eq(4, eval('strwidth("Bär")'))
- end)
+ it('can be set to utf-8 without error', function()
+ execute('set encoding=utf-8')
+ eq("", eval('v:errmsg'))
+ clear('--cmd', 'set enc=utf-8')
+ eq("", eval('v:errmsg'))
+ end)
end)
diff --git a/test/functional/ex_cmds/global_spec.lua b/test/functional/ex_cmds/global_spec.lua
new file mode 100644
index 0000000000..81a0ef3248
--- /dev/null
+++ b/test/functional/ex_cmds/global_spec.lua
@@ -0,0 +1,74 @@
+local helpers = require('test.functional.helpers')(after_each)
+local Screen = require('test.functional.ui.screen')
+local clear, feed, source = helpers.clear, helpers.feed, helpers.source
+
+if helpers.pending_win32(pending) then return end
+
+describe(':global', function()
+ before_each(function()
+ clear()
+ end)
+
+ it('is interrupted by mapped CTRL-C', function()
+ if os.getenv("TRAVIS") and os.getenv("CLANG_SANITIZER") == "ASAN_UBSAN" then
+ -- XXX: ASAN_UBSAN is too slow to react to the CTRL-C.
+ pending("", function() end)
+ return
+ end
+
+ source([[
+ set nomore
+ set undolevels=-1
+ nnoremap <C-C> <NOP>
+ for i in range(0, 99999)
+ put ='XXX'
+ endfor
+ put ='ZZZ'
+ 1
+ .delete
+ ]])
+
+ local screen = Screen.new(52, 6)
+ screen:attach()
+ screen:set_default_attr_ids({
+ [0] = {foreground = Screen.colors.White,
+ background = Screen.colors.Red},
+ [1] = {bold = true,
+ foreground = Screen.colors.SeaGreen}
+ })
+
+ screen:expect([[
+ ^XXX |
+ XXX |
+ XXX |
+ XXX |
+ XXX |
+ |
+ ]])
+
+ local function test_ctrl_c(ms)
+ feed(":global/^/p<CR>")
+ helpers.sleep(ms)
+ feed("<C-C>")
+ screen:expect([[
+ XXX |
+ XXX |
+ XXX |
+ XXX |
+ {0:Interrupted} |
+ Interrupt: {1:Press ENTER or type command to continue}^ |
+ ]])
+ end
+
+ -- The test is time-sensitive. Try with different sleep values.
+ local ms_values = {10, 50, 100}
+ for i, ms in ipairs(ms_values) do
+ if i < #ms_values then
+ local status, _ = pcall(test_ctrl_c, ms)
+ if status then break end
+ else -- Call the last attempt directly.
+ test_ctrl_c(ms)
+ end
+ end
+ end)
+end)