aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/ui/multibyte_spec.lua63
-rw-r--r--test/functional/viml/function_spec.lua11
-rw-r--r--test/includes/CMakeLists.txt7
-rw-r--r--test/includes/pre/uv.h (renamed from test/includes/pre/uv-errno.h)2
-rw-r--r--test/unit/buffer_spec.lua19
-rw-r--r--test/unit/os/fs_spec.lua2
6 files changed, 94 insertions, 10 deletions
diff --git a/test/functional/ui/multibyte_spec.lua b/test/functional/ui/multibyte_spec.lua
index 278480ec4f..3e63353ad2 100644
--- a/test/functional/ui/multibyte_spec.lua
+++ b/test/functional/ui/multibyte_spec.lua
@@ -1,6 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
+local command = helpers.command
local feed = helpers.feed
local feed_command = helpers.feed_command
local insert = helpers.insert
@@ -120,3 +121,65 @@ describe("multibyte rendering", function()
end)
end)
+describe('multibyte rendering: statusline', function()
+ local screen
+
+ before_each(function()
+ clear()
+ screen = Screen.new(40, 4)
+ screen:attach()
+ command('set laststatus=2')
+ end)
+
+ after_each(function()
+ screen:detach()
+ end)
+
+ it('last char shows (multibyte)', function()
+ command('set statusline=你好')
+ screen:expect([[
+ ^ |
+ ~ |
+ 你好 |
+ |
+ ]])
+ end)
+ it('last char shows (single byte)', function()
+ command('set statusline=abc')
+ screen:expect([[
+ ^ |
+ ~ |
+ abc |
+ |
+ ]])
+ end)
+ it('unicode control points', function()
+ command('set statusline=Ÿ')
+ screen:expect([[
+ ^ |
+ ~ |
+ <9f> |
+ |
+ ]])
+ end)
+ it('MAX_MCO (6) unicode combination points', function()
+ command('set statusline=o̸⃯ᷰ⃐⃧⃝')
+ -- o + U+1DF0 + U+20EF + U+0338 + U+20D0 + U+20E7 + U+20DD
+ screen:expect([[
+ ^ |
+ ~ |
+ o̸⃯ᷰ⃐⃧⃝ |
+ |
+ ]])
+ end)
+ it('non-printable followed by MAX_MCO unicode combination points', function()
+ command('set statusline=Ÿ̸⃯ᷰ⃐⃧⃝')
+ -- U+9F + U+1DF0 + U+20EF + U+0338 + U+20D0 + U+20E7 + U+20DD
+ screen:expect([[
+ ^ |
+ ~ |
+ <9f><1df0><20ef><0338><20d0><20e7><20dd>|
+ |
+ ]])
+ end)
+end)
diff --git a/test/functional/viml/function_spec.lua b/test/functional/viml/function_spec.lua
index 0cf92f7d40..b8137038b1 100644
--- a/test/functional/viml/function_spec.lua
+++ b/test/functional/viml/function_spec.lua
@@ -2,16 +2,11 @@ local helpers = require('test.functional.helpers')(after_each)
local eq = helpers.eq
local clear = helpers.clear
-local funcs = helpers.funcs
local dedent = helpers.dedent
local redir_exec = helpers.redir_exec
before_each(clear)
-local function check_nofunc(fname)
- eq(0, funcs.exists('*' .. fname))
-end
-
local function check_func(fname, body, indent)
if type(body) == 'number' then
body = ('return %i'):format(body)
@@ -141,12 +136,12 @@ describe(':endfunction', function()
]]))
check_func('F1', 42)
end)
- it('errors out on an uncommented bar', function()
- eq('\nE488: Trailing characters: | echo 42', redir_exec([[
+ it('accepts uncommented bar', function()
+ eq('\n42', redir_exec([[
function F1()
endfunction | echo 42
]]))
- check_nofunc('F1')
+ check_func('F1')
end)
it('allows running multiple commands', function()
eq('\n2', redir_exec([[
diff --git a/test/includes/CMakeLists.txt b/test/includes/CMakeLists.txt
index 2846df0e37..4d7e962fbd 100644
--- a/test/includes/CMakeLists.txt
+++ b/test/includes/CMakeLists.txt
@@ -7,6 +7,13 @@ foreach(gen_include ${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES})
list(APPEND gen_cflags ${CMAKE_INCLUDE_FLAG_C}${gen_include})
endforeach()
+get_directory_property(gen_cdefs COMPILE_DEFINITIONS)
+foreach(gen_cdef ${gen_cdefs})
+ if(NOT ${gen_cdef} MATCHES "INCLUDE_GENERATED_DECLARATIONS")
+ list(APPEND gen_cflags "-D${gen_cdef}")
+ endif()
+endforeach()
+
foreach(hfile ${PRE_HEADERS})
string(REGEX REPLACE ^pre/ post/ post_hfile ${hfile})
get_filename_component(hdir ${CMAKE_CURRENT_BINARY_DIR}/${post_hfile} PATH)
diff --git a/test/includes/pre/uv-errno.h b/test/includes/pre/uv.h
index 6b80f60e5c..da7818cd07 100644
--- a/test/includes/pre/uv-errno.h
+++ b/test/includes/pre/uv.h
@@ -1,4 +1,4 @@
-#include <uv-errno.h>
+#include <uv.h>
static const int kUV_ENOENT = UV_ENOENT;
static const int kUV_EEXIST = UV_EEXIST;
diff --git a/test/unit/buffer_spec.lua b/test/unit/buffer_spec.lua
index f7124b2782..bf4e5a0e6d 100644
--- a/test/unit/buffer_spec.lua
+++ b/test/unit/buffer_spec.lua
@@ -282,6 +282,12 @@ describe('buffer functions', function()
end)
end
+ -- expression testing
+ statusline_test('Should expand expression', 2,
+ '%!expand(20+1)', '21')
+ statusline_test('Should expand broken expression to itself', 11,
+ '%!expand(20+1', 'expand(20+1')
+
-- file name testing
statusline_test('should print no file name', 10,
'%f', '[No Name]',
@@ -306,6 +312,12 @@ describe('buffer functions', function()
statusline_test('should put fillchar `~` in between text', 10,
'abc%=def', 'abc~~~~def',
{fillchar=('~'):byte()})
+ statusline_test('should handle zero-fillchar as a space', 10,
+ 'abcde%=', 'abcde ',
+ {fillchar=0})
+ statusline_test('should handle multibyte-fillchar as a dash', 10,
+ 'abcde%=', 'abcde-----',
+ {fillchar=0x80})
statusline_test('should print the tail file name', 80,
'%t', 'buffer_spec.lua',
{file_name='test/unit/buffer_spec.lua', expected_cell_count=15})
@@ -352,6 +364,8 @@ describe('buffer functions', function()
statusline_test('should truncate at the first `<`', 10,
'abc%<def%<ghijklm', 'abc<hijklm')
+ statusline_test('should ignore trailing %', 3, 'abc%', 'abc')
+
-- alignment testing
statusline_test('should right align when using =', 20,
'neo%=vim', 'neo vim')
@@ -452,5 +466,10 @@ describe('buffer functions', function()
'Ą%=mid%=end', 'Ą@mid@@end',
{fillchar=('@'):byte(), expected_byte_length=11})
+ -- escaping % testing
+ statusline_test('should handle escape of %', 4, 'abc%%', 'abc%')
+ statusline_test('case where escaped % does not fit', 3, 'abc%%abcabc', '<bc')
+ statusline_test('escaped % is first', 1, '%%', '%')
+
end)
end)
diff --git a/test/unit/os/fs_spec.lua b/test/unit/os/fs_spec.lua
index ae6dfe6423..ddb438eb3d 100644
--- a/test/unit/os/fs_spec.lua
+++ b/test/unit/os/fs_spec.lua
@@ -27,7 +27,7 @@ cimport('./src/nvim/fileio.h')
local fs = cimport('./src/nvim/os/os.h', './src/nvim/path.h')
cppimport('sys/stat.h')
cppimport('fcntl.h')
-cppimport('uv-errno.h')
+cppimport('uv.h')
local s = ''
for i = 0, 255 do