Mercurial > vim
annotate src/testdir/test85.in @ 12225:fc791b69be77
Added tag v8.0.0992 for changeset bccf3de747249564fee1e2b1aca090391d5e5da7
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 24 Aug 2017 00:00:05 +0200 |
parents | ae45d497868f |
children |
rev | line source |
---|---|
3452 | 1 Test for Lua interface and luaeval() function |
2 | |
3 STARTTEST | |
4 :so small.vim | |
11091
ae45d497868f
patch 8.0.0433: beeps when running tests
Christian Brabandt <cb@256bit.org>
parents:
4293
diff
changeset
|
5 :set belloff=all |
3452 | 6 :so lua.vim |
7 :set nocompatible viminfo+=nviminfo | |
8 :lua l = vim.list():add"item0":add"dictionary with list OK":add"item2" | |
9 :lua h = vim.dict(); h.list = l | |
10 :call garbagecollect() | |
11 /^1 | |
12 :" change buffer contents | |
13 :lua curbuf = vim.buffer() | |
14 :lua curline = vim.eval"line('.')" | |
15 :lua curbuf[curline] = "1 changed line 1" | |
16 :" scalar test | |
17 :let tmp_string = luaeval('"string"') | |
18 :let tmp_1000 = luaeval('1000') | |
19 :if printf("%s%.0f", tmp_string, tmp_1000) == "string1000" | |
20 :let scalar_res = "OK" | |
21 :else | |
22 :let scalar_res = "FAILED" | |
23 :endif | |
24 :call append(search("^1"), "scalar test " . scalar_res) | |
25 :" dictionary containing a list | |
26 :let tmp = luaeval("h").list[1] | |
27 :/^2/put =tmp | |
28 :" circular list (at the same time test lists containing lists) | |
29 :lua l[2] = l | |
30 :let l2 = luaeval("h").list | |
31 :if l2[2] == l2 | |
32 :let res = "OK" | |
33 :else | |
34 :let res = "FAILED" | |
35 :endif | |
36 :call setline(search("^3"), "circular test " . res) | |
4293 | 37 |
38 :let l = [] | |
39 :lua l = vim.eval("l") | |
40 :lua l:add(123) | |
41 :lua l:add("abc") | |
42 :lua l:add(vim.eval("[1, 2, 3]")) | |
43 :lua l:add(vim.eval("{'a':1, 'b':2, 'c':3}")) | |
44 :lua l:insert(123) | |
45 :lua l:insert("abc") | |
46 :lua l:insert(vim.eval("[1, 2, 3]")) | |
47 :lua l:insert(vim.eval("{'a':1, 'b':2, 'c':3}")) | |
48 :lua l[0] = l[0] | |
49 :lua l[1] = l[1] | |
50 :lua l[2] = l[2] | |
51 :lua l[3] = l[3] | |
52 :lua l[0] = 123 | |
53 :lua l[1] = "abc" | |
54 :lua l[2] = vim.eval("[1, 2, 3]") | |
55 :lua l[3] = vim.eval("{'a':1, 'b':2, 'c':3}") | |
56 :lua l[3] = nil | |
57 :lua l[2] = nil | |
58 :lua l[1] = nil | |
59 :lua l[0] = nil | |
60 :lua l = nil | |
61 :$put =string(l) | |
62 | |
63 :let d = {} | |
64 :lua d = vim.eval("d") | |
65 :lua d[0] = 123 | |
66 :lua d[1] = "abc" | |
67 :lua d[2] = vim.eval("[1, 2, 3]") | |
68 :lua d[3] = vim.eval("{'a':1, 'b':2, 'c':3}") | |
69 :lua d[4] = d[0] | |
70 :lua d[5] = d[1] | |
71 :lua d[6] = d[2] | |
72 :lua d[7] = d[3] | |
73 :lua d[3] = nil | |
74 :lua d[2] = nil | |
75 :lua d[1] = nil | |
76 :lua d[0] = nil | |
77 :lua d = nil | |
78 :$put =string(d) | |
79 | |
3452 | 80 :?^1?,$w! test.out |
81 :qa! | |
82 ENDTEST | |
83 | |
84 1 line 1 | |
85 2 line 2 | |
86 3 line 3 |