diff --git a/test/functional/api/autocmd_spec.lua b/test/functional/api/autocmd_spec.lua index e908b3d8f7..7cc84a1023 100644 --- a/test/functional/api/autocmd_spec.lua +++ b/test/functional/api/autocmd_spec.lua @@ -590,11 +590,11 @@ describe('autocmd api', function() local aus = api.nvim_get_autocmds { event = { 'InsertEnter', 'InsertLeave' } } local first = aus[1] - eq(first.id, nil) + eq(nil, first.id) -- TODO: Maybe don't have this number, just assert it's not nil local second = aus[2] - neq(second.id, nil) + neq(nil, second.id) api.nvim_del_autocmd(second.id) local new_aus = api.nvim_get_autocmds { event = { 'InsertEnter', 'InsertLeave' } } diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua index 22974d6218..1f390b8077 100644 --- a/test/functional/api/server_requests_spec.lua +++ b/test/functional/api/server_requests_spec.lua @@ -449,7 +449,7 @@ describe('server -> client', function() call chansend(chan, 0Z71616C6C21) let g:statuses = jobwait([chan]) ]]) - eq(eval('g:statuses'), { 0 }) + eq({ 0 }, eval('g:statuses')) assert_alive() end) end) diff --git a/test/functional/api/tabpage_spec.lua b/test/functional/api/tabpage_spec.lua index cb8feff515..974f8969e4 100644 --- a/test/functional/api/tabpage_spec.lua +++ b/test/functional/api/tabpage_spec.lua @@ -6,7 +6,6 @@ local describe, it, before_each = t.describe, t.it, t.before_each local clear, eq, ok = n.clear, t.eq, t.ok local matches = t.matches local exec = n.exec -local feed = n.feed local api = n.api local fn = n.fn local request = n.request @@ -201,12 +200,12 @@ describe('api/tabpage', function() local newtabs = api.nvim_list_tabpages() eq(3, #newtabs) - eq(newtabs, { + eq({ tab1, tab2, -- new_tab, tab3, - }) + }, newtabs) local new_tab = api.nvim_open_tabpage(0, false, { after = api.nvim_tabpage_get_number(tab2) }) local newtabs2 = api.nvim_list_tabpages() @@ -217,7 +216,7 @@ describe('api/tabpage', function() new_tab, tab3, }, newtabs2) - eq(api.nvim_get_current_tabpage(), tab3) + eq(tab3, api.nvim_get_current_tabpage()) end) it('respects the `enter` argument', function() @@ -228,8 +227,8 @@ describe('api/tabpage', function() local new_tab = api.nvim_open_tabpage(0, false, {}) local newtabs = api.nvim_list_tabpages() eq(2, #newtabs) - eq(newtabs, { tab1, new_tab }) - eq(api.nvim_get_current_tabpage(), tab1) + eq({ tab1, new_tab }, newtabs) + eq(tab1, api.nvim_get_current_tabpage()) -- Tabline redrawn when not entering. screen:expect([[ {5: [No Name] }{24: [No Name] }{2: }{24:X}| @@ -241,8 +240,8 @@ describe('api/tabpage', function() local new_tab2 = api.nvim_open_tabpage(0, true, {}) local newtabs2 = api.nvim_list_tabpages() eq(3, #newtabs2) - eq(newtabs2, { tab1, new_tab2, new_tab }) - eq(api.nvim_get_current_tabpage(), new_tab2) + eq({ tab1, new_tab2, new_tab }, newtabs2) + eq(new_tab2, api.nvim_get_current_tabpage()) -- Tabline redrawn. (when entering) screen:expect([[ {24: [No Name] }{5: [No Name] }{24: [No Name] }{2: }{24:X}| @@ -364,7 +363,7 @@ describe('api/tabpage', function() eq(6, #tabs_after_middle) eq({ first_tab, tab1, before_middle, tab2, tab3, explicit_after_current }, tabs_after_middle) - eq(api.nvim_get_current_tabpage(), tab3) + eq(tab3, api.nvim_get_current_tabpage()) -- Test default behavior (after current) local default_after_current = api.nvim_open_tabpage(0, false, {}) diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua index f79b8aad12..c4af4e5519 100644 --- a/test/functional/api/window_spec.lua +++ b/test/functional/api/window_spec.lua @@ -48,9 +48,9 @@ describe('API/win', function() it('works', function() command('new') local windows = api.nvim_list_wins() - neq(api.nvim_win_get_buf(windows[2]), api.nvim_win_get_buf(windows[1])) + neq(api.nvim_win_get_buf(windows[1]), api.nvim_win_get_buf(windows[2])) api.nvim_win_set_buf(windows[2], api.nvim_win_get_buf(windows[1])) - eq(api.nvim_win_get_buf(windows[2]), api.nvim_win_get_buf(windows[1])) + eq(api.nvim_win_get_buf(windows[1]), api.nvim_win_get_buf(windows[2])) end) it('validates args', function() @@ -651,13 +651,13 @@ describe('API/win', function() end) end) - describe('get_position', function() + describe('get_tabpage', function() it('works', function() command('tabnew') command('vsplit') - eq(api.nvim_win_get_tabpage(api.nvim_list_wins()[1]), api.nvim_list_tabpages()[1]) - eq(api.nvim_win_get_tabpage(api.nvim_list_wins()[2]), api.nvim_list_tabpages()[2]) - eq(api.nvim_win_get_tabpage(api.nvim_list_wins()[3]), api.nvim_list_tabpages()[2]) + eq(api.nvim_list_tabpages()[1], api.nvim_win_get_tabpage(api.nvim_list_wins()[1])) + eq(api.nvim_list_tabpages()[2], api.nvim_win_get_tabpage(api.nvim_list_wins()[2])) + eq(api.nvim_list_tabpages()[2], api.nvim_win_get_tabpage(api.nvim_list_wins()[3])) end) end) @@ -1693,8 +1693,8 @@ describe('API/win', function() row = 1, col = 1, }) - eq(api.nvim_win_get_tabpage(win), first_tab) - eq(api.nvim_get_current_tabpage(), new_tab) + eq(first_tab, api.nvim_win_get_tabpage(win)) + eq(new_tab, api.nvim_get_current_tabpage()) end) it('switches to new windows in non-current tabpages when enter=true', function() @@ -1709,8 +1709,8 @@ describe('API/win', function() row = 1, col = 1, }) - eq(api.nvim_win_get_tabpage(win), first_tab) - eq(api.nvim_get_current_tabpage(), first_tab) + eq(first_tab, api.nvim_win_get_tabpage(win)) + eq(first_tab, api.nvim_get_current_tabpage()) end) local function setup_tabbed_autocmd_test() diff --git a/test/functional/ex_cmds/menu_spec.lua b/test/functional/ex_cmds/menu_spec.lua index 9fa8681701..07cb5ccf62 100644 --- a/test/functional/ex_cmds/menu_spec.lua +++ b/test/functional/ex_cmds/menu_spec.lua @@ -626,7 +626,7 @@ describe('menu_get', function() }, } - eq(m, expected) + eq(expected, m) end) it('works with right-aligned text and spaces', function() @@ -707,6 +707,6 @@ describe('menu_get', function() }, } - eq(m, expected) + eq(expected, m) end) end) diff --git a/test/functional/lua/comment_spec.lua b/test/functional/lua/comment_spec.lua index 95debcfc53..7ba54bcac8 100644 --- a/test/functional/lua/comment_spec.lua +++ b/test/functional/lua/comment_spec.lua @@ -65,19 +65,19 @@ describe('commenting', function() it('works', function() toggle_lines(3, 5) - eq(get_lines(2, 5), { ' # aa', ' #', ' # aa' }) + eq({ ' # aa', ' #', ' # aa' }, get_lines(2, 5)) toggle_lines(3, 5) - eq(get_lines(2, 5), { ' aa', '', ' aa' }) + eq({ ' aa', '', ' aa' }, get_lines(2, 5)) end) it("works with different 'commentstring' options", function() local validate = function(lines_before, lines_after, lines_again) set_lines(lines_before) toggle_lines(1, #lines_before) - eq(get_lines(), lines_after) + eq(lines_after, get_lines()) toggle_lines(1, #lines_before) - eq(get_lines(), lines_again or lines_before) + eq(lines_again or lines_before, get_lines()) end -- Single whitespace inside comment parts (main case) @@ -259,7 +259,7 @@ describe('commenting', function() local validate = function(line, ref_output) set_lines(lines) toggle_lines(line, line) - eq(get_lines(line - 1, line)[1], ref_output) + eq(ref_output, get_lines(line - 1, line)[1]) end validate(1, '"set background=dark') @@ -274,21 +274,21 @@ describe('commenting', function() set_lines(lines) toggle_lines(1, 3) local out_lines = get_lines() - eq(out_lines[1], '"set background=dark') - eq(out_lines[2], '"lua << EOF') - eq(out_lines[3], '"print(1)') + eq('"set background=dark', out_lines[1]) + eq('"lua << EOF', out_lines[2]) + eq('"print(1)', out_lines[3]) end) it('correctly computes indent', function() toggle_lines(2, 4) - eq(get_lines(1, 4), { ' # aa', ' # aa', ' #' }) + eq({ ' # aa', ' # aa', ' #' }, get_lines(1, 4)) end) it('correctly detects comment/uncomment', function() local validate = function(from, to, ref_lines) set_lines({ '', 'aa', '# aa', '# aa', 'aa', '' }) toggle_lines(from, to) - eq(get_lines(), ref_lines) + eq(ref_lines, get_lines()) end -- It should uncomment only if all non-blank lines are comments @@ -300,14 +300,14 @@ describe('commenting', function() -- Blank lines should be ignored when making a decision set_lines({ '# aa', '', ' ', '\t', '# aa' }) toggle_lines(1, 5) - eq(get_lines(), { 'aa', '', ' ', '\t', 'aa' }) + eq({ 'aa', '', ' ', '\t', 'aa' }, get_lines()) end) it('correctly matches comment parts during checking and uncommenting', function() local validate = function(from, to, ref_lines) set_lines({ '/*aa*/', '/* aa */', '/* aa */' }) toggle_lines(from, to) - eq(get_lines(), ref_lines) + eq(ref_lines, get_lines()) end -- Should first try to match 'commentstring' parts exactly with their @@ -336,7 +336,7 @@ describe('commenting', function() it('uncomments on inconsistent indent levels', function() set_lines({ '# aa', ' # aa', ' # aa' }) toggle_lines(1, 3) - eq(get_lines(), { 'aa', ' aa', ' aa' }) + eq({ 'aa', ' aa', ' aa' }, get_lines()) end) it('respects tabs', function() @@ -344,10 +344,10 @@ describe('commenting', function() set_lines({ '\t\taa', '\t\taa' }) toggle_lines(1, 2) - eq(get_lines(), { '\t\t# aa', '\t\t# aa' }) + eq({ '\t\t# aa', '\t\t# aa' }, get_lines()) toggle_lines(1, 2) - eq(get_lines(), { '\t\taa', '\t\taa' }) + eq({ '\t\taa', '\t\taa' }, get_lines()) end) it('works with trailing whitespace', function() @@ -355,23 +355,23 @@ describe('commenting', function() set_commentstring('# %s') set_lines({ ' aa', ' aa ', ' ' }) toggle_lines(1, 3) - eq(get_lines(), { ' # aa', ' # aa ', ' #' }) + eq({ ' # aa', ' # aa ', ' #' }, get_lines()) toggle_lines(1, 3) - eq(get_lines(), { ' aa', ' aa ', '' }) + eq({ ' aa', ' aa ', '' }, get_lines()) -- With right-hand side set_commentstring('%s #') set_lines({ ' aa', ' aa ', ' ' }) toggle_lines(1, 3) - eq(get_lines(), { ' aa #', ' aa #', ' #' }) + eq({ ' aa #', ' aa #', ' #' }, get_lines()) toggle_lines(1, 3) - eq(get_lines(), { ' aa', ' aa ', '' }) + eq({ ' aa', ' aa ', '' }, get_lines()) -- Trailing whitespace after right side should be preserved for non-blanks set_commentstring('%s #') set_lines({ ' aa # ', ' aa #\t', ' # ', ' #\t' }) toggle_lines(1, 4) - eq(get_lines(), { ' aa ', ' aa\t', '', '' }) + eq({ ' aa ', ' aa\t', '', '' }, get_lines()) end) end) @@ -379,15 +379,15 @@ describe('commenting', function() it('works in Normal mode', function() set_cursor(2, 2) feed('gc', 'ap') - eq(get_lines(), { '# aa', '# aa', '# aa', '#', ' aa', ' aa', 'aa' }) + eq({ '# aa', '# aa', '# aa', '#', ' aa', ' aa', 'aa' }, get_lines()) -- Cursor moves to start line - eq(get_cursor(), { 1, 0 }) + eq({ 1, 0 }, get_cursor()) -- Supports `v:count` set_lines(example_lines) set_cursor(2, 0) feed('2gc', 'ap') - eq(get_lines(), { '# aa', '# aa', '# aa', '#', '# aa', '# aa', '# aa' }) + eq({ '# aa', '# aa', '# aa', '#', '# aa', '# aa', '# aa' }, get_lines()) end) it('allows dot-repeat in Normal mode', function() @@ -397,7 +397,7 @@ describe('commenting', function() set_cursor(2, 2) feed('gc', 'ap') feed('.') - eq(get_lines(), doubly_commented) + eq(doubly_commented, get_lines()) -- Not immediate dot-repeat set_lines(example_lines) @@ -405,16 +405,16 @@ describe('commenting', function() feed('gc', 'ap') set_cursor(7, 0) feed('.') - eq(get_lines(), doubly_commented) + eq(doubly_commented, get_lines()) end) it('works in Visual mode', function() set_cursor(2, 2) feed('v', 'ap', 'gc') - eq(get_lines(), { '# aa', '# aa', '# aa', '#', ' aa', ' aa', 'aa' }) + eq({ '# aa', '# aa', '# aa', '#', ' aa', ' aa', 'aa' }, get_lines()) -- Cursor moves to start line - eq(get_cursor(), { 1, 0 }) + eq({ 1, 0 }, get_cursor()) end) it('allows dot-repeat after initial Visual mode', function() @@ -423,32 +423,32 @@ describe('commenting', function() set_lines(example_lines) set_cursor(2, 2) feed('vip', 'gc') - eq(get_lines(), { '# aa', '# aa', '# aa', '', ' aa', ' aa', 'aa' }) - eq(get_cursor(), { 1, 0 }) + eq({ '# aa', '# aa', '# aa', '', ' aa', ' aa', 'aa' }, get_lines()) + eq({ 1, 0 }, get_cursor()) -- Dot-repeat after first application in Visual mode applies to the paragraph at cursor (not -- a fixed-size region). feed('.') - eq(get_lines(), example_lines) + eq(example_lines, get_lines()) set_cursor(3, 0) feed('.') - eq(get_lines(), { '# aa', '# aa', '# aa', '', ' aa', ' aa', 'aa' }) + eq({ '# aa', '# aa', '# aa', '', ' aa', ' aa', 'aa' }, get_lines()) end) it("respects 'commentstring'", function() set_commentstring('/*%s*/') set_cursor(2, 2) feed('gc', 'ap') - eq(get_lines(), { '/*aa*/', '/* aa*/', '/* aa*/', '/**/', ' aa', ' aa', 'aa' }) + eq({ '/*aa*/', '/* aa*/', '/* aa*/', '/**/', ' aa', ' aa', 'aa' }, get_lines()) end) it("works with empty 'commentstring'", function() set_commentstring('') set_cursor(2, 2) feed('gc', 'ap') - eq(get_lines(), example_lines) - eq(exec_capture('1messages'), [[Option 'commentstring' is empty.]]) + eq(example_lines, get_lines()) + eq([[Option 'commentstring' is empty.]], exec_capture('1messages')) end) it('respects tree-sitter injections', function() @@ -469,7 +469,7 @@ describe('commenting', function() set_lines(lines) set_cursor(line, 0) feed('gc_') - eq(get_lines(line - 1, line)[1], ref_output) + eq(ref_output, get_lines(line - 1, line)[1]) end validate(1, '"set background=dark') @@ -485,11 +485,11 @@ describe('commenting', function() set_cursor(1, 0) feed('gc_') - eq(get_lines()[1], '"set background=dark') + eq('"set background=dark', get_lines()[1]) set_cursor(3, 0) feed('.') - eq(get_lines()[3], '-- print(1)') + eq('-- print(1)', get_lines()[3]) -- Multiline comments should be computed based on cursor position -- which in case of Visual selection means its left part @@ -497,9 +497,9 @@ describe('commenting', function() set_cursor(1, 0) feed('v2j', 'gc') local out_lines = get_lines() - eq(out_lines[1], '"set background=dark') - eq(out_lines[2], '"lua << EOF') - eq(out_lines[3], '"print(1)') + eq('"set background=dark', out_lines[1]) + eq('"lua << EOF', out_lines[2]) + eq('"print(1)', out_lines[3]) end) it("recomputes local 'commentstring' based on cursor position", function() @@ -514,12 +514,12 @@ describe('commenting', function() set_cursor(1, 1) feed('gc_') - eq(get_lines()[1], ' "print(1)') + eq(' "print(1)', get_lines()[1]) set_lines(lines) set_cursor(3, 2) feed('.') - eq(get_lines()[3], ' -- print(1)') + eq(' -- print(1)', get_lines()[3]) end) it('preserves marks', function() @@ -527,8 +527,8 @@ describe('commenting', function() -- Set '`<' and '`>' marks feed('VV') feed('gc', 'ip') - eq(api.nvim_buf_get_mark(0, '<'), { 2, 0 }) - eq(api.nvim_buf_get_mark(0, '>'), { 2, 2147483647 }) + eq({ 2, 0 }, api.nvim_buf_get_mark(0, '<')) + eq({ 2, 2147483647 }, api.nvim_buf_get_mark(0, '>')) end) end) @@ -537,19 +537,19 @@ describe('commenting', function() set_lines(example_lines) set_cursor(1, 1) feed('gcc') - eq(get_lines(0, 2), { '# aa', ' aa' }) + eq({ '# aa', ' aa' }, get_lines(0, 2)) -- Does not comment empty line set_lines(example_lines) set_cursor(4, 0) feed('gcc') - eq(get_lines(2, 5), { ' aa', '', ' aa' }) + eq({ ' aa', '', ' aa' }, get_lines(2, 5)) -- Supports `v:count` set_lines(example_lines) set_cursor(2, 0) feed('2gcc') - eq(get_lines(0, 3), { 'aa', ' # aa', ' # aa' }) + eq({ 'aa', ' # aa', ' # aa' }, get_lines(0, 3)) end) it('allows dot-repeat', function() @@ -557,7 +557,7 @@ describe('commenting', function() set_cursor(1, 1) feed('gcc') feed('.') - eq(get_lines(), example_lines) + eq(example_lines, get_lines()) -- Not immediate dot-repeat set_lines(example_lines) @@ -565,7 +565,7 @@ describe('commenting', function() feed('gcc') set_cursor(7, 0) feed('.') - eq(get_lines(6, 7), { '# aa' }) + eq({ '# aa' }, get_lines(6, 7)) end) it('respects tree-sitter injections', function() @@ -581,12 +581,12 @@ describe('commenting', function() set_cursor(1, 0) feed('gcc') - eq(get_lines(), { '"set background=dark', 'lua << EOF', 'print(1)', 'EOF' }) + eq({ '"set background=dark', 'lua << EOF', 'print(1)', 'EOF' }, get_lines()) -- Should work with dot-repeat set_cursor(3, 0) feed('.') - eq(get_lines(), { '"set background=dark', 'lua << EOF', '-- print(1)', 'EOF' }) + eq({ '"set background=dark', 'lua << EOF', '-- print(1)', 'EOF' }, get_lines()) end) it('respects tree-sitter commentstring metadata', function() @@ -762,7 +762,7 @@ describe('commenting', function() set_lines({ 'aa', '# aa', '# aa', 'aa' }) set_cursor(2, 0) feed('d', 'gc') - eq(get_lines(), { 'aa', 'aa' }) + eq({ 'aa', 'aa' }, get_lines()) end) it('allows dot-repeat', function() @@ -771,20 +771,20 @@ describe('commenting', function() feed('d', 'gc') set_cursor(3, 0) feed('.') - eq(get_lines(), { 'aa', 'aa' }) + eq({ 'aa', 'aa' }, get_lines()) end) it('does nothing when not inside textobject', function() -- Builtin operators feed('d', 'gc') - eq(get_lines(), example_lines) + eq(example_lines, get_lines()) -- Comment operator local validate_no_action = function(line, col) set_lines(example_lines) set_cursor(line, col) feed('gc', 'gc') - eq(get_lines(), example_lines) + eq(example_lines, get_lines()) end validate_no_action(1, 1) @@ -809,12 +809,12 @@ describe('commenting', function() set_cursor(1, 0) feed('dgc') - eq(get_lines(), { 'lua << EOF', '-- print(1)', '-- print(2)', 'EOF' }) + eq({ 'lua << EOF', '-- print(1)', '-- print(2)', 'EOF' }, get_lines()) -- Should work with dot-repeat set_cursor(2, 0) feed('.') - eq(get_lines(), { 'lua << EOF', 'EOF' }) + eq({ 'lua << EOF', 'EOF' }, get_lines()) end) end) end) diff --git a/test/functional/lua/fs_spec.lua b/test/functional/lua/fs_spec.lua index 26c86c920a..df256dc93a 100644 --- a/test/functional/lua/fs_spec.lua +++ b/test/functional/lua/fs_spec.lua @@ -1019,14 +1019,14 @@ describe('vim.fs', function() -- File vim.uv.fs_symlink('Xtest_fs-rm/file-to-link', 'Xtest_fs-rm/file-as-link') vim.fs.rm('Xtest_fs-rm/file-as-link') - eq(vim.uv.fs_stat('Xtest_fs-rm/file-as-link'), nil) + eq(nil, vim.uv.fs_stat('Xtest_fs-rm/file-as-link')) eq({ 'File to link' }, fn.readfile('Xtest_fs-rm/file-to-link')) -- Directory local function assert_rm_symlinked_dir(opts) vim.uv.fs_symlink('Xtest_fs-rm/dir-to-link', 'Xtest_fs-rm/dir-as-link') vim.fs.rm('Xtest_fs-rm/dir-as-link', opts) - eq(vim.uv.fs_stat('Xtest_fs-rm/dir-as-link'), nil) + eq(nil, vim.uv.fs_stat('Xtest_fs-rm/dir-as-link')) eq({ 'File in dir to link' }, fn.readfile('Xtest_fs-rm/dir-to-link/file')) end diff --git a/test/functional/lua/range_spec.lua b/test/functional/lua/range_spec.lua index c1e9f1708c..d994d64fe6 100644 --- a/test/functional/lua/range_spec.lua +++ b/test/functional/lua/range_spec.lua @@ -53,7 +53,7 @@ describe('vim.range', function() return vim.range(vim.pos(buf1, 3, 5), vim.pos(buf2, 4, 6)) end) end) - eq(success, false) + eq(false, success) end) it('is modifiable', function() diff --git a/test/functional/lua/ui_spec.lua b/test/functional/lua/ui_spec.lua index bcd7ff7419..04646c202e 100644 --- a/test/functional/lua/ui_spec.lua +++ b/test/functional/lua/ui_spec.lua @@ -203,7 +203,7 @@ describe('vim.ui', function() }) n.api.nvim_set_option_value('filetype', 'help', { buf = buf, scope = 'local' }) local tags = n.api.nvim_buf_get_extmarks(buf, link_ns, 0, -1, {}) - eq(#tags, 0) + eq(0, #tags) end) end) end) diff --git a/test/functional/lua/version_spec.lua b/test/functional/lua/version_spec.lua index c40733ff19..b7308853a6 100644 --- a/test/functional/lua/version_spec.lua +++ b/test/functional/lua/version_spec.lua @@ -91,8 +91,8 @@ describe('version', function() end) it('tostring() ' .. input, function() - eq(type(tostring(range)), 'string') - eq(vim.version.range(tostring(range)), range) + eq('string', type(tostring(range))) + eq(range, vim.version.range(tostring(range))) end) it('[from] in range ' .. input, function() @@ -150,11 +150,11 @@ describe('version', function() assert(vim.version.range('>1.2.3-0'):has('1.2.3-1')) local range_alpha = vim.version.range('1.2.3-alpha') - eq(vim.version.range(tostring(range_alpha)), range_alpha) + eq(range_alpha, vim.version.range(tostring(range_alpha))) end) it('returns nil with empty version', function() - eq(vim.version.parse(''), nil) + eq(nil, vim.version.parse('')) end) end) @@ -163,12 +163,12 @@ describe('version', function() local r1 = vim.version.range(input[1]) local r2 = vim.version.range(input[2]) if output == nil then - eq(vim.version.intersect(r1, r2), nil) - eq(vim.version.intersect(r2, r1), nil) + eq(nil, vim.version.intersect(r1, r2)) + eq(nil, vim.version.intersect(r2, r1)) else local ref = vim.version.range(output) - eq(vim.version.intersect(r1, r2), ref) - eq(vim.version.intersect(r2, r1), ref) + eq(ref, vim.version.intersect(r1, r2)) + eq(ref, vim.version.intersect(r2, r1)) end end @@ -457,8 +457,8 @@ describe('version', function() assert(v('v1.2.3') >= v('1.2.2')) assert(v('v1.2.3') > v('1.2.2')) assert(v('v1.2.3') > v('1.0.3')) - eq(vim.version.last({ v('1.2.3'), v('2.0.0') }), v('2.0.0')) - eq(vim.version.last({ v('2.0.0'), v('1.2.3') }), v('2.0.0')) + eq(v('2.0.0'), vim.version.last({ v('1.2.3'), v('2.0.0') })) + eq(v('2.0.0'), vim.version.last({ v('2.0.0'), v('1.2.3') })) end) it('le()', function() diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index 485ded7e47..f1b47619a1 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -1392,7 +1392,7 @@ describe('lua stdlib', function() it('vim.fn `func_lua` (fast path for Lua-implemented builtins)', function() -- hostname() is implemented via func_lua, calling Lua directly when invoked from Lua. local lua_result = exec_lua([[return vim.fn.hostname()]]) - eq(type(lua_result), 'string') + eq('string', type(lua_result)) assert(#lua_result > 0, 'hostname() should return a non-empty string') -- VimScript path (lua_wrapper) should return the same result. eq(lua_result, eval('hostname()')) diff --git a/test/functional/lua/with_spec.lua b/test/functional/lua/with_spec.lua index e5b9b013c0..f86562ed4f 100644 --- a/test/functional/lua/with_spec.lua +++ b/test/functional/lua/with_spec.lua @@ -724,8 +724,8 @@ describe('vim._with', function() command('wincmd s | wincmd 5+') win_id_3 = api.nvim_get_current_win() - eq(is_approx_eq('width', win_id_1, win_id_2), false) - eq(is_approx_eq('height', win_id_3, win_id_2), false) + eq(false, is_approx_eq('width', win_id_1, win_id_2)) + eq(false, is_approx_eq('height', win_id_3, win_id_2)) end) pending('works', function() @@ -735,8 +735,8 @@ describe('vim._with', function() vim.cmd.wincmd('=') end) ]] - eq(is_approx_eq('width', win_id_1, win_id_2), true) - eq(is_approx_eq('height', win_id_3, win_id_2), false) + eq(true, is_approx_eq('width', win_id_1, win_id_2)) + eq(false, is_approx_eq('height', win_id_3, win_id_2)) end) pending('can be nested', function() @@ -748,8 +748,8 @@ describe('vim._with', function() end) end) ]] - eq(is_approx_eq('width', win_id_1, win_id_2), true) - eq(is_approx_eq('height', win_id_3, win_id_2), true) + eq(true, is_approx_eq('width', win_id_1, win_id_2)) + eq(true, is_approx_eq('height', win_id_3, win_id_2)) end) end) diff --git a/test/functional/plugin/lsp/diagnostic_spec.lua b/test/functional/plugin/lsp/diagnostic_spec.lua index f1c3cded05..df530ed472 100644 --- a/test/functional/plugin/lsp/diagnostic_spec.lua +++ b/test/functional/plugin/lsp/diagnostic_spec.lua @@ -509,8 +509,8 @@ describe('vim.lsp.diagnostic', function() end) -- This test case must be run over a multiline diagnostic in which the start line is shorter -- than the end line, and the end_col exceeds the start line's length. - eq(#lines[1], 8) - eq(#lines[2], 16) + eq(8, #lines[1]) + eq(16, #lines[2]) eq(1, #diags) eq(6, diags[1].col) eq(10, diags[1].end_col) diff --git a/test/functional/plugin/pack_spec.lua b/test/functional/plugin/pack_spec.lua index ece1731df7..0287b05d14 100644 --- a/test/functional/plugin/pack_spec.lua +++ b/test/functional/plugin/pack_spec.lua @@ -393,12 +393,12 @@ local function assert_progress_report(echo_log, action, step_names) steps_seen[step] = true -- Should not add intermediate progress report to history - eq(echo_args[2], false) + eq(false, echo_args[2]) -- Should update a single message by its id (computed after first call) progress.id = progress.id or echo_args[3].id ---@type integer progress.percent = math.floor(100 * i / n_steps) - eq(echo_args[3], progress) + eq(progress, echo_args[3]) end -- Should report all steps @@ -499,7 +499,7 @@ describe('vim.pack', function() watch_events({ 'PackChanged' }) vim_pack_add({ repos_src.basic }) - eq(exec_lua('return #_G.event_log'), 0) + eq(0, exec_lua('return #_G.event_log')) -- Should not create redundant stash entry local basic_path = pack_get_plug_path('basic') @@ -1338,13 +1338,13 @@ describe('vim.pack', function() -- Buffer should be special and shown in a separate tabpage eq(2, #api.nvim_list_tabpages()) eq(2, fn.tabpagenr()) - eq(api.nvim_get_option_value('filetype', {}), 'nvim-pack') - eq(api.nvim_get_option_value('modifiable', {}), false) - eq(api.nvim_get_option_value('buftype', {}), 'acwrite') + eq('nvim-pack', api.nvim_get_option_value('filetype', {})) + eq(false, api.nvim_get_option_value('modifiable', {})) + eq('acwrite', api.nvim_get_option_value('buftype', {})) local confirm_bufnr = api.nvim_get_current_buf() local confirm_winnr = api.nvim_get_current_win() local confirm_tabpage = api.nvim_get_current_tabpage() - eq(api.nvim_buf_get_name(0), 'nvim-pack://confirm#' .. confirm_bufnr) + eq('nvim-pack://confirm#' .. confirm_bufnr, api.nvim_buf_get_name(0)) -- Adjust lines for a more robust screenshot testing local fetch_src = repos_src.fetch @@ -1826,7 +1826,7 @@ describe('vim.pack', function() -- - Can still respect `:write` after action n.exec('write') eq('vim.pack: Nothing to update', n.exec_capture('1messages')) - eq(api.nvim_get_option_value('filetype', {}), '') + eq('', api.nvim_get_option_value('filetype', {})) end) it('has buffer-local mappings', function() diff --git a/test/functional/terminal/parser_spec.lua b/test/functional/terminal/parser_spec.lua index d2cfae0794..db4078db7a 100644 --- a/test/functional/terminal/parser_spec.lua +++ b/test/functional/terminal/parser_spec.lua @@ -28,7 +28,7 @@ describe(':terminal', function() api.nvim_chan_send(chan, input) --- @type string local term_title = api.nvim_buf_get_var(0, 'term_title') - t.eq(term_title, 'This title set with OSC 2') + t.eq('This title set with OSC 2', term_title) assert_alive() end) @@ -40,7 +40,7 @@ describe(':terminal', function() api.nvim_chan_send(chan, input) --- @type string local term_title = api.nvim_buf_get_var(0, 'term_title') - t.eq(term_title, 'This title set with OSC 0') + t.eq('This title set with OSC 0', term_title) assert_alive() end) diff --git a/test/functional/ui/cmdline2_spec.lua b/test/functional/ui/cmdline2_spec.lua index 2077985419..2033d16abf 100644 --- a/test/functional/ui/cmdline2_spec.lua +++ b/test/functional/ui/cmdline2_spec.lua @@ -180,7 +180,7 @@ describe('cmdline2', function() {1:~ }|*12 {16::}{15:find} ^ | ]]) - t.eq(n.eval('v:errmsg'), "E1514: 'findfunc' did not return a List type") + t.eq("E1514: 'findfunc' did not return a List type", n.eval('v:errmsg')) end) it('substitution match, empty message does not clear active cmdline', function() diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index d1b7a28835..414ad9707b 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -1427,7 +1427,7 @@ stack traceback: ^ | {1:~ }|*4 ]]) - eq(showmode, 0) + eq(0, showmode) feed('i') screen:expect({ grid = [[ @@ -1436,17 +1436,17 @@ stack traceback: ]], showmode = { { '-- INSERT --', 5, 'ModeMsg' } }, }) - eq(showmode, 2) + eq(2, showmode) command('set noshowmode') feed('') screen:expect([[ ^ | {1:~ }|*4 ]]) - eq(showmode, 3) + eq(3, showmode) feed('i') screen:expect_unchanged() - eq(showmode, 3) + eq(3, showmode) end) it('emits single message for multiline print())', function() diff --git a/test/functional/ui/scrollbind_spec.lua b/test/functional/ui/scrollbind_spec.lua index 1818a5c5f4..54239fec1c 100644 --- a/test/functional/ui/scrollbind_spec.lua +++ b/test/functional/ui/scrollbind_spec.lua @@ -398,8 +398,8 @@ describe('Scrollbind', function() n.feed('') n.feed('') - t.eq(n.exec_lua [[return vim.fn.line('w0', 1001)]], 6) - t.eq(n.exec_lua [[return vim.fn.line('w0', 1000)]], 3) + t.eq(6, n.exec_lua [[return vim.fn.line('w0', 1001)]]) + t.eq(3, n.exec_lua [[return vim.fn.line('w0', 1000)]]) screen:expect({ grid = [[ diff --git a/test/unit/mbyte_spec.lua b/test/unit/mbyte_spec.lua index b9ce24fb4f..298b2c4f28 100644 --- a/test/unit/mbyte_spec.lua +++ b/test/unit/mbyte_spec.lua @@ -312,9 +312,9 @@ describe('mbyte', function() pos = pos + clen table.insert(breaks, pos) end - eq(breaks[#breaks], len) -- include EOT as break + eq(len, breaks[#breaks]) -- include EOT as break -- we could also send in breaks, but this is more human readable - eq(mb_glyphs, expected_glyphs) + eq(expected_glyphs, mb_glyphs) for i = 1, #breaks - 1 do local start, next = breaks[i], breaks[i + 1] diff --git a/test/unit/os/fs_spec.lua b/test/unit/os/fs_spec.lua index 1d6ae312ec..4bb1901965 100644 --- a/test/unit/os/fs_spec.lua +++ b/test/unit/os/fs_spec.lua @@ -508,7 +508,7 @@ describe('fs.c', function() for _, _ in pairs(tbl) do i = i + 1 end - eq(i, 6) -- All fds must be unique + eq(6, i) -- All fds must be unique end) end) diff --git a/test/unit/termkey_spec.lua b/test/unit/termkey_spec.lua index 4faf282a1f..3a53bb4947 100644 --- a/test/unit/termkey_spec.lua +++ b/test/unit/termkey_spec.lua @@ -71,16 +71,16 @@ local termkey = t.cimport( describe('termkey', function() itp('01base', function() local tk = termkey.termkey_new_abstract(nil, 0) - t.neq(tk, nil) + t.neq(nil, tk) - t.eq(termkey.termkey_get_buffer_size(tk), 256) - t.eq(tk.is_started, 1) -- tk->is_started true after construction + t.eq(256, termkey.termkey_get_buffer_size(tk)) + t.eq(1, tk.is_started) -- tk->is_started true after construction termkey.termkey_stop(tk) - t.neq(tk.is_started, 1) -- tk->is_started false after termkey_stop() + t.neq(1, tk.is_started) -- tk->is_started false after termkey_stop() termkey.termkey_start(tk) - t.eq(tk.is_started, 1) -- tk->is_started true after termkey_start() + t.eq(1, tk.is_started) -- tk->is_started true after termkey_start() termkey.termkey_destroy(tk) end) @@ -89,42 +89,42 @@ describe('termkey', function() local tk = termkey.termkey_new_abstract(nil, 0) local key = t.ffi.new('TermKeyKey') ---@type TermKeyKey - t.eq(termkey.termkey_get_buffer_remaining(tk), 256) -- buffer free initially 256 + t.eq(256, termkey.termkey_get_buffer_remaining(tk)) -- buffer free initially 256 - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_NONE) -- getkey yields RES_NONE when empty + t.eq(termkey.TERMKEY_RES_NONE, termkey.termkey_getkey(tk, key)) -- getkey yields RES_NONE when empty - t.eq(termkey.termkey_push_bytes(tk, 'h', 1), 1) -- push_bytes returns 1 + t.eq(1, termkey.termkey_push_bytes(tk, 'h', 1)) -- push_bytes returns 1 - t.eq(termkey.termkey_get_buffer_remaining(tk), 255) -- buffer free 255 after push_bytes + t.eq(255, termkey.termkey_get_buffer_remaining(tk)) -- buffer free 255 after push_bytes - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY after h + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY after h - t.eq(key.type, termkey.TERMKEY_TYPE_UNICODE) -- key.type after h - t.eq(key.code.codepoint, string.byte('h')) -- key.code.codepoint after h - t.eq(key.modifiers, 0) -- key.modifiers after h - t.eq(t.ffi.string(key.utf8), 'h') -- key.utf8 after h + t.eq(termkey.TERMKEY_TYPE_UNICODE, key.type) -- key.type after h + t.eq(string.byte('h'), key.code.codepoint) -- key.code.codepoint after h + t.eq(0, key.modifiers) -- key.modifiers after h + t.eq('h', t.ffi.string(key.utf8)) -- key.utf8 after h - t.eq(termkey.termkey_get_buffer_remaining(tk), 256) -- buffer free 256 after getkey + t.eq(256, termkey.termkey_get_buffer_remaining(tk)) -- buffer free 256 after getkey - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_NONE) -- getkey yields RES_NONE a second time + t.eq(termkey.TERMKEY_RES_NONE, termkey.termkey_getkey(tk, key)) -- getkey yields RES_NONE a second time termkey.termkey_push_bytes(tk, '\x01', 1) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY after C-a + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY after C-a - t.eq(key.type, termkey.TERMKEY_TYPE_UNICODE) -- key.type after C-a - t.eq(key.code.codepoint, string.byte('a')) -- key.code.codepoint after C-a - t.eq(key.modifiers, termkey.TERMKEY_KEYMOD_CTRL) -- key.modifiers after C-a + t.eq(termkey.TERMKEY_TYPE_UNICODE, key.type) -- key.type after C-a + t.eq(string.byte('a'), key.code.codepoint) -- key.code.codepoint after C-a + t.eq(termkey.TERMKEY_KEYMOD_CTRL, key.modifiers) -- key.modifiers after C-a termkey.termkey_push_bytes(tk, '\033OA', 3) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY after Up + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY after Up -- is_int(key.type, TERMKEY_TYPE_KEYSYM, "key.type after Up"); -- is_int(key.code.sym, TERMKEY_SYM_UP, "key.code.sym after Up"); - t.eq(key.modifiers, 0) -- key.modifiers after Up + t.eq(0, key.modifiers) -- key.modifiers after Up - t.eq(termkey.termkey_push_bytes(tk, '\033O', 2), 2) -- push_bytes returns 2 + t.eq(2, termkey.termkey_push_bytes(tk, '\033O', 2)) -- push_bytes returns 2 -- is_int(termkey_get_buffer_remaining(tk), 254, "buffer free 254 after partial write"); @@ -132,7 +132,7 @@ describe('termkey', function() termkey.termkey_push_bytes(tk, 'C', 1) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY after Right completion + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY after Right completion -- is_int(key.type, TERMKEY_TYPE_KEYSYM, "key.type after Right"); -- is_int(key.code.sym, TERMKEY_SYM_RIGHT, "key.code.sym after Right"); @@ -142,7 +142,7 @@ describe('termkey', function() termkey.termkey_push_bytes(tk, '\033[27;5u', 7) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY after Ctrl-Escape + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY after Ctrl-Escape -- is_int(key.type, TERMKEY_TYPE_KEYSYM, "key.type after Ctrl-Escape"); -- is_int(key.code.sym, TERMKEY_SYM_ESCAPE, "key.code.sym after Ctrl-Escape"); @@ -150,10 +150,10 @@ describe('termkey', function() termkey.termkey_push_bytes(tk, '\0', 1) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY after Ctrl-Space + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY after Ctrl-Space - t.eq(key.type, termkey.TERMKEY_TYPE_UNICODE) -- key.type after Ctrl-Space - -- t.eq(key.code.codepoint, string.byte(' ')) -- key.code.codepoint after Ctrl-Space + t.eq(termkey.TERMKEY_TYPE_UNICODE, key.type) -- key.type after Ctrl-Space + -- t.eq(string.byte(' '), key.code.codepoint) -- key.code.codepoint after Ctrl-Space -- is_int(key.modifiers, TERMKEY_KEYMOD_CTRL, "key.modifiers after Ctrl-Space"); termkey.termkey_destroy(tk) @@ -165,128 +165,128 @@ describe('termkey', function() termkey.termkey_push_bytes(tk, 'a', 1) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY low ASCII - t.eq(key.type, termkey.TERMKEY_TYPE_UNICODE) -- key.type low ASCII - t.eq(key.code.codepoint, string.byte('a')) -- key.code.codepoint low ASCII + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY low ASCII + t.eq(termkey.TERMKEY_TYPE_UNICODE, key.type) -- key.type low ASCII + t.eq(string.byte('a'), key.code.codepoint) -- key.code.codepoint low ASCII -- 2-byte UTF-8 range is U+0080 to U+07FF (0xDF 0xBF) -- However, we'd best avoid the C1 range, so we'll start at U+00A0 (0xC2 0xA0) termkey.termkey_push_bytes(tk, '\xC2\xA0', 2) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY UTF-8 2 low - t.eq(key.type, termkey.TERMKEY_TYPE_UNICODE) -- key.type UTF-8 2 low - t.eq(key.code.codepoint, 0x00A0) -- key.code.codepoint UTF-8 2 low + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY UTF-8 2 low + t.eq(termkey.TERMKEY_TYPE_UNICODE, key.type) -- key.type UTF-8 2 low + t.eq(0x00A0, key.code.codepoint) -- key.code.codepoint UTF-8 2 low termkey.termkey_push_bytes(tk, '\xDF\xBF', 2) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY UTF-8 2 high - t.eq(key.type, termkey.TERMKEY_TYPE_UNICODE) -- key.type UTF-8 2 high - t.eq(key.code.codepoint, 0x07FF) -- key.code.codepoint UTF-8 2 high + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY UTF-8 2 high + t.eq(termkey.TERMKEY_TYPE_UNICODE, key.type) -- key.type UTF-8 2 high + t.eq(0x07FF, key.code.codepoint) -- key.code.codepoint UTF-8 2 high -- 3-byte UTF-8 range is U+0800 (0xE0 0xA0 0x80) to U+FFFD (0xEF 0xBF 0xBD) termkey.termkey_push_bytes(tk, '\xE0\xA0\x80', 3) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY UTF-8 3 low - t.eq(key.type, termkey.TERMKEY_TYPE_UNICODE) -- key.type UTF-8 3 low - t.eq(key.code.codepoint, 0x0800) -- key.code.codepoint UTF-8 3 low + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY UTF-8 3 low + t.eq(termkey.TERMKEY_TYPE_UNICODE, key.type) -- key.type UTF-8 3 low + t.eq(0x0800, key.code.codepoint) -- key.code.codepoint UTF-8 3 low termkey.termkey_push_bytes(tk, '\xEF\xBF\xBD', 3) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY UTF-8 3 high - t.eq(key.type, termkey.TERMKEY_TYPE_UNICODE) -- key.type UTF-8 3 high - t.eq(key.code.codepoint, 0xFFFD) -- key.code.codepoint UTF-8 3 high + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY UTF-8 3 high + t.eq(termkey.TERMKEY_TYPE_UNICODE, key.type) -- key.type UTF-8 3 high + t.eq(0xFFFD, key.code.codepoint) -- key.code.codepoint UTF-8 3 high -- 4-byte UTF-8 range is U+10000 (0xF0 0x90 0x80 0x80) to U+10FFFF (0xF4 0x8F 0xBF 0xBF) termkey.termkey_push_bytes(tk, '\xF0\x90\x80\x80', 4) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY UTF-8 4 low - t.eq(key.type, termkey.TERMKEY_TYPE_UNICODE) -- key.type UTF-8 4 low - t.eq(key.code.codepoint, 0x10000) -- key.code.codepoint UTF-8 4 low + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY UTF-8 4 low + t.eq(termkey.TERMKEY_TYPE_UNICODE, key.type) -- key.type UTF-8 4 low + t.eq(0x10000, key.code.codepoint) -- key.code.codepoint UTF-8 4 low termkey.termkey_push_bytes(tk, '\xF4\x8F\xBF\xBF', 4) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY UTF-8 4 high - t.eq(key.type, termkey.TERMKEY_TYPE_UNICODE) -- key.type UTF-8 4 high - t.eq(key.code.codepoint, 0x10FFFF) -- key.code.codepoint UTF-8 4 high + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY UTF-8 4 high + t.eq(termkey.TERMKEY_TYPE_UNICODE, key.type) -- key.type UTF-8 4 high + t.eq(0x10FFFF, key.code.codepoint) -- key.code.codepoint UTF-8 4 high -- Invalid continuations termkey.termkey_push_bytes(tk, '\xC2!', 2) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY UTF-8 2 invalid cont - t.eq(key.code.codepoint, 0xFFFD) -- key.code.codepoint UTF-8 2 invalid cont - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY UTF-8 2 invalid after - t.eq(key.code.codepoint, string.byte('!')) -- key.code.codepoint UTF-8 2 invalid after + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY UTF-8 2 invalid cont + t.eq(0xFFFD, key.code.codepoint) -- key.code.codepoint UTF-8 2 invalid cont + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY UTF-8 2 invalid after + t.eq(string.byte('!'), key.code.codepoint) -- key.code.codepoint UTF-8 2 invalid after termkey.termkey_push_bytes(tk, '\xE0!', 2) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY UTF-8 3 invalid cont - t.eq(key.code.codepoint, 0xFFFD) -- key.code.codepoint UTF-8 3 invalid cont - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY UTF-8 3 invalid after - t.eq(key.code.codepoint, string.byte('!')) -- key.code.codepoint UTF-8 3 invalid after + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY UTF-8 3 invalid cont + t.eq(0xFFFD, key.code.codepoint) -- key.code.codepoint UTF-8 3 invalid cont + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY UTF-8 3 invalid after + t.eq(string.byte('!'), key.code.codepoint) -- key.code.codepoint UTF-8 3 invalid after termkey.termkey_push_bytes(tk, '\xE0\xA0!', 3) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY UTF-8 3 invalid cont 2 - t.eq(key.code.codepoint, 0xFFFD) -- key.code.codepoint UTF-8 3 invalid cont 2 - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY UTF-8 3 invalid after - t.eq(key.code.codepoint, string.byte('!')) -- key.code.codepoint UTF-8 3 invalid after + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY UTF-8 3 invalid cont 2 + t.eq(0xFFFD, key.code.codepoint) -- key.code.codepoint UTF-8 3 invalid cont 2 + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY UTF-8 3 invalid after + t.eq(string.byte('!'), key.code.codepoint) -- key.code.codepoint UTF-8 3 invalid after termkey.termkey_push_bytes(tk, '\xF0!', 2) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY UTF-8 4 invalid cont - t.eq(key.code.codepoint, 0xFFFD) -- key.code.codepoint UTF-8 4 invalid cont - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY UTF-8 4 invalid after - t.eq(key.code.codepoint, string.byte('!')) -- key.code.codepoint UTF-8 4 invalid after + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY UTF-8 4 invalid cont + t.eq(0xFFFD, key.code.codepoint) -- key.code.codepoint UTF-8 4 invalid cont + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY UTF-8 4 invalid after + t.eq(string.byte('!'), key.code.codepoint) -- key.code.codepoint UTF-8 4 invalid after termkey.termkey_push_bytes(tk, '\xF0\x90!', 3) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY UTF-8 4 invalid cont 2 - t.eq(key.code.codepoint, 0xFFFD) -- key.code.codepoint UTF-8 4 invalid cont 2 - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY UTF-8 4 invalid after - t.eq(key.code.codepoint, string.byte('!')) -- key.code.codepoint UTF-8 4 invalid after + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY UTF-8 4 invalid cont 2 + t.eq(0xFFFD, key.code.codepoint) -- key.code.codepoint UTF-8 4 invalid cont 2 + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY UTF-8 4 invalid after + t.eq(string.byte('!'), key.code.codepoint) -- key.code.codepoint UTF-8 4 invalid after termkey.termkey_push_bytes(tk, '\xF0\x90\x80!', 4) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY UTF-8 4 invalid cont 3 - t.eq(key.code.codepoint, 0xFFFD) -- key.code.codepoint UTF-8 4 invalid cont 3 - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY UTF-8 4 invalid after - t.eq(key.code.codepoint, string.byte('!')) -- key.code.codepoint UTF-8 4 invalid after + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY UTF-8 4 invalid cont 3 + t.eq(0xFFFD, key.code.codepoint) -- key.code.codepoint UTF-8 4 invalid cont 3 + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY UTF-8 4 invalid after + t.eq(string.byte('!'), key.code.codepoint) -- key.code.codepoint UTF-8 4 invalid after -- Partials termkey.termkey_push_bytes(tk, '\xC2', 1) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_AGAIN) -- getkey yields RES_AGAIN UTF-8 2 partial + t.eq(termkey.TERMKEY_RES_AGAIN, termkey.termkey_getkey(tk, key)) -- getkey yields RES_AGAIN UTF-8 2 partial termkey.termkey_push_bytes(tk, '\xA0', 1) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY UTF-8 2 partial - t.eq(key.code.codepoint, 0x00A0) -- key.code.codepoint UTF-8 2 partial + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY UTF-8 2 partial + t.eq(0x00A0, key.code.codepoint) -- key.code.codepoint UTF-8 2 partial termkey.termkey_push_bytes(tk, '\xE0', 1) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_AGAIN) -- getkey yields RES_AGAIN UTF-8 3 partial + t.eq(termkey.TERMKEY_RES_AGAIN, termkey.termkey_getkey(tk, key)) -- getkey yields RES_AGAIN UTF-8 3 partial termkey.termkey_push_bytes(tk, '\xA0', 1) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_AGAIN) -- getkey yields RES_AGAIN UTF-8 3 partial + t.eq(termkey.TERMKEY_RES_AGAIN, termkey.termkey_getkey(tk, key)) -- getkey yields RES_AGAIN UTF-8 3 partial termkey.termkey_push_bytes(tk, '\x80', 1) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY UTF-8 3 partial - t.eq(key.code.codepoint, 0x0800) -- key.code.codepoint UTF-8 3 partial + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY UTF-8 3 partial + t.eq(0x0800, key.code.codepoint) -- key.code.codepoint UTF-8 3 partial termkey.termkey_push_bytes(tk, '\xF0', 1) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_AGAIN) -- getkey yields RES_AGAIN UTF-8 4 partial + t.eq(termkey.TERMKEY_RES_AGAIN, termkey.termkey_getkey(tk, key)) -- getkey yields RES_AGAIN UTF-8 4 partial termkey.termkey_push_bytes(tk, '\x90', 1) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_AGAIN) -- getkey yields RES_AGAIN UTF-8 4 partial + t.eq(termkey.TERMKEY_RES_AGAIN, termkey.termkey_getkey(tk, key)) -- getkey yields RES_AGAIN UTF-8 4 partial termkey.termkey_push_bytes(tk, '\x80', 1) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_AGAIN) -- getkey yields RES_AGAIN UTF-8 4 partial + t.eq(termkey.TERMKEY_RES_AGAIN, termkey.termkey_getkey(tk, key)) -- getkey yields RES_AGAIN UTF-8 4 partial termkey.termkey_push_bytes(tk, '\x80', 1) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY UTF-8 4 partial - t.eq(key.code.codepoint, 0x10000) -- key.code.codepoint UTF-8 4 partial + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY UTF-8 4 partial + t.eq(0x10000, key.code.codepoint) -- key.code.codepoint UTF-8 4 partial termkey.termkey_destroy(tk) end) @@ -297,21 +297,21 @@ describe('termkey', function() termkey.termkey_push_bytes(tk, ' ', 1) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY after space + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY after space - t.eq(key.type, termkey.TERMKEY_TYPE_UNICODE) -- key.type after space - t.eq(key.code.codepoint, string.byte(' ')) -- key.code.codepoint after space - t.eq(key.modifiers, 0) -- key.modifiers after space + t.eq(termkey.TERMKEY_TYPE_UNICODE, key.type) -- key.type after space + t.eq(string.byte(' '), key.code.codepoint) -- key.code.codepoint after space + t.eq(0, key.modifiers) -- key.modifiers after space termkey.termkey_set_flags(tk, termkey.TERMKEY_FLAG_SPACESYMBOL) termkey.termkey_push_bytes(tk, ' ', 1) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY after space + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY after space - t.eq(key.type, termkey.TERMKEY_TYPE_KEYSYM) -- key.type after space with FLAG_SPACESYMBOL - t.eq(key.code.sym, termkey.TERMKEY_SYM_SPACE) -- key.code.sym after space with FLAG_SPACESYMBOL - t.eq(key.modifiers, 0) -- key.modifiers after space with FLAG_SPACESYMBOL + t.eq(termkey.TERMKEY_TYPE_KEYSYM, key.type) -- key.type after space with FLAG_SPACESYMBOL + t.eq(termkey.TERMKEY_SYM_SPACE, key.code.sym) -- key.code.sym after space with FLAG_SPACESYMBOL + t.eq(0, key.modifiers) -- key.modifiers after space with FLAG_SPACESYMBOL termkey.termkey_destroy(tk) end) @@ -320,20 +320,20 @@ describe('termkey', function() local tk = termkey.termkey_new_abstract(nil, 0) local key = t.ffi.new('TermKeyKey') ---@type TermKeyKey - t.eq(termkey.termkey_get_buffer_remaining(tk), 256) -- buffer free initially 256 - t.eq(termkey.termkey_get_buffer_size(tk), 256) -- buffer size initially 256 + t.eq(256, termkey.termkey_get_buffer_remaining(tk)) -- buffer free initially 256 + t.eq(256, termkey.termkey_get_buffer_size(tk)) -- buffer size initially 256 - t.eq(termkey.termkey_push_bytes(tk, 'h', 1), 1) -- push_bytes returns 1 + t.eq(1, termkey.termkey_push_bytes(tk, 'h', 1)) -- push_bytes returns 1 - t.eq(termkey.termkey_get_buffer_remaining(tk), 255) -- buffer free 255 after push_bytes - t.eq(termkey.termkey_get_buffer_size(tk), 256) -- buffer size 256 after push_bytes + t.eq(255, termkey.termkey_get_buffer_remaining(tk)) -- buffer free 255 after push_bytes + t.eq(256, termkey.termkey_get_buffer_size(tk)) -- buffer size 256 after push_bytes - t.eq(not not termkey.termkey_set_buffer_size(tk, 512), true) -- buffer set size OK + t.eq(true, not not termkey.termkey_set_buffer_size(tk, 512)) -- buffer set size OK - t.eq(termkey.termkey_get_buffer_remaining(tk), 511) -- buffer free 511 after push_bytes - t.eq(termkey.termkey_get_buffer_size(tk), 512) -- buffer size 512 after push_bytes + t.eq(511, termkey.termkey_get_buffer_remaining(tk)) -- buffer free 511 after push_bytes + t.eq(512, termkey.termkey_get_buffer_size(tk)) -- buffer size 512 after push_bytes - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- buffered key still usable after resize + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- buffered key still usable after resize termkey.termkey_destroy(tk) end) @@ -351,25 +351,25 @@ describe('termkey', function() local tk = termkey.termkey_new_abstract(nil, 0) local sym = termkey_keyname2sym(tk, 'SomeUnknownKey') - t.eq(sym, termkey.TERMKEY_SYM_UNKNOWN) -- keyname2sym SomeUnknownKey + t.eq(termkey.TERMKEY_SYM_UNKNOWN, sym) -- keyname2sym SomeUnknownKey sym = termkey_keyname2sym(tk, 'Space') - t.eq(sym[0], termkey.TERMKEY_SYM_SPACE) -- keyname2sym Space + t.eq(termkey.TERMKEY_SYM_SPACE, sym[0]) -- keyname2sym Space local _end = termkey.termkey_lookup_keyname(tk, 'Up', sym) - t.neq(_end, nil) -- termkey_get_keyname Up returns non-NULL - t.eq(t.ffi.string(_end), '') -- termkey_get_keyname Up return points at endofstring - t.eq(sym[0], termkey.TERMKEY_SYM_UP) -- termkey_get_keyname Up yields Up symbol + t.neq(nil, _end) -- termkey_get_keyname Up returns non-NULL + t.eq('', t.ffi.string(_end)) -- termkey_get_keyname Up return points at endofstring + t.eq(termkey.TERMKEY_SYM_UP, sym[0]) -- termkey_get_keyname Up yields Up symbol _end = termkey.termkey_lookup_keyname(tk, 'DownMore', sym) - t.neq(_end, nil) -- termkey_get_keyname DownMore returns non-NULL - t.eq(t.ffi.string(_end), 'More') -- termkey_get_keyname DownMore return points at More - t.eq(sym[0], termkey.TERMKEY_SYM_DOWN) -- termkey_get_keyname DownMore yields Down symbol + t.neq(nil, _end) -- termkey_get_keyname DownMore returns non-NULL + t.eq('More', t.ffi.string(_end)) -- termkey_get_keyname DownMore return points at More + t.eq(termkey.TERMKEY_SYM_DOWN, sym[0]) -- termkey_get_keyname DownMore yields Down symbol _end = termkey.termkey_lookup_keyname(tk, 'SomeUnknownKey', sym) - t.eq(_end, nil) -- termkey_get_keyname SomeUnknownKey returns NULL + t.eq(nil, _end) -- termkey_get_keyname SomeUnknownKey returns NULL - t.eq(t.ffi.string(termkey.termkey_get_keyname(tk, termkey.TERMKEY_SYM_SPACE)), 'Space') -- "get_keyname SPACE"); + t.eq('Space', t.ffi.string(termkey.termkey_get_keyname(tk, termkey.TERMKEY_SYM_SPACE))) -- "get_keyname SPACE"); termkey.termkey_destroy(tk) end) @@ -384,8 +384,8 @@ describe('termkey', function() local buffer = t.ffi.new('char[16]') local len = termkey.termkey_strfkey(tk, buffer, t.ffi.sizeof(buffer), key, 0) - t.eq(len, 1) -- length for unicode/A/0 - t.eq(t.ffi.string(buffer), 'A') -- buffer for unicode/A/0 + t.eq(1, len) -- length for unicode/A/0 + t.eq('A', t.ffi.string(buffer)) -- buffer for unicode/A/0 len = termkey.termkey_strfkey( tk, @@ -394,8 +394,8 @@ describe('termkey', function() key, termkey.TERMKEY_FORMAT_WRAPBRACKET ) - t.eq(len, 1) -- length for unicode/A/0 wrapbracket - t.eq(t.ffi.string(buffer), 'A') -- buffer for unicode/A/0 wrapbracket + t.eq(1, len) -- length for unicode/A/0 wrapbracket + t.eq('A', t.ffi.string(buffer)) -- buffer for unicode/A/0 wrapbracket ---@type TermKeyKey key = t.ffi.new('TermKeyKey', { @@ -405,13 +405,13 @@ describe('termkey', function() }) len = termkey.termkey_strfkey(tk, buffer, t.ffi.sizeof(buffer), key, 0) - t.eq(len, 3) -- length for unicode/b/CTRL - t.eq(t.ffi.string(buffer), 'C-b') -- buffer for unicode/b/CTRL + t.eq(3, len) -- length for unicode/b/CTRL + t.eq('C-b', t.ffi.string(buffer)) -- buffer for unicode/b/CTRL len = termkey.termkey_strfkey(tk, buffer, t.ffi.sizeof(buffer), key, termkey.TERMKEY_FORMAT_LONGMOD) - t.eq(len, 6) -- length for unicode/b/CTRL longmod - t.eq(t.ffi.string(buffer), 'Ctrl-b') -- buffer for unicode/b/CTRL longmod + t.eq(6, len) -- length for unicode/b/CTRL longmod + t.eq('Ctrl-b', t.ffi.string(buffer)) -- buffer for unicode/b/CTRL longmod len = termkey.termkey_strfkey( tk, @@ -420,8 +420,8 @@ describe('termkey', function() key, bit.bor(termkey.TERMKEY_FORMAT_LONGMOD, termkey.TERMKEY_FORMAT_SPACEMOD) ) - t.eq(len, 6) -- length for unicode/b/CTRL longmod|spacemod - t.eq(t.ffi.string(buffer), 'Ctrl b') -- buffer for unicode/b/CTRL longmod|spacemod + t.eq(6, len) -- length for unicode/b/CTRL longmod|spacemod + t.eq('Ctrl b', t.ffi.string(buffer)) -- buffer for unicode/b/CTRL longmod|spacemod len = termkey.termkey_strfkey( tk, @@ -430,8 +430,8 @@ describe('termkey', function() key, bit.bor(termkey.TERMKEY_FORMAT_LONGMOD, termkey.TERMKEY_FORMAT_LOWERMOD) ) - t.eq(len, 6) -- length for unicode/b/CTRL longmod|lowermod - t.eq(t.ffi.string(buffer), 'ctrl-b') -- buffer for unicode/b/CTRL longmod|lowermod + t.eq(6, len) -- length for unicode/b/CTRL longmod|lowermod + t.eq('ctrl-b', t.ffi.string(buffer)) -- buffer for unicode/b/CTRL longmod|lowermod len = termkey.termkey_strfkey( tk, @@ -444,8 +444,8 @@ describe('termkey', function() termkey.TERMKEY_FORMAT_LOWERMOD ) ) - t.eq(len, 6) -- length for unicode/b/CTRL longmod|spacemod|lowermode - t.eq(t.ffi.string(buffer), 'ctrl b') -- buffer for unicode/b/CTRL longmod|spacemod|lowermode + t.eq(6, len) -- length for unicode/b/CTRL longmod|spacemod|lowermode + t.eq('ctrl b', t.ffi.string(buffer)) -- buffer for unicode/b/CTRL longmod|spacemod|lowermode len = termkey.termkey_strfkey( tk, @@ -454,8 +454,8 @@ describe('termkey', function() key, termkey.TERMKEY_FORMAT_CARETCTRL ) - t.eq(len, 2) -- length for unicode/b/CTRL caretctrl - t.eq(t.ffi.string(buffer), '^B') -- buffer for unicode/b/CTRL caretctrl + t.eq(2, len) -- length for unicode/b/CTRL caretctrl + t.eq('^B', t.ffi.string(buffer)) -- buffer for unicode/b/CTRL caretctrl len = termkey.termkey_strfkey( tk, @@ -464,8 +464,8 @@ describe('termkey', function() key, termkey.TERMKEY_FORMAT_WRAPBRACKET ) - t.eq(len, 5) -- length for unicode/b/CTRL wrapbracket - t.eq(t.ffi.string(buffer), '') -- buffer for unicode/b/CTRL wrapbracket + t.eq(5, len) -- length for unicode/b/CTRL wrapbracket + t.eq('', t.ffi.string(buffer)) -- buffer for unicode/b/CTRL wrapbracket ---@type TermKeyKey key = t.ffi.new('TermKeyKey', { @@ -475,13 +475,13 @@ describe('termkey', function() }) len = termkey.termkey_strfkey(tk, buffer, t.ffi.sizeof(buffer), key, 0) - t.eq(len, 3) -- length for unicode/c/ALT - t.eq(t.ffi.string(buffer), 'A-c') -- buffer for unicode/c/ALT + t.eq(3, len) -- length for unicode/c/ALT + t.eq('A-c', t.ffi.string(buffer)) -- buffer for unicode/c/ALT len = termkey.termkey_strfkey(tk, buffer, t.ffi.sizeof(buffer), key, termkey.TERMKEY_FORMAT_LONGMOD) - t.eq(len, 5) -- length for unicode/c/ALT longmod - t.eq(t.ffi.string(buffer), 'Alt-c') -- buffer for unicode/c/ALT longmod + t.eq(5, len) -- length for unicode/c/ALT longmod + t.eq('Alt-c', t.ffi.string(buffer)) -- buffer for unicode/c/ALT longmod len = termkey.termkey_strfkey( tk, @@ -490,8 +490,8 @@ describe('termkey', function() key, termkey.TERMKEY_FORMAT_ALTISMETA ) - t.eq(len, 3) -- length for unicode/c/ALT altismeta - t.eq(t.ffi.string(buffer), 'M-c') -- buffer for unicode/c/ALT altismeta + t.eq(3, len) -- length for unicode/c/ALT altismeta + t.eq('M-c', t.ffi.string(buffer)) -- buffer for unicode/c/ALT altismeta len = termkey.termkey_strfkey( tk, @@ -500,8 +500,8 @@ describe('termkey', function() key, bit.bor(termkey.TERMKEY_FORMAT_LONGMOD, termkey.TERMKEY_FORMAT_ALTISMETA) ) - t.eq(len, 6) -- length for unicode/c/ALT longmod|altismeta - t.eq(t.ffi.string(buffer), 'Meta-c') -- buffer for unicode/c/ALT longmod|altismeta + t.eq(6, len) -- length for unicode/c/ALT longmod|altismeta + t.eq('Meta-c', t.ffi.string(buffer)) -- buffer for unicode/c/ALT longmod|altismeta ---@type TermKeyKey key = t.ffi.new( @@ -510,8 +510,8 @@ describe('termkey', function() ) len = termkey.termkey_strfkey(tk, buffer, t.ffi.sizeof(buffer), key, 0) - t.eq(len, 2) -- length for sym/Up/0 - t.eq(t.ffi.string(buffer), 'Up') -- buffer for sym/Up/0 + t.eq(2, len) -- length for sym/Up/0 + t.eq('Up', t.ffi.string(buffer)) -- buffer for sym/Up/0 len = termkey.termkey_strfkey( tk, @@ -520,8 +520,8 @@ describe('termkey', function() key, termkey.TERMKEY_FORMAT_WRAPBRACKET ) - t.eq(len, 4) -- length for sym/Up/0 wrapbracket - t.eq(t.ffi.string(buffer), '') -- buffer for sym/Up/0 wrapbracket + t.eq(4, len) -- length for sym/Up/0 wrapbracket + t.eq('', t.ffi.string(buffer)) -- buffer for sym/Up/0 wrapbracket ---@type TermKeyKey key = t.ffi.new( @@ -530,8 +530,8 @@ describe('termkey', function() ) len = termkey.termkey_strfkey(tk, buffer, t.ffi.sizeof(buffer), key, 0) - t.eq(len, 6) -- length for sym/PageUp/0 - t.eq(t.ffi.string(buffer), 'PageUp') -- buffer for sym/PageUp/0 + t.eq(6, len) -- length for sym/PageUp/0 + t.eq('PageUp', t.ffi.string(buffer)) -- buffer for sym/PageUp/0 len = termkey.termkey_strfkey( tk, @@ -540,23 +540,23 @@ describe('termkey', function() key, termkey.TERMKEY_FORMAT_LOWERSPACE ) - t.eq(len, 7) -- length for sym/PageUp/0 lowerspace - t.eq(t.ffi.string(buffer), 'page up') -- buffer for sym/PageUp/0 lowerspace + t.eq(7, len) -- length for sym/PageUp/0 lowerspace + t.eq('page up', t.ffi.string(buffer)) -- buffer for sym/PageUp/0 lowerspace -- If size of buffer is too small, strfkey should return something consistent len = termkey.termkey_strfkey(tk, buffer, 4, key, 0) - t.eq(len, 6) -- length for sym/PageUp/0 - t.eq(t.ffi.string(buffer), 'Pag') -- buffer of len 4 for sym/PageUp/0 + t.eq(6, len) -- length for sym/PageUp/0 + t.eq('Pag', t.ffi.string(buffer)) -- buffer of len 4 for sym/PageUp/0 len = termkey.termkey_strfkey(tk, buffer, 4, key, termkey.TERMKEY_FORMAT_LOWERSPACE) - t.eq(len, 7) -- length for sym/PageUp/0 lowerspace - t.eq(t.ffi.string(buffer), 'pag') -- buffer of len 4 for sym/PageUp/0 lowerspace + t.eq(7, len) -- length for sym/PageUp/0 lowerspace + t.eq('pag', t.ffi.string(buffer)) -- buffer of len 4 for sym/PageUp/0 lowerspace key = t.ffi.new('TermKeyKey', { type = termkey.TERMKEY_TYPE_FUNCTION, code = { number = 5 } }) ---@type TermKeyKey len = termkey.termkey_strfkey(tk, buffer, t.ffi.sizeof(buffer), key, 0) - t.eq(len, 2) -- length for func/5/0 - t.eq(t.ffi.string(buffer), 'F5') -- buffer for func/5/0 + t.eq(2, len) -- length for func/5/0 + t.eq('F5', t.ffi.string(buffer)) -- buffer for func/5/0 len = termkey.termkey_strfkey( tk, @@ -565,8 +565,8 @@ describe('termkey', function() key, termkey.TERMKEY_FORMAT_WRAPBRACKET ) - t.eq(len, 4) -- length for func/5/0 wrapbracket - t.eq(t.ffi.string(buffer), '') -- buffer for func/5/0 wrapbracket + t.eq(4, len) -- length for func/5/0 wrapbracket + t.eq('', t.ffi.string(buffer)) -- buffer for func/5/0 wrapbracket len = termkey.termkey_strfkey( tk, @@ -575,8 +575,8 @@ describe('termkey', function() key, termkey.TERMKEY_FORMAT_LOWERSPACE ) - t.eq(len, 2) -- length for func/5/0 lowerspace - t.eq(t.ffi.string(buffer), 'f5') -- buffer for func/5/0 lowerspace + t.eq(2, len) -- length for func/5/0 lowerspace + t.eq('f5', t.ffi.string(buffer)) -- buffer for func/5/0 lowerspace termkey.termkey_destroy(tk) end) @@ -613,30 +613,30 @@ describe('termkey', function() modifiers = 0, }) - t.eq(termkey_keycmp(tk, key1, key1), 0) -- cmpkey same structure - t.eq(termkey_keycmp(tk, key1, key2), 0) -- cmpkey identical structure + t.eq(0, termkey_keycmp(tk, key1, key1)) -- cmpkey same structure + t.eq(0, termkey_keycmp(tk, key1, key2)) -- cmpkey identical structure key2.modifiers = termkey.TERMKEY_KEYMOD_CTRL - t.eq(termkey_keycmp(tk, key1, key2) < 0, true) -- cmpkey orders CTRL after nomod - t.eq(termkey_keycmp(tk, key2, key1) > 0, true) -- cmpkey orders nomod before CTRL + t.eq(true, termkey_keycmp(tk, key1, key2) < 0) -- cmpkey orders CTRL after nomod + t.eq(true, termkey_keycmp(tk, key2, key1) > 0) -- cmpkey orders nomod before CTRL key2.code.codepoint = string.byte('B') key2.modifiers = 0 - t.eq(termkey_keycmp(tk, key1, key2) < 0, true) -- cmpkey orders 'B' after 'A' - t.eq(termkey_keycmp(tk, key2, key1) > 0, true) -- cmpkey orders 'A' before 'B' + t.eq(true, termkey_keycmp(tk, key1, key2) < 0) -- cmpkey orders 'B' after 'A' + t.eq(true, termkey_keycmp(tk, key2, key1) > 0) -- cmpkey orders 'A' before 'B' key1.modifiers = termkey.TERMKEY_KEYMOD_CTRL - t.eq(termkey_keycmp(tk, key1, key2) < 0, true) -- cmpkey orders nomod 'B' after CTRL 'A' - t.eq(termkey_keycmp(tk, key2, key1) > 0, true) -- cmpkey orders CTRL 'A' before nomod 'B' + t.eq(true, termkey_keycmp(tk, key1, key2) < 0) -- cmpkey orders nomod 'B' after CTRL 'A' + t.eq(true, termkey_keycmp(tk, key2, key1) > 0) -- cmpkey orders CTRL 'A' before nomod 'B' key2.type = termkey.TERMKEY_TYPE_KEYSYM key2.code.sym = termkey.TERMKEY_SYM_UP - t.eq(termkey_keycmp(tk, key1, key2) < 0, true) -- cmpkey orders KEYSYM after UNICODE - t.eq(termkey_keycmp(tk, key2, key1) > 0, true) -- cmpkey orders UNICODE before KEYSYM + t.eq(true, termkey_keycmp(tk, key1, key2) < 0) -- cmpkey orders KEYSYM after UNICODE + t.eq(true, termkey_keycmp(tk, key2, key1) > 0) -- cmpkey orders UNICODE before KEYSYM key1.type = termkey.TERMKEY_TYPE_KEYSYM key1.code.sym = termkey.TERMKEY_SYM_SPACE @@ -645,13 +645,13 @@ describe('termkey', function() key2.code.codepoint = string.byte(' ') key2.modifiers = 0 - t.eq(termkey_keycmp(tk, key1, key2), 0) -- cmpkey considers KEYSYM/SPACE and UNICODE/SP identical + t.eq(0, termkey_keycmp(tk, key1, key2)) -- cmpkey considers KEYSYM/SPACE and UNICODE/SP identical termkey.termkey_set_canonflags( tk, bit.bor(termkey.termkey_get_canonflags(tk), termkey.TERMKEY_CANON_SPACESYMBOL) ) - t.eq(termkey_keycmp(tk, key1, key2), 0) -- "cmpkey considers KEYSYM/SPACE and UNICODE/SP identical under SPACESYMBOL"); + t.eq(0, termkey_keycmp(tk, key1, key2)) -- "cmpkey considers KEYSYM/SPACE and UNICODE/SP identical under SPACESYMBOL"); termkey.termkey_destroy(tk) end) @@ -667,21 +667,21 @@ describe('termkey', function() termkey.termkey_push_bytes(tk, '\x1b[M !!', 6) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY for mouse press + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY for mouse press - t.eq(key.type, termkey.TERMKEY_TYPE_MOUSE) -- key.type for mouse press + t.eq(termkey.TERMKEY_TYPE_MOUSE, key.type) -- key.type for mouse press - t.eq(termkey.termkey_interpret_mouse(tk, key, ev, button, line, col), termkey.TERMKEY_RES_KEY) -- interpret_mouse yields RES_KEY + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_interpret_mouse(tk, key, ev, button, line, col)) -- interpret_mouse yields RES_KEY - t.eq(ev[0], termkey.TERMKEY_MOUSE_PRESS) -- mouse event for press - t.eq(button[0], 1) -- mouse button for press - t.eq(line[0], 1) -- mouse line for press - t.eq(col[0], 1) -- mouse column for press - t.eq(key.modifiers, 0) -- modifiers for press + t.eq(termkey.TERMKEY_MOUSE_PRESS, ev[0]) -- mouse event for press + t.eq(1, button[0]) -- mouse button for press + t.eq(1, line[0]) -- mouse line for press + t.eq(1, col[0]) -- mouse column for press + t.eq(0, key.modifiers) -- modifiers for press local len = termkey.termkey_strfkey(tk, buffer, t.ffi.sizeof(buffer), key, 0) - t.eq(len, 13) -- string length for press - t.eq(t.ffi.string(buffer), 'MousePress(1)') -- string buffer for press + t.eq(13, len) -- string length for press + t.eq('MousePress(1)', t.ffi.string(buffer)) -- string buffer for press len = termkey.termkey_strfkey( tk, @@ -690,121 +690,121 @@ describe('termkey', function() key, termkey.TERMKEY_FORMAT_MOUSE_POS ) - t.eq(len, 21) -- string length for press - t.eq(t.ffi.string(buffer), 'MousePress(1) @ (1,1)') -- string buffer for press + t.eq(21, len) -- string length for press + t.eq('MousePress(1) @ (1,1)', t.ffi.string(buffer)) -- string buffer for press termkey.termkey_push_bytes(tk, '\x1b[M@"!', 6) termkey.termkey_getkey(tk, key) - t.eq(termkey.termkey_interpret_mouse(tk, key, ev, button, line, col), termkey.TERMKEY_RES_KEY) -- interpret_mouse yields RES_KEY + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_interpret_mouse(tk, key, ev, button, line, col)) -- interpret_mouse yields RES_KEY - t.eq(ev[0], termkey.TERMKEY_MOUSE_DRAG) -- mouse event for drag - t.eq(button[0], 1) -- mouse button for drag - t.eq(line[0], 1) -- mouse line for drag - t.eq(col[0], 2) -- mouse column for drag - t.eq(key.modifiers, 0) -- modifiers for press + t.eq(termkey.TERMKEY_MOUSE_DRAG, ev[0]) -- mouse event for drag + t.eq(1, button[0]) -- mouse button for drag + t.eq(1, line[0]) -- mouse line for drag + t.eq(2, col[0]) -- mouse column for drag + t.eq(0, key.modifiers) -- modifiers for press termkey.termkey_push_bytes(tk, '\x1b[M##!', 6) termkey.termkey_getkey(tk, key) - t.eq(termkey.termkey_interpret_mouse(tk, key, ev, button, line, col), termkey.TERMKEY_RES_KEY) -- interpret_mouse yields RES_KEY + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_interpret_mouse(tk, key, ev, button, line, col)) -- interpret_mouse yields RES_KEY - t.eq(ev[0], termkey.TERMKEY_MOUSE_RELEASE) -- mouse event for release - t.eq(line[0], 1) -- mouse line for release - t.eq(col[0], 3) -- mouse column for release - t.eq(key.modifiers, 0) -- modifiers for press + t.eq(termkey.TERMKEY_MOUSE_RELEASE, ev[0]) -- mouse event for release + t.eq(1, line[0]) -- mouse line for release + t.eq(3, col[0]) -- mouse column for release + t.eq(0, key.modifiers) -- modifiers for press termkey.termkey_push_bytes(tk, '\x1b[M0++', 6) termkey.termkey_getkey(tk, key) - t.eq(termkey.termkey_interpret_mouse(tk, key, ev, button, line, col), termkey.TERMKEY_RES_KEY) -- interpret_mouse yields RES_KEY + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_interpret_mouse(tk, key, ev, button, line, col)) -- interpret_mouse yields RES_KEY - t.eq(ev[0], termkey.TERMKEY_MOUSE_PRESS) -- mouse event for Ctrl-press - t.eq(button[0], 1) -- mouse button for Ctrl-press - t.eq(line[0], 11) -- mouse line for Ctrl-press - t.eq(col[0], 11) -- mouse column for Ctrl-press - t.eq(key.modifiers, termkey.TERMKEY_KEYMOD_CTRL) -- modifiers for Ctrl-press + t.eq(termkey.TERMKEY_MOUSE_PRESS, ev[0]) -- mouse event for Ctrl-press + t.eq(1, button[0]) -- mouse button for Ctrl-press + t.eq(11, line[0]) -- mouse line for Ctrl-press + t.eq(11, col[0]) -- mouse column for Ctrl-press + t.eq(termkey.TERMKEY_KEYMOD_CTRL, key.modifiers) -- modifiers for Ctrl-press len = termkey.termkey_strfkey(tk, buffer, t.ffi.sizeof(buffer), key, 0) - t.eq(len, 15) -- string length for Ctrl-press - t.eq(t.ffi.string(buffer), 'C-MousePress(1)') -- string buffer for Ctrl-press + t.eq(15, len) -- string length for Ctrl-press + t.eq('C-MousePress(1)', t.ffi.string(buffer)) -- string buffer for Ctrl-press termkey.termkey_push_bytes(tk, '\x1b[M`!!', 6) termkey.termkey_getkey(tk, key) - t.eq(termkey.termkey_interpret_mouse(tk, key, ev, button, line, col), termkey.TERMKEY_RES_KEY) -- interpret_mouse yields RES_KEY + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_interpret_mouse(tk, key, ev, button, line, col)) -- interpret_mouse yields RES_KEY - t.eq(ev[0], termkey.TERMKEY_MOUSE_PRESS) -- mouse event for wheel down - t.eq(button[0], 4) -- mouse button for wheel down + t.eq(termkey.TERMKEY_MOUSE_PRESS, ev[0]) -- mouse event for wheel down + t.eq(4, button[0]) -- mouse button for wheel down termkey.termkey_push_bytes(tk, '\x1b[Mb!!', 6) termkey.termkey_getkey(tk, key) - t.eq(termkey.termkey_interpret_mouse(tk, key, ev, button, line, col), termkey.TERMKEY_RES_KEY) -- interpret_mouse yields RES_KEY + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_interpret_mouse(tk, key, ev, button, line, col)) -- interpret_mouse yields RES_KEY - t.eq(ev[0], termkey.TERMKEY_MOUSE_PRESS) -- mouse event for wheel left - t.eq(button[0], 6) -- mouse button for wheel left + t.eq(termkey.TERMKEY_MOUSE_PRESS, ev[0]) -- mouse event for wheel left + t.eq(6, button[0]) -- mouse button for wheel left -- rxvt protocol termkey.termkey_push_bytes(tk, '\x1b[0;20;20M', 10) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY for mouse press rxvt protocol + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY for mouse press rxvt protocol - t.eq(key.type, termkey.TERMKEY_TYPE_MOUSE) -- key.type for mouse press rxvt protocol + t.eq(termkey.TERMKEY_TYPE_MOUSE, key.type) -- key.type for mouse press rxvt protocol - t.eq(termkey.termkey_interpret_mouse(tk, key, ev, button, line, col), termkey.TERMKEY_RES_KEY) -- interpret_mouse yields RES_KEY + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_interpret_mouse(tk, key, ev, button, line, col)) -- interpret_mouse yields RES_KEY - t.eq(ev[0], termkey.TERMKEY_MOUSE_PRESS) -- mouse event for press rxvt protocol - t.eq(button[0], 1) -- mouse button for press rxvt protocol - t.eq(line[0], 20) -- mouse line for press rxvt protocol - t.eq(col[0], 20) -- mouse column for press rxvt protocol - t.eq(key.modifiers, 0) -- modifiers for press rxvt protocol + t.eq(termkey.TERMKEY_MOUSE_PRESS, ev[0]) -- mouse event for press rxvt protocol + t.eq(1, button[0]) -- mouse button for press rxvt protocol + t.eq(20, line[0]) -- mouse line for press rxvt protocol + t.eq(20, col[0]) -- mouse column for press rxvt protocol + t.eq(0, key.modifiers) -- modifiers for press rxvt protocol termkey.termkey_push_bytes(tk, '\x1b[3;20;20M', 10) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY for mouse release rxvt protocol + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY for mouse release rxvt protocol - t.eq(key.type, termkey.TERMKEY_TYPE_MOUSE) -- key.type for mouse release rxvt protocol + t.eq(termkey.TERMKEY_TYPE_MOUSE, key.type) -- key.type for mouse release rxvt protocol - t.eq(termkey.termkey_interpret_mouse(tk, key, ev, button, line, col), termkey.TERMKEY_RES_KEY) -- interpret_mouse yields RES_KEY + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_interpret_mouse(tk, key, ev, button, line, col)) -- interpret_mouse yields RES_KEY - t.eq(ev[0], termkey.TERMKEY_MOUSE_RELEASE) -- mouse event for release rxvt protocol - t.eq(line[0], 20) -- mouse line for release rxvt protocol - t.eq(col[0], 20) -- mouse column for release rxvt protocol - t.eq(key.modifiers, 0) -- modifiers for release rxvt protocol + t.eq(termkey.TERMKEY_MOUSE_RELEASE, ev[0]) -- mouse event for release rxvt protocol + t.eq(20, line[0]) -- mouse line for release rxvt protocol + t.eq(20, col[0]) -- mouse column for release rxvt protocol + t.eq(0, key.modifiers) -- modifiers for release rxvt protocol -- SGR protocol termkey.termkey_push_bytes(tk, '\x1b[<0;30;30M', 11) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY for mouse press SGR encoding + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY for mouse press SGR encoding - t.eq(key.type, termkey.TERMKEY_TYPE_MOUSE) -- key.type for mouse press SGR encoding + t.eq(termkey.TERMKEY_TYPE_MOUSE, key.type) -- key.type for mouse press SGR encoding - t.eq(termkey.termkey_interpret_mouse(tk, key, ev, button, line, col), termkey.TERMKEY_RES_KEY) -- interpret_mouse yields RES_KEY + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_interpret_mouse(tk, key, ev, button, line, col)) -- interpret_mouse yields RES_KEY - t.eq(ev[0], termkey.TERMKEY_MOUSE_PRESS) -- mouse event for press SGR - t.eq(button[0], 1) -- mouse button for press SGR - t.eq(line[0], 30) -- mouse line for press SGR - t.eq(col[0], 30) -- mouse column for press SGR - t.eq(key.modifiers, 0) -- modifiers for press SGR + t.eq(termkey.TERMKEY_MOUSE_PRESS, ev[0]) -- mouse event for press SGR + t.eq(1, button[0]) -- mouse button for press SGR + t.eq(30, line[0]) -- mouse line for press SGR + t.eq(30, col[0]) -- mouse column for press SGR + t.eq(0, key.modifiers) -- modifiers for press SGR termkey.termkey_push_bytes(tk, '\x1b[<0;30;30m', 11) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY for mouse release SGR encoding + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY for mouse release SGR encoding - t.eq(key.type, termkey.TERMKEY_TYPE_MOUSE) -- key.type for mouse release SGR encoding + t.eq(termkey.TERMKEY_TYPE_MOUSE, key.type) -- key.type for mouse release SGR encoding - t.eq(termkey.termkey_interpret_mouse(tk, key, ev, button, line, col), termkey.TERMKEY_RES_KEY) -- interpret_mouse yields RES_KEY + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_interpret_mouse(tk, key, ev, button, line, col)) -- interpret_mouse yields RES_KEY - t.eq(ev[0], termkey.TERMKEY_MOUSE_RELEASE) -- mouse event for release SGR + t.eq(termkey.TERMKEY_MOUSE_RELEASE, ev[0]) -- mouse event for release SGR termkey.termkey_push_bytes(tk, '\x1b[<0;500;300M', 13) termkey.termkey_getkey(tk, key) termkey.termkey_interpret_mouse(tk, key, ev, button, line, col) - t.eq(line[0], 300) -- mouse line for press SGR wide - t.eq(col[0], 500) -- mouse column for press SGR wide + t.eq(300, line[0]) -- mouse line for press SGR wide + t.eq(500, col[0]) -- mouse column for press SGR wide termkey.termkey_destroy(tk) end) @@ -817,24 +817,24 @@ describe('termkey', function() termkey.termkey_push_bytes(tk, '\x1b[?15;7R', 8) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY for position report + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY for position report - t.eq(key.type, termkey.TERMKEY_TYPE_POSITION) -- key.type for position report + t.eq(termkey.TERMKEY_TYPE_POSITION, key.type) -- key.type for position report - t.eq(termkey.termkey_interpret_position(tk, key, line, col), termkey.TERMKEY_RES_KEY) -- interpret_position yields RES_KEY + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_interpret_position(tk, key, line, col)) -- interpret_position yields RES_KEY - t.eq(line[0], 15) -- line for position report - t.eq(col[0], 7) -- column for position report + t.eq(15, line[0]) -- line for position report + t.eq(7, col[0]) -- column for position report -- A plain CSI R is likely to be though. -- This is tricky :/ termkey.termkey_push_bytes(tk, '\x1b[R', 3) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY for + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY for - t.eq(key.type, termkey.TERMKEY_TYPE_FUNCTION) -- key.type for - t.eq(key.code.number, 3) -- key.code.number for + t.eq(termkey.TERMKEY_TYPE_FUNCTION, key.type) -- key.type for + t.eq(3, key.code.number) -- key.code.number for termkey.termkey_destroy(tk) end) @@ -848,33 +848,33 @@ describe('termkey', function() termkey.termkey_push_bytes(tk, '\x1b[?1;2$y', 8) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY for mode report + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY for mode report - t.eq(key.type, termkey.TERMKEY_TYPE_MODEREPORT) -- key.type for mode report + t.eq(termkey.TERMKEY_TYPE_MODEREPORT, key.type) -- key.type for mode report t.eq( - termkey.termkey_interpret_modereport(tk, key, initial, mode, value), - termkey.TERMKEY_RES_KEY + termkey.TERMKEY_RES_KEY, + termkey.termkey_interpret_modereport(tk, key, initial, mode, value) ) -- interpret_modereoprt yields RES_KEY - t.eq(initial[0], 63) -- initial indicator from mode report - t.eq(mode[0], 1) -- mode number from mode report - t.eq(value[0], 2) -- mode value from mode report + t.eq(63, initial[0]) -- initial indicator from mode report + t.eq(1, mode[0]) -- mode number from mode report + t.eq(2, value[0]) -- mode value from mode report termkey.termkey_push_bytes(tk, '\x1b[4;1$y', 7) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY for mode report + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY for mode report - t.eq(key.type, termkey.TERMKEY_TYPE_MODEREPORT) -- key.type for mode report + t.eq(termkey.TERMKEY_TYPE_MODEREPORT, key.type) -- key.type for mode report t.eq( - termkey.termkey_interpret_modereport(tk, key, initial, mode, value), - termkey.TERMKEY_RES_KEY + termkey.TERMKEY_RES_KEY, + termkey.termkey_interpret_modereport(tk, key, initial, mode, value) ) -- interpret_modereoprt yields RES_KEY - t.eq(initial[0], 0) -- initial indicator from mode report - t.eq(mode[0], 4) -- mode number from mode report - t.eq(value[0], 1) -- mode value from mode report + t.eq(0, initial[0]) -- initial indicator from mode report + t.eq(4, mode[0]) -- mode number from mode report + t.eq(1, value[0]) -- mode value from mode report termkey.termkey_destroy(tk) end) @@ -888,30 +888,30 @@ describe('termkey', function() termkey.termkey_push_bytes(tk, '\x1b[5;25v', 7) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY for CSI v + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY for CSI v - t.eq(key.type, termkey.TERMKEY_TYPE_UNKNOWN_CSI) -- key.type for unknown CSI + t.eq(termkey.TERMKEY_TYPE_UNKNOWN_CSI, key.type) -- key.type for unknown CSI - t.eq(termkey.termkey_interpret_csi(tk, key, args, nargs, command), termkey.TERMKEY_RES_KEY) -- interpret_csi yields RES_KEY + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_interpret_csi(tk, key, args, nargs, command)) -- interpret_csi yields RES_KEY - t.eq(nargs[0], 2) -- nargs for unknown CSI - -- t.eq(args[0], 5) -- args[0] for unknown CSI - -- t.eq(args[1], 25) -- args[1] for unknown CSI - t.eq(command[0], 118) -- command for unknown CSI + t.eq(2, nargs[0]) -- nargs for unknown CSI + -- t.eq(5, args[0]) -- args[0] for unknown CSI + -- t.eq(25, args[1]) -- args[1] for unknown CSI + t.eq(118, command[0]) -- command for unknown CSI termkey.termkey_push_bytes(tk, '\x1b[?w', 4) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY for CSI ? w - t.eq(key.type, termkey.TERMKEY_TYPE_UNKNOWN_CSI) -- key.type for unknown CSI - t.eq(termkey.termkey_interpret_csi(tk, key, args, nargs, command), termkey.TERMKEY_RES_KEY) -- interpret_csi yields RES_KEY - t.eq(command[0], bit.bor(bit.lshift(63, 8), 119)) -- command for unknown CSI + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY for CSI ? w + t.eq(termkey.TERMKEY_TYPE_UNKNOWN_CSI, key.type) -- key.type for unknown CSI + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_interpret_csi(tk, key, args, nargs, command)) -- interpret_csi yields RES_KEY + t.eq(bit.bor(bit.lshift(63, 8), 119), command[0]) -- command for unknown CSI termkey.termkey_push_bytes(tk, '\x1b[?$x', 5) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY for CSI ? $x - t.eq(key.type, termkey.TERMKEY_TYPE_UNKNOWN_CSI) -- key.type for unknown CSI - t.eq(termkey.termkey_interpret_csi(tk, key, args, nargs, command), termkey.TERMKEY_RES_KEY) -- interpret_csi yields RES_KEY - t.eq(command[0], bit.bor(bit.lshift(36, 16), bit.lshift(63, 8), 120)) -- command for unknown CSI + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY for CSI ? $x + t.eq(termkey.TERMKEY_TYPE_UNKNOWN_CSI, key.type) -- key.type for unknown CSI + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_interpret_csi(tk, key, args, nargs, command)) -- interpret_csi yields RES_KEY + t.eq(bit.bor(bit.lshift(36, 16), bit.lshift(63, 8), 120), command[0]) -- command for unknown CSI termkey.termkey_destroy(tk) end) @@ -923,53 +923,53 @@ describe('termkey', function() -- 7bit DCS termkey.termkey_push_bytes(tk, '\x1bP1$r1 q\x1b\\', 10) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY for DCS + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY for DCS - t.eq(key.type, termkey.TERMKEY_TYPE_DCS) -- key.type for DCS - t.eq(key.modifiers, 0) -- key.modifiers for DCS + t.eq(termkey.TERMKEY_TYPE_DCS, key.type) -- key.type for DCS + t.eq(0, key.modifiers) -- key.modifiers for DCS local str = t.ffi.new('const char*[1]') - t.eq(termkey.termkey_interpret_string(tk, key, str), termkey.TERMKEY_RES_KEY) -- termkey_interpret_string() gives string - t.eq(t.ffi.string(str[0]), '1$r1 q') -- termkey_interpret_string() yields correct string + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_interpret_string(tk, key, str)) -- termkey_interpret_string() gives string + t.eq('1$r1 q', t.ffi.string(str[0])) -- termkey_interpret_string() yields correct string - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_NONE) -- getkey again yields RES_NONE + t.eq(termkey.TERMKEY_RES_NONE, termkey.termkey_getkey(tk, key)) -- getkey again yields RES_NONE -- 8bit DCS termkey.termkey_push_bytes(tk, '\x901$r2 q\x9c', 8) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY for DCS + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY for DCS - t.eq(key.type, termkey.TERMKEY_TYPE_DCS) -- key.type for DCS - t.eq(key.modifiers, 0) -- key.modifiers for DCS + t.eq(termkey.TERMKEY_TYPE_DCS, key.type) -- key.type for DCS + t.eq(0, key.modifiers) -- key.modifiers for DCS - t.eq(termkey.termkey_interpret_string(tk, key, str), termkey.TERMKEY_RES_KEY) -- "termkey_interpret_string() gives string"); - t.eq(t.ffi.string(str[0]), '1$r2 q') -- "termkey_interpret_string() yields correct string"); + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_interpret_string(tk, key, str)) -- "termkey_interpret_string() gives string"); + t.eq('1$r2 q', t.ffi.string(str[0])) -- "termkey_interpret_string() yields correct string"); - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_NONE) -- "getkey again yields RES_NONE"); + t.eq(termkey.TERMKEY_RES_NONE, termkey.termkey_getkey(tk, key)) -- "getkey again yields RES_NONE"); -- 7bit OSC termkey.termkey_push_bytes(tk, '\x1b]15;abc\x1b\\', 10) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_KEY) -- getkey yields RES_KEY for OSC + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey(tk, key)) -- getkey yields RES_KEY for OSC - t.eq(key.type, termkey.TERMKEY_TYPE_OSC) -- key.type for OSC - t.eq(key.modifiers, 0) -- key.modifiers for OSC + t.eq(termkey.TERMKEY_TYPE_OSC, key.type) -- key.type for OSC + t.eq(0, key.modifiers) -- key.modifiers for OSC - t.eq(termkey.termkey_interpret_string(tk, key, str), termkey.TERMKEY_RES_KEY) -- "termkey_interpret_string() gives string"); - t.eq(t.ffi.string(str[0]), '15;abc') -- "termkey_interpret_string() yields correct string"); + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_interpret_string(tk, key, str)) -- "termkey_interpret_string() gives string"); + t.eq('15;abc', t.ffi.string(str[0])) -- "termkey_interpret_string() yields correct string"); - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_NONE) -- getkey again yields RES_NONE + t.eq(termkey.TERMKEY_RES_NONE, termkey.termkey_getkey(tk, key)) -- getkey again yields RES_NONE -- False alarm termkey.termkey_push_bytes(tk, '\x1bP', 2) - t.eq(termkey.termkey_getkey(tk, key), termkey.TERMKEY_RES_AGAIN) -- getkey yields RES_AGAIN for false alarm + t.eq(termkey.TERMKEY_RES_AGAIN, termkey.termkey_getkey(tk, key)) -- getkey yields RES_AGAIN for false alarm - t.eq(termkey.termkey_getkey_force(tk, key), termkey.TERMKEY_RES_KEY) -- getkey_force yields RES_KEY for false alarm + t.eq(termkey.TERMKEY_RES_KEY, termkey.termkey_getkey_force(tk, key)) -- getkey_force yields RES_KEY for false alarm - t.eq(key.type, termkey.TERMKEY_TYPE_UNICODE) -- key.type for false alarm - t.eq(key.code.codepoint, string.byte('P')) -- key.code.codepoint for false alarm - t.eq(key.modifiers, termkey.TERMKEY_KEYMOD_ALT) -- key.modifiers for false alarm + t.eq(termkey.TERMKEY_TYPE_UNICODE, key.type) -- key.type for false alarm + t.eq(string.byte('P'), key.code.codepoint) -- key.code.codepoint for false alarm + t.eq(termkey.TERMKEY_KEYMOD_ALT, key.modifiers) -- key.modifiers for false alarm termkey.termkey_destroy(tk) end) diff --git a/test/unit/undo_spec.lua b/test/unit/undo_spec.lua index 556c3fbf8c..fec4e0afa0 100644 --- a/test/unit/undo_spec.lua +++ b/test/unit/undo_spec.lua @@ -70,7 +70,7 @@ describe('u_write_undo', function() local correct_name = ffi.string(undo.u_get_undo_file_name(file_buffer.b_ffname, false)) local undo_file = io.open(correct_name, 'r') - neq(undo_file, nil) + neq(nil, undo_file) local success, err = os.remove(correct_name) -- delete the file now that we're done with it. if not success then print(err) -- inform tester if undofile fails to delete @@ -82,7 +82,7 @@ describe('u_write_undo', function() u_write_undo(correct_name, false, file_buffer, buffer_hash) local undo_file = io.open(correct_name, 'r') - neq(undo_file, nil) + neq(nil, undo_file) local success, err = os.remove(correct_name) -- delete the file now that we're done with it. if not success then print(err) -- inform tester if undofile fails to delete @@ -206,6 +206,6 @@ describe('u_write_undo', function() u_write_undo(nil, false, file_buffer, buffer_hash) local undo_file = io.open(correct_name, 'r') - eq(undo_file, nil) + eq(nil, undo_file) end) end) diff --git a/test/unit/vterm_spec.lua b/test/unit/vterm_spec.lua index da118d33b4..e20249940f 100644 --- a/test/unit/vterm_spec.lua +++ b/test/unit/vterm_spec.lua @@ -315,9 +315,9 @@ local function lineinfo(row, expected, state) local dhl = info.doubleheight == 1 local cont = info.continuation == 1 - t.eq(dwl, expected.dwl or false) - t.eq(dhl, expected.dhl or false) - t.eq(cont, expected.cont or false) + t.eq(expected.dwl or false, dwl) + t.eq(expected.dhl or false, dhl) + t.eq(expected.cont or false, cont) end local function pen(attribute, expected, state)