diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-02-27 10:29:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-27 10:29:46 +0100 |
commit | c318d8e672a3b1dfe4ba7954dbca61c509c2b99c (patch) | |
tree | 282a6090dbf2d9017a3ad0a7382df08b2d320a05 /test/functional/api | |
parent | 8c8ce1832e780f87b2922ba3acf0d44f78c50931 (diff) | |
parent | a85021068de95ef7c69b3b93b31bc32fbb154ed3 (diff) | |
download | rneovim-c318d8e672a3b1dfe4ba7954dbca61c509c2b99c.tar.gz rneovim-c318d8e672a3b1dfe4ba7954dbca61c509c2b99c.tar.bz2 rneovim-c318d8e672a3b1dfe4ba7954dbca61c509c2b99c.zip |
Merge #6112 from ZyX-I/split-eval'/buf_get_changedtick
Better b:changedtick support
Diffstat (limited to 'test/functional/api')
-rw-r--r-- | test/functional/api/buffer_spec.lua | 23 | ||||
-rw-r--r-- | test/functional/api/tabpage_spec.lua | 7 | ||||
-rw-r--r-- | test/functional/api/vim_spec.lua | 13 | ||||
-rw-r--r-- | test/functional/api/window_spec.lua | 7 |
4 files changed, 46 insertions, 4 deletions
diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua index 3d3a2bb046..e7e2168238 100644 --- a/test/functional/api/buffer_spec.lua +++ b/test/functional/api/buffer_spec.lua @@ -2,8 +2,11 @@ local helpers = require('test.functional.helpers')(after_each) local clear, nvim, buffer = helpers.clear, helpers.nvim, helpers.buffer local curbuf, curwin, eq = helpers.curbuf, helpers.curwin, helpers.eq local curbufmeths, ok = helpers.curbufmeths, helpers.ok -local funcs, request = helpers.funcs, helpers.request +local funcs = helpers.funcs +local request = helpers.request local NIL = helpers.NIL +local meth_pcall = helpers.meth_pcall +local command = helpers.command describe('api/buf', function() before_each(clear) @@ -249,6 +252,24 @@ describe('api/buf', function() eq(1, funcs.exists('b:lua')) curbufmeths.del_var('lua') eq(0, funcs.exists('b:lua')) + eq({false, 'Key "lua" doesn\'t exist'}, meth_pcall(curbufmeths.del_var, 'lua')) + curbufmeths.set_var('lua', 1) + command('lockvar b:lua') + eq({false, 'Key is locked: lua'}, meth_pcall(curbufmeths.del_var, 'lua')) + eq({false, 'Key is locked: lua'}, meth_pcall(curbufmeths.set_var, 'lua', 1)) + eq({false, 'Key is read-only: changedtick'}, + meth_pcall(curbufmeths.del_var, 'changedtick')) + eq({false, 'Key is read-only: changedtick'}, + meth_pcall(curbufmeths.set_var, 'changedtick', 1)) + end) + end) + + describe('get_changedtick', function() + it('works', function() + eq(2, curbufmeths.get_changedtick()) + curbufmeths.set_lines(0, 1, false, {'abc\0', '\0def', 'ghi'}) + eq(3, curbufmeths.get_changedtick()) + eq(3, curbufmeths.get_var('changedtick')) end) it('buffer_set_var returns the old value', function() diff --git a/test/functional/api/tabpage_spec.lua b/test/functional/api/tabpage_spec.lua index e10f30085f..d7ef53a88f 100644 --- a/test/functional/api/tabpage_spec.lua +++ b/test/functional/api/tabpage_spec.lua @@ -6,6 +6,8 @@ local curtabmeths = helpers.curtabmeths local funcs = helpers.funcs local request = helpers.request local NIL = helpers.NIL +local meth_pcall = helpers.meth_pcall +local command = helpers.command describe('api/tabpage', function() before_each(clear) @@ -32,6 +34,11 @@ describe('api/tabpage', function() eq(1, funcs.exists('t:lua')) curtabmeths.del_var('lua') eq(0, funcs.exists('t:lua')) + eq({false, 'Key "lua" doesn\'t exist'}, meth_pcall(curtabmeths.del_var, 'lua')) + curtabmeths.set_var('lua', 1) + command('lockvar t:lua') + eq({false, 'Key is locked: lua'}, meth_pcall(curtabmeths.del_var, 'lua')) + eq({false, 'Key is locked: lua'}, meth_pcall(curtabmeths.set_var, 'lua', 1)) end) it('tabpage_set_var returns the old value', function() diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index ce6c52e334..3348368a36 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -7,6 +7,8 @@ local os_name = helpers.os_name local meths = helpers.meths local funcs = helpers.funcs local request = helpers.request +local meth_pcall = helpers.meth_pcall +local command = helpers.command describe('api', function() before_each(clear) @@ -43,7 +45,7 @@ describe('api', function() it('works', function() nvim('command', 'let g:v1 = "a"') nvim('command', 'let g:v2 = [1, 2, {"v3": 3}]') - eq({v1 = 'a', v2 = {1, 2, {v3 = 3}}}, nvim('eval', 'g:')) + eq({v1 = 'a', v2 = { 1, 2, { v3 = 3 } } }, nvim('eval', 'g:')) end) it('handles NULL-initialized strings correctly', function() @@ -65,7 +67,7 @@ describe('api', function() describe('nvim_call_function', function() it('works', function() - nvim('call_function', 'setqflist', {{{ filename = 'something', lnum = 17}}, 'r'}) + nvim('call_function', 'setqflist', { { { filename = 'something', lnum = 17 } }, 'r' }) eq(17, nvim('call_function', 'getqflist', {})[1].lnum) eq(17, nvim('call_function', 'eval', {17})) eq('foo', nvim('call_function', 'simplify', {'this/./is//redundant/../../../foo'})) @@ -117,6 +119,11 @@ describe('api', function() eq(1, funcs.exists('g:lua')) meths.del_var('lua') eq(0, funcs.exists('g:lua')) + eq({false, 'Key "lua" doesn\'t exist'}, meth_pcall(meths.del_var, 'lua')) + meths.set_var('lua', 1) + command('lockvar lua') + eq({false, 'Key is locked: lua'}, meth_pcall(meths.del_var, 'lua')) + eq({false, 'Key is locked: lua'}, meth_pcall(meths.set_var, 'lua', 1)) end) it('vim_set_var returns the old value', function() @@ -396,7 +403,7 @@ describe('api', function() eq(1, meths.get_var('avar')) req = { - {'nvim_set_var', {'bvar', {2,3}}}, + { 'nvim_set_var', { 'bvar', { 2, 3 } } }, 12, } status, err = pcall(meths.call_atomic, req) diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua index 465bda6bc9..deffc68994 100644 --- a/test/functional/api/window_spec.lua +++ b/test/functional/api/window_spec.lua @@ -8,6 +8,8 @@ local curwinmeths = helpers.curwinmeths local funcs = helpers.funcs local request = helpers.request local NIL = helpers.NIL +local meth_pcall = helpers.meth_pcall +local command = helpers.command -- check if str is visible at the beginning of some line local function is_visible(str) @@ -137,6 +139,11 @@ describe('api/win', function() eq(1, funcs.exists('w:lua')) curwinmeths.del_var('lua') eq(0, funcs.exists('w:lua')) + eq({false, 'Key "lua" doesn\'t exist'}, meth_pcall(curwinmeths.del_var, 'lua')) + curwinmeths.set_var('lua', 1) + command('lockvar w:lua') + eq({false, 'Key is locked: lua'}, meth_pcall(curwinmeths.del_var, 'lua')) + eq({false, 'Key is locked: lua'}, meth_pcall(curwinmeths.set_var, 'lua', 1)) end) it('window_set_var returns the old value', function() |