3452
|
1 Test for Lua interface and luaeval() function
|
|
2
|
|
3 STARTTEST
|
|
4 :so small.vim
|
|
5 :so lua.vim
|
|
6 :set nocompatible viminfo+=nviminfo
|
|
7 :lua l = vim.list():add"item0":add"dictionary with list OK":add"item2"
|
|
8 :lua h = vim.dict(); h.list = l
|
|
9 :call garbagecollect()
|
|
10 /^1
|
|
11 :" change buffer contents
|
|
12 :lua curbuf = vim.buffer()
|
|
13 :lua curline = vim.eval"line('.')"
|
|
14 :lua curbuf[curline] = "1 changed line 1"
|
|
15 :" scalar test
|
|
16 :let tmp_string = luaeval('"string"')
|
|
17 :let tmp_1000 = luaeval('1000')
|
|
18 :if printf("%s%.0f", tmp_string, tmp_1000) == "string1000"
|
|
19 :let scalar_res = "OK"
|
|
20 :else
|
|
21 :let scalar_res = "FAILED"
|
|
22 :endif
|
|
23 :call append(search("^1"), "scalar test " . scalar_res)
|
|
24 :" dictionary containing a list
|
|
25 :let tmp = luaeval("h").list[1]
|
|
26 :/^2/put =tmp
|
|
27 :" circular list (at the same time test lists containing lists)
|
|
28 :lua l[2] = l
|
|
29 :let l2 = luaeval("h").list
|
|
30 :if l2[2] == l2
|
|
31 :let res = "OK"
|
|
32 :else
|
|
33 :let res = "FAILED"
|
|
34 :endif
|
|
35 :call setline(search("^3"), "circular test " . res)
|
|
36 :?^1?,$w! test.out
|
|
37 :qa!
|
|
38 ENDTEST
|
|
39
|
|
40 1 line 1
|
|
41 2 line 2
|
|
42 3 line 3
|