Skip to content

Commit a0928e0

Browse files
committed
add tests for vim.api
1 parent 34e40ae commit a0928e0

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

test/test_buffer.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ def test_vars():
7676
eq(vim.eval('b:python'), [1, 2, {'3': 1}])
7777

7878

79+
@with_setup(setup=cleanup)
80+
def test_api():
81+
vim.current.buffer.api.set_var('myvar', 'thetext')
82+
eq(vim.current.buffer.api.get_var('myvar'), 'thetext')
83+
eq(vim.eval('b:myvar'), 'thetext')
84+
vim.current.buffer.api.set_line_slice(0,-1,True,True,['alpha', 'beta'])
85+
eq(vim.current.buffer.api.get_line_slice(0,-1,True,True), ['alpha', 'beta'])
86+
eq(vim.current.buffer[:], ['alpha', 'beta'])
87+
88+
7989
@with_setup(setup=cleanup)
8090
def test_options():
8191
eq(vim.current.buffer.options['shiftwidth'], 8)

test/test_vim.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ def test_call():
4747
eq(vim.funcs.Testfun(3, 'alpha'), '3:alpha')
4848

4949

50+
@with_setup(setup=cleanup)
51+
def test_api():
52+
vim.api.command('let g:var = 3')
53+
eq(vim.api.eval('g:var'), 3)
54+
55+
5056
@with_setup(setup=cleanup)
5157
def test_strwidth():
5258
eq(vim.strwidth('abc'), 3)

0 commit comments

Comments
 (0)