Mercurial > vim
annotate src/testdir/test_lua.vim @ 34639:ceee63c7f7aa v9.1.0205
patch 9.1.0205: Cannot use modifiers before :-Ntabmove
Commit: https://github.com/vim/vim/commit/076faac5378cf517baa8c331c57488d39efadec0
Author: zeertzjq <zeertzjq@outlook.com>
Date: Mon Mar 25 16:41:06 2024 +0100
patch 9.1.0205: Cannot use modifiers before :-Ntabmove
Problem: Cannot use modifiers before :-Ntabmove.
Solution: Check backwards from the command instead of checking from the
start of the command line. Slightly adjust docs to make them
more consistent (zeertzjq).
closes: #14289
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 25 Mar 2024 16:45:06 +0100 |
parents | daaff6843090 |
children | 37fd52cbb48e |
rev | line source |
---|---|
10757
6c3d42d18366
patch 8.0.0268: may get ml_get error when :luado deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Tests for Lua. |
6c3d42d18366
patch 8.0.0268: may get ml_get error when :luado deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
17089
8e9e9124c7a2
patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents:
17049
diff
changeset
|
3 source check.vim |
22719
8da5e18effc5
patch 8.2.1908: Lua is initialized even when not used
Bram Moolenaar <Bram@vim.org>
parents:
21283
diff
changeset
|
4 |
8da5e18effc5
patch 8.2.1908: Lua is initialized even when not used
Bram Moolenaar <Bram@vim.org>
parents:
21283
diff
changeset
|
5 " This test also works without the lua feature. |
8da5e18effc5
patch 8.2.1908: Lua is initialized even when not used
Bram Moolenaar <Bram@vim.org>
parents:
21283
diff
changeset
|
6 func Test_skip_lua() |
8da5e18effc5
patch 8.2.1908: Lua is initialized even when not used
Bram Moolenaar <Bram@vim.org>
parents:
21283
diff
changeset
|
7 if 0 |
8da5e18effc5
patch 8.2.1908: Lua is initialized even when not used
Bram Moolenaar <Bram@vim.org>
parents:
21283
diff
changeset
|
8 lua print("Not executed") |
8da5e18effc5
patch 8.2.1908: Lua is initialized even when not used
Bram Moolenaar <Bram@vim.org>
parents:
21283
diff
changeset
|
9 endif |
8da5e18effc5
patch 8.2.1908: Lua is initialized even when not used
Bram Moolenaar <Bram@vim.org>
parents:
21283
diff
changeset
|
10 endfunc |
8da5e18effc5
patch 8.2.1908: Lua is initialized even when not used
Bram Moolenaar <Bram@vim.org>
parents:
21283
diff
changeset
|
11 |
17089
8e9e9124c7a2
patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents:
17049
diff
changeset
|
12 CheckFeature lua |
10757
6c3d42d18366
patch 8.0.0268: may get ml_get error when :luado deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 |
24311
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
14 " Depending on the lua version, the error messages are different. |
24385
0878f0fd349b
patch 8.2.2733: detecting Lua version is not reliable
Bram Moolenaar <Bram@vim.org>
parents:
24317
diff
changeset
|
15 let [s:major, s:minor, s:patch] = luaeval('vim.lua_version')->split('\.')->map({-> str2nr(v:val)}) |
24311
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
16 let s:lua_53_or_later = 0 |
27430
da3a39fd0964
patch 8.2.4243: Lua tests fail with Lua 5.4.4
Bram Moolenaar <Bram@vim.org>
parents:
25527
diff
changeset
|
17 let s:lua_543 = 0 |
24311
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
18 if (s:major == 5 && s:minor >= 3) || s:major > 5 |
21108
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
19 let s:lua_53_or_later = 1 |
27430
da3a39fd0964
patch 8.2.4243: Lua tests fail with Lua 5.4.4
Bram Moolenaar <Bram@vim.org>
parents:
25527
diff
changeset
|
20 if s:major == 5 && s:minor == 4 && s:patch == 3 |
da3a39fd0964
patch 8.2.4243: Lua tests fail with Lua 5.4.4
Bram Moolenaar <Bram@vim.org>
parents:
25527
diff
changeset
|
21 let s:lua_543 = 1 |
24311
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
22 endif |
21108
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
23 endif |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
24 |
15997
725255793949
patch 8.1.1004: function "luaV_setref()" not covered with tests
Bram Moolenaar <Bram@vim.org>
parents:
15328
diff
changeset
|
25 func TearDown() |
725255793949
patch 8.1.1004: function "luaV_setref()" not covered with tests
Bram Moolenaar <Bram@vim.org>
parents:
15328
diff
changeset
|
26 " Run garbage collection after each test to exercise luaV_setref(). |
725255793949
patch 8.1.1004: function "luaV_setref()" not covered with tests
Bram Moolenaar <Bram@vim.org>
parents:
15328
diff
changeset
|
27 call test_garbagecollect_now() |
725255793949
patch 8.1.1004: function "luaV_setref()" not covered with tests
Bram Moolenaar <Bram@vim.org>
parents:
15328
diff
changeset
|
28 endfunc |
725255793949
patch 8.1.1004: function "luaV_setref()" not covered with tests
Bram Moolenaar <Bram@vim.org>
parents:
15328
diff
changeset
|
29 |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
30 " Check that switching to another buffer does not trigger ml_get error. |
34234
daaff6843090
patch 9.1.0062: Internal error when :luado/perldo/pydo etc delete lines
Christian Brabandt <cb@256bit.org>
parents:
33339
diff
changeset
|
31 func Test_lua_luado_change_buffer() |
10757
6c3d42d18366
patch 8.0.0268: may get ml_get error when :luado deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 new |
34234
daaff6843090
patch 9.1.0062: Internal error when :luado/perldo/pydo etc delete lines
Christian Brabandt <cb@256bit.org>
parents:
33339
diff
changeset
|
33 |
10757
6c3d42d18366
patch 8.0.0268: may get ml_get error when :luado deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 let wincount = winnr('$') |
6c3d42d18366
patch 8.0.0268: may get ml_get error when :luado deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 call setline(1, ['one', 'two', 'three']) |
6c3d42d18366
patch 8.0.0268: may get ml_get error when :luado deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 luado vim.command("new") |
6c3d42d18366
patch 8.0.0268: may get ml_get error when :luado deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 call assert_equal(wincount + 1, winnr('$')) |
34234
daaff6843090
patch 9.1.0062: Internal error when :luado/perldo/pydo etc delete lines
Christian Brabandt <cb@256bit.org>
parents:
33339
diff
changeset
|
38 |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
39 %bwipe! |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
40 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
41 |
34234
daaff6843090
patch 9.1.0062: Internal error when :luado/perldo/pydo etc delete lines
Christian Brabandt <cb@256bit.org>
parents:
33339
diff
changeset
|
42 " Check that :luado deleting lines does not trigger ml_get error. |
daaff6843090
patch 9.1.0062: Internal error when :luado/perldo/pydo etc delete lines
Christian Brabandt <cb@256bit.org>
parents:
33339
diff
changeset
|
43 func Test_lua_luado_delete_lines() |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
44 new |
34234
daaff6843090
patch 9.1.0062: Internal error when :luado/perldo/pydo etc delete lines
Christian Brabandt <cb@256bit.org>
parents:
33339
diff
changeset
|
45 |
daaff6843090
patch 9.1.0062: Internal error when :luado/perldo/pydo etc delete lines
Christian Brabandt <cb@256bit.org>
parents:
33339
diff
changeset
|
46 call setline(1, ['one', 'two', 'three']) |
daaff6843090
patch 9.1.0062: Internal error when :luado/perldo/pydo etc delete lines
Christian Brabandt <cb@256bit.org>
parents:
33339
diff
changeset
|
47 luado vim.command("%d_") |
daaff6843090
patch 9.1.0062: Internal error when :luado/perldo/pydo etc delete lines
Christian Brabandt <cb@256bit.org>
parents:
33339
diff
changeset
|
48 call assert_equal([''], getline(1, '$')) |
daaff6843090
patch 9.1.0062: Internal error when :luado/perldo/pydo etc delete lines
Christian Brabandt <cb@256bit.org>
parents:
33339
diff
changeset
|
49 |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
50 call setline(1, ['one', 'two', 'three']) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
51 luado vim.command("1,2d_") |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
52 call assert_equal(['three'], getline(1, '$')) |
34234
daaff6843090
patch 9.1.0062: Internal error when :luado/perldo/pydo etc delete lines
Christian Brabandt <cb@256bit.org>
parents:
33339
diff
changeset
|
53 |
daaff6843090
patch 9.1.0062: Internal error when :luado/perldo/pydo etc delete lines
Christian Brabandt <cb@256bit.org>
parents:
33339
diff
changeset
|
54 call setline(1, ['one', 'two', 'three']) |
daaff6843090
patch 9.1.0062: Internal error when :luado/perldo/pydo etc delete lines
Christian Brabandt <cb@256bit.org>
parents:
33339
diff
changeset
|
55 luado vim.command("2,3d_"); return "REPLACED" |
daaff6843090
patch 9.1.0062: Internal error when :luado/perldo/pydo etc delete lines
Christian Brabandt <cb@256bit.org>
parents:
33339
diff
changeset
|
56 call assert_equal(['REPLACED'], getline(1, '$')) |
daaff6843090
patch 9.1.0062: Internal error when :luado/perldo/pydo etc delete lines
Christian Brabandt <cb@256bit.org>
parents:
33339
diff
changeset
|
57 |
daaff6843090
patch 9.1.0062: Internal error when :luado/perldo/pydo etc delete lines
Christian Brabandt <cb@256bit.org>
parents:
33339
diff
changeset
|
58 call setline(1, ['one', 'two', 'three']) |
daaff6843090
patch 9.1.0062: Internal error when :luado/perldo/pydo etc delete lines
Christian Brabandt <cb@256bit.org>
parents:
33339
diff
changeset
|
59 2,3luado vim.command("1,2d_"); return "REPLACED" |
daaff6843090
patch 9.1.0062: Internal error when :luado/perldo/pydo etc delete lines
Christian Brabandt <cb@256bit.org>
parents:
33339
diff
changeset
|
60 call assert_equal(['three'], getline(1, '$')) |
daaff6843090
patch 9.1.0062: Internal error when :luado/perldo/pydo etc delete lines
Christian Brabandt <cb@256bit.org>
parents:
33339
diff
changeset
|
61 |
10757
6c3d42d18366
patch 8.0.0268: may get ml_get error when :luado deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
62 bwipe! |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
63 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
64 |
21108
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
65 func Test_lua_luado() |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
66 new |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
67 call setline(1, ['one', 'two']) |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
68 luado return(linenr) |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
69 call assert_equal(['1', '2'], getline(1, '$')) |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
70 close! |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
71 |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
72 " Error cases |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
73 call assert_fails('luado string.format()', |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
74 \ "[string \"vim chunk\"]:1: bad argument #1 to 'format' (string expected, got no value)") |
27430
da3a39fd0964
patch 8.2.4243: Lua tests fail with Lua 5.4.4
Bram Moolenaar <Bram@vim.org>
parents:
25527
diff
changeset
|
75 if s:lua_543 |
24311
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
76 let msg = "[string \"vim chunk\"]:1: global 'func' is not callable (a nil value)" |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
77 elseif s:lua_53_or_later |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
78 let msg = "[string \"vim chunk\"]:1: attempt to call a nil value (global 'func')" |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
79 else |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
80 let msg = "[string \"vim chunk\"]:1: attempt to call global 'func' (a nil value)" |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
81 endif |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
82 call assert_fails('luado func()', msg) |
21108
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
83 call assert_fails('luado error("failed")', "[string \"vim chunk\"]:1: failed") |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
84 endfunc |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
85 |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
86 " Test vim.eval() |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
87 func Test_lua_eval() |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
88 " lua.eval with a number |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
89 lua v = vim.eval('123') |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
90 call assert_equal('number', luaeval('vim.type(v)')) |
20441
86dde5c4b375
patch 8.2.0775: not easy to call a Vim function from Lua
Bram Moolenaar <Bram@vim.org>
parents:
20233
diff
changeset
|
91 call assert_equal(123, luaeval('v')) |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
92 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
93 " lua.eval with a string |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
94 lua v = vim.eval('"abc"') |
17916
2e53305f2239
patch 8.1.1954: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
95 call assert_equal('string', 'vim.type(v)'->luaeval()) |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
96 call assert_equal('abc', luaeval('v')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
97 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
98 " lua.eval with a list |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
99 lua v = vim.eval("['a']") |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
100 call assert_equal('list', luaeval('vim.type(v)')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
101 call assert_equal(['a'], luaeval('v')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
102 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
103 " lua.eval with a dict |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
104 lua v = vim.eval("{'a':'b'}") |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
105 call assert_equal('dict', luaeval('vim.type(v)')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
106 call assert_equal({'a':'b'}, luaeval('v')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
107 |
16076
a2f0e93a5857
patch 8.1.1043: Lua interface does not support Blob
Bram Moolenaar <Bram@vim.org>
parents:
16028
diff
changeset
|
108 " lua.eval with a blob |
a2f0e93a5857
patch 8.1.1043: Lua interface does not support Blob
Bram Moolenaar <Bram@vim.org>
parents:
16028
diff
changeset
|
109 lua v = vim.eval("0z00112233.deadbeef") |
a2f0e93a5857
patch 8.1.1043: Lua interface does not support Blob
Bram Moolenaar <Bram@vim.org>
parents:
16028
diff
changeset
|
110 call assert_equal('blob', luaeval('vim.type(v)')) |
a2f0e93a5857
patch 8.1.1043: Lua interface does not support Blob
Bram Moolenaar <Bram@vim.org>
parents:
16028
diff
changeset
|
111 call assert_equal(0z00112233.deadbeef, luaeval('v')) |
a2f0e93a5857
patch 8.1.1043: Lua interface does not support Blob
Bram Moolenaar <Bram@vim.org>
parents:
16028
diff
changeset
|
112 |
21108
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
113 " lua.eval with a float |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
114 lua v = vim.eval('3.14') |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
115 call assert_equal('number', luaeval('vim.type(v)')) |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
116 call assert_equal(3.14, luaeval('v')) |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
117 |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
118 " lua.eval with a bool |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
119 lua v = vim.eval('v:true') |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
120 call assert_equal('number', luaeval('vim.type(v)')) |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
121 call assert_equal(1, luaeval('v')) |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
122 lua v = vim.eval('v:false') |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
123 call assert_equal('number', luaeval('vim.type(v)')) |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
124 call assert_equal(0, luaeval('v')) |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
125 |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
126 " lua.eval with a null |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
127 lua v = vim.eval('v:null') |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
128 call assert_equal('nil', luaeval('vim.type(v)')) |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
129 call assert_equal(v:null, luaeval('v')) |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
130 |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
131 call assert_fails('lua v = vim.eval(nil)', |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
132 \ "[string \"vim chunk\"]:1: bad argument #1 to 'eval' (string expected, got nil)") |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
133 call assert_fails('lua v = vim.eval(true)', |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
134 \ "[string \"vim chunk\"]:1: bad argument #1 to 'eval' (string expected, got boolean)") |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
135 call assert_fails('lua v = vim.eval({})', |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
136 \ "[string \"vim chunk\"]:1: bad argument #1 to 'eval' (string expected, got table)") |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
137 call assert_fails('lua v = vim.eval(print)', |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
138 \ "[string \"vim chunk\"]:1: bad argument #1 to 'eval' (string expected, got function)") |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
139 call assert_fails('lua v = vim.eval(vim.buffer())', |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
140 \ "[string \"vim chunk\"]:1: bad argument #1 to 'eval' (string expected, got userdata)") |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
141 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
142 lua v = nil |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
143 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
144 |
24073
c424821dc031
patch 8.2.2578: Lua cannot handle a passed in lambda
Bram Moolenaar <Bram@vim.org>
parents:
22719
diff
changeset
|
145 " Test luaeval() with lambda |
c424821dc031
patch 8.2.2578: Lua cannot handle a passed in lambda
Bram Moolenaar <Bram@vim.org>
parents:
22719
diff
changeset
|
146 func Test_luaeval_with_lambda() |
c424821dc031
patch 8.2.2578: Lua cannot handle a passed in lambda
Bram Moolenaar <Bram@vim.org>
parents:
22719
diff
changeset
|
147 lua function hello_luaeval_lambda(a, cb) return a .. cb() end |
c424821dc031
patch 8.2.2578: Lua cannot handle a passed in lambda
Bram Moolenaar <Bram@vim.org>
parents:
22719
diff
changeset
|
148 call assert_equal('helloworld', |
c424821dc031
patch 8.2.2578: Lua cannot handle a passed in lambda
Bram Moolenaar <Bram@vim.org>
parents:
22719
diff
changeset
|
149 \ luaeval('hello_luaeval_lambda(_A[1], _A[2])', |
c424821dc031
patch 8.2.2578: Lua cannot handle a passed in lambda
Bram Moolenaar <Bram@vim.org>
parents:
22719
diff
changeset
|
150 \ ['hello', {->'world'}])) |
c424821dc031
patch 8.2.2578: Lua cannot handle a passed in lambda
Bram Moolenaar <Bram@vim.org>
parents:
22719
diff
changeset
|
151 lua hello_luaeval_lambda = nil |
c424821dc031
patch 8.2.2578: Lua cannot handle a passed in lambda
Bram Moolenaar <Bram@vim.org>
parents:
22719
diff
changeset
|
152 endfunc |
c424821dc031
patch 8.2.2578: Lua cannot handle a passed in lambda
Bram Moolenaar <Bram@vim.org>
parents:
22719
diff
changeset
|
153 |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
154 " Test vim.window() |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
155 func Test_lua_window() |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
156 e Xfoo2 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
157 new Xfoo1 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
158 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
159 " Window 1 (top window) contains Xfoo1 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
160 " Window 2 (bottom window) contains Xfoo2 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
161 call assert_equal('Xfoo1', luaeval('vim.window(1):buffer().name')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
162 call assert_equal('Xfoo2', luaeval('vim.window(2):buffer().name')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
163 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
164 " Window 3 does not exist so vim.window(3) should return nil |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
165 call assert_equal('nil', luaeval('tostring(vim.window(3))')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
166 |
27430
da3a39fd0964
patch 8.2.4243: Lua tests fail with Lua 5.4.4
Bram Moolenaar <Bram@vim.org>
parents:
25527
diff
changeset
|
167 if s:lua_543 |
24311
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
168 let msg = "[string \"luaeval\"]:1: field 'xyz' is not callable (a nil value)" |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
169 elseif s:lua_53_or_later |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
170 let msg = "[string \"luaeval\"]:1: attempt to call a nil value (field 'xyz')" |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
171 else |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
172 let msg = "[string \"luaeval\"]:1: attempt to call field 'xyz' (a nil value)" |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
173 endif |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
174 call assert_fails("let n = luaeval('vim.window().xyz()')", msg) |
21108
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
175 call assert_fails('lua vim.window().xyz = 1', |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
176 \ "[string \"vim chunk\"]:1: invalid window property: `xyz'") |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
177 |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
178 %bwipe! |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
179 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
180 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
181 " Test vim.window().height |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
182 func Test_lua_window_height() |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
183 new |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
184 lua vim.window().height = 2 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
185 call assert_equal(2, winheight(0)) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
186 lua vim.window().height = vim.window().height + 1 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
187 call assert_equal(3, winheight(0)) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
188 bwipe! |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
189 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
190 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
191 " Test vim.window().width |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
192 func Test_lua_window_width() |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
193 vert new |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
194 lua vim.window().width = 2 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
195 call assert_equal(2, winwidth(0)) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
196 lua vim.window().width = vim.window().width + 1 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
197 call assert_equal(3, winwidth(0)) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
198 bwipe! |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
199 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
200 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
201 " Test vim.window().line and vim.window.col |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
202 func Test_lua_window_line_col() |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
203 new |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
204 call setline(1, ['line1', 'line2', 'line3']) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
205 lua vim.window().line = 2 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
206 lua vim.window().col = 4 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
207 call assert_equal([0, 2, 4, 0], getpos('.')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
208 lua vim.window().line = vim.window().line + 1 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
209 lua vim.window().col = vim.window().col - 1 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
210 call assert_equal([0, 3, 3, 0], getpos('.')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
211 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
212 call assert_fails('lua vim.window().line = 10', |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
213 \ '[string "vim chunk"]:1: line out of range') |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
214 bwipe! |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
215 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
216 |
20441
86dde5c4b375
patch 8.2.0775: not easy to call a Vim function from Lua
Bram Moolenaar <Bram@vim.org>
parents:
20233
diff
changeset
|
217 " Test vim.call |
86dde5c4b375
patch 8.2.0775: not easy to call a Vim function from Lua
Bram Moolenaar <Bram@vim.org>
parents:
20233
diff
changeset
|
218 func Test_lua_call() |
86dde5c4b375
patch 8.2.0775: not easy to call a Vim function from Lua
Bram Moolenaar <Bram@vim.org>
parents:
20233
diff
changeset
|
219 call assert_equal(has('lua'), luaeval('vim.call("has", "lua")')) |
86dde5c4b375
patch 8.2.0775: not easy to call a Vim function from Lua
Bram Moolenaar <Bram@vim.org>
parents:
20233
diff
changeset
|
220 call assert_equal(printf("Hello %s", "vim"), luaeval('vim.call("printf", "Hello %s", "vim")')) |
21108
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
221 |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
222 " Error cases |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
223 call assert_fails("call luaeval('vim.call(\"min\", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21)')", |
21283
1d2c814f4bed
patch 8.2.1192: Lua test fails with older Lua version
Bram Moolenaar <Bram@vim.org>
parents:
21269
diff
changeset
|
224 \ s:lua_53_or_later |
1d2c814f4bed
patch 8.2.1192: Lua test fails with older Lua version
Bram Moolenaar <Bram@vim.org>
parents:
21269
diff
changeset
|
225 \ ? '[string "luaeval"]:1: Function called with too many arguments' |
1d2c814f4bed
patch 8.2.1192: Lua test fails with older Lua version
Bram Moolenaar <Bram@vim.org>
parents:
21269
diff
changeset
|
226 \ : 'Function called with too many arguments') |
21108
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
227 lua co = coroutine.create(function () print("hi") end) |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
228 call assert_fails("call luaeval('vim.call(\"type\", co)')", |
21283
1d2c814f4bed
patch 8.2.1192: Lua test fails with older Lua version
Bram Moolenaar <Bram@vim.org>
parents:
21269
diff
changeset
|
229 \ s:lua_53_or_later |
1d2c814f4bed
patch 8.2.1192: Lua test fails with older Lua version
Bram Moolenaar <Bram@vim.org>
parents:
21269
diff
changeset
|
230 \ ? '[string "luaeval"]:1: lua: cannot convert value' |
1d2c814f4bed
patch 8.2.1192: Lua test fails with older Lua version
Bram Moolenaar <Bram@vim.org>
parents:
21269
diff
changeset
|
231 \ : 'lua: cannot convert value') |
21108
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
232 lua co = nil |
21283
1d2c814f4bed
patch 8.2.1192: Lua test fails with older Lua version
Bram Moolenaar <Bram@vim.org>
parents:
21269
diff
changeset
|
233 call assert_fails("call luaeval('vim.call(\"abc\")')", |
1d2c814f4bed
patch 8.2.1192: Lua test fails with older Lua version
Bram Moolenaar <Bram@vim.org>
parents:
21269
diff
changeset
|
234 \ ['E117:', s:lua_53_or_later ? '\[string "luaeval"]:1: lua: call_vim_function failed' |
1d2c814f4bed
patch 8.2.1192: Lua test fails with older Lua version
Bram Moolenaar <Bram@vim.org>
parents:
21269
diff
changeset
|
235 \ : 'lua: call_vim_function failed']) |
20441
86dde5c4b375
patch 8.2.0775: not easy to call a Vim function from Lua
Bram Moolenaar <Bram@vim.org>
parents:
20233
diff
changeset
|
236 endfunc |
86dde5c4b375
patch 8.2.0775: not easy to call a Vim function from Lua
Bram Moolenaar <Bram@vim.org>
parents:
20233
diff
changeset
|
237 |
86dde5c4b375
patch 8.2.0775: not easy to call a Vim function from Lua
Bram Moolenaar <Bram@vim.org>
parents:
20233
diff
changeset
|
238 " Test vim.fn.* |
86dde5c4b375
patch 8.2.0775: not easy to call a Vim function from Lua
Bram Moolenaar <Bram@vim.org>
parents:
20233
diff
changeset
|
239 func Test_lua_fn() |
86dde5c4b375
patch 8.2.0775: not easy to call a Vim function from Lua
Bram Moolenaar <Bram@vim.org>
parents:
20233
diff
changeset
|
240 call assert_equal(has('lua'), luaeval('vim.fn.has("lua")')) |
86dde5c4b375
patch 8.2.0775: not easy to call a Vim function from Lua
Bram Moolenaar <Bram@vim.org>
parents:
20233
diff
changeset
|
241 call assert_equal(printf("Hello %s", "vim"), luaeval('vim.fn.printf("Hello %s", "vim")')) |
86dde5c4b375
patch 8.2.0775: not easy to call a Vim function from Lua
Bram Moolenaar <Bram@vim.org>
parents:
20233
diff
changeset
|
242 endfunc |
86dde5c4b375
patch 8.2.0775: not easy to call a Vim function from Lua
Bram Moolenaar <Bram@vim.org>
parents:
20233
diff
changeset
|
243 |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
244 " Test setting the current window |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
245 func Test_lua_window_set_current() |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
246 new Xfoo1 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
247 lua w1 = vim.window() |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
248 new Xfoo2 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
249 lua w2 = vim.window() |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
250 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
251 call assert_equal('Xfoo2', bufname('%')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
252 lua w1() |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
253 call assert_equal('Xfoo1', bufname('%')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
254 lua w2() |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
255 call assert_equal('Xfoo2', bufname('%')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
256 |
14239
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
257 lua w1, w2 = nil |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
258 %bwipe! |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
259 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
260 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
261 " Test vim.window().buffer |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
262 func Test_lua_window_buffer() |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
263 new Xfoo1 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
264 lua w1 = vim.window() |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
265 lua b1 = w1.buffer() |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
266 new Xfoo2 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
267 lua w2 = vim.window() |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
268 lua b2 = w2.buffer() |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
269 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
270 lua b1() |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
271 call assert_equal('Xfoo1', bufname('%')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
272 lua b2() |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
273 call assert_equal('Xfoo2', bufname('%')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
274 |
14239
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
275 lua b1, b2, w1, w2 = nil |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
276 %bwipe! |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
277 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
278 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
279 " Test vim.window():previous() and vim.window():next() |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
280 func Test_lua_window_next_previous() |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
281 new Xfoo1 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
282 new Xfoo2 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
283 new Xfoo3 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
284 wincmd j |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
285 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
286 call assert_equal('Xfoo2', luaeval('vim.window().buffer().name')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
287 call assert_equal('Xfoo1', luaeval('vim.window():next():buffer().name')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
288 call assert_equal('Xfoo3', luaeval('vim.window():previous():buffer().name')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
289 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
290 %bwipe! |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
291 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
292 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
293 " Test vim.window():isvalid() |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
294 func Test_lua_window_isvalid() |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
295 new Xfoo |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
296 lua w = vim.window() |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
297 call assert_true(luaeval('w:isvalid()')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
298 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
299 " FIXME: how to test the case when isvalid() returns v:false? |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
300 " isvalid() gives errors when the window is deleted. Is it a bug? |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
301 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
302 lua w = nil |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
303 bwipe! |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
304 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
305 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
306 " Test vim.buffer() with and without argument |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
307 func Test_lua_buffer() |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
308 new Xfoo1 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
309 let bn1 = bufnr('%') |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
310 new Xfoo2 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
311 let bn2 = bufnr('%') |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
312 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
313 " Test vim.buffer() without argument. |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
314 call assert_equal('Xfoo2', luaeval("vim.buffer().name")) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
315 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
316 " Test vim.buffer() with string argument. |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
317 call assert_equal('Xfoo1', luaeval("vim.buffer('Xfoo1').name")) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
318 call assert_equal('Xfoo2', luaeval("vim.buffer('Xfoo2').name")) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
319 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
320 " Test vim.buffer() with integer argument. |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
321 call assert_equal('Xfoo1', luaeval("vim.buffer(" . bn1 . ").name")) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
322 call assert_equal('Xfoo2', luaeval("vim.buffer(" . bn2 . ").name")) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
323 |
14239
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
324 lua bn1, bn2 = nil |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
325 %bwipe! |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
326 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
327 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
328 " Test vim.buffer().name and vim.buffer().fname |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
329 func Test_lua_buffer_name() |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
330 new |
14296
396b71b242b2
patch 8.1.0164: luaeval('vim.buffer().name') returns an error
Christian Brabandt <cb@256bit.org>
parents:
14245
diff
changeset
|
331 call assert_equal('', luaeval('vim.buffer().name')) |
396b71b242b2
patch 8.1.0164: luaeval('vim.buffer().name') returns an error
Christian Brabandt <cb@256bit.org>
parents:
14245
diff
changeset
|
332 call assert_equal('', luaeval('vim.buffer().fname')) |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
333 bwipe! |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
334 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
335 new Xfoo |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
336 call assert_equal('Xfoo', luaeval('vim.buffer().name')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
337 call assert_equal(expand('%:p'), luaeval('vim.buffer().fname')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
338 bwipe! |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
339 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
340 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
341 " Test vim.buffer().number |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
342 func Test_lua_buffer_number() |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
343 " All numbers in Lua are floating points number (no integers). |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
344 call assert_equal(bufnr('%'), float2nr(luaeval('vim.buffer().number'))) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
345 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
346 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
347 " Test inserting lines in buffer. |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
348 func Test_lua_buffer_insert() |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
349 new |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
350 lua vim.buffer()[1] = '3' |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
351 lua vim.buffer():insert('1', 0) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
352 lua vim.buffer():insert('2', 1) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
353 lua vim.buffer():insert('4', 10) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
354 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
355 call assert_equal(['1', '2', '3', '4'], getline(1, '$')) |
21108
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
356 call assert_equal('4', luaeval('vim.buffer()[4]')) |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
357 call assert_equal(v:null, luaeval('vim.buffer()[5]')) |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
358 call assert_equal(v:null, luaeval('vim.buffer()[{}]')) |
27430
da3a39fd0964
patch 8.2.4243: Lua tests fail with Lua 5.4.4
Bram Moolenaar <Bram@vim.org>
parents:
25527
diff
changeset
|
359 if s:lua_543 |
24311
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
360 let msg = "[string \"vim chunk\"]:1: method 'xyz' is not callable (a nil value)" |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
361 elseif s:lua_53_or_later |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
362 let msg = "[string \"vim chunk\"]:1: attempt to call a nil value (method 'xyz')" |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
363 else |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
364 let msg = "[string \"vim chunk\"]:1: attempt to call method 'xyz' (a nil value)" |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
365 endif |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
366 call assert_fails('lua vim.buffer():xyz()', msg) |
21108
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
367 call assert_fails('lua vim.buffer()[1] = {}', |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
368 \ '[string "vim chunk"]:1: wrong argument to change') |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
369 bwipe! |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
370 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
371 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
372 " Test deleting line in buffer |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
373 func Test_lua_buffer_delete() |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
374 new |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
375 call setline(1, ['1', '2', '3']) |
21108
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
376 call cursor(3, 1) |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
377 lua vim.buffer()[2] = nil |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
378 call assert_equal(['1', '3'], getline(1, '$')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
379 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
380 call assert_fails('lua vim.buffer()[3] = nil', |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
381 \ '[string "vim chunk"]:1: invalid line number') |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
382 bwipe! |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
383 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
384 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
385 " Test #vim.buffer() i.e. number of lines in buffer |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
386 func Test_lua_buffer_number_lines() |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
387 new |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
388 call setline(1, ['a', 'b', 'c']) |
20441
86dde5c4b375
patch 8.2.0775: not easy to call a Vim function from Lua
Bram Moolenaar <Bram@vim.org>
parents:
20233
diff
changeset
|
389 call assert_equal(3, luaeval('#vim.buffer()')) |
10757
6c3d42d18366
patch 8.0.0268: may get ml_get error when :luado deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
390 bwipe! |
6c3d42d18366
patch 8.0.0268: may get ml_get error when :luado deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
391 endfunc |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
392 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
393 " Test vim.buffer():next() and vim.buffer():previous() |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
394 " Note that these functions get the next or previous buffers |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
395 " but do not switch buffer. |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
396 func Test_lua_buffer_next_previous() |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
397 new Xfoo1 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
398 new Xfoo2 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
399 new Xfoo3 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
400 b Xfoo2 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
401 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
402 lua bn = vim.buffer():next() |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
403 lua bp = vim.buffer():previous() |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
404 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
405 call assert_equal('Xfoo2', luaeval('vim.buffer().name')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
406 call assert_equal('Xfoo1', luaeval('bp.name')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
407 call assert_equal('Xfoo3', luaeval('bn.name')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
408 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
409 call assert_equal('Xfoo2', bufname('%')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
410 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
411 lua bn() |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
412 call assert_equal('Xfoo3', luaeval('vim.buffer().name')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
413 call assert_equal('Xfoo3', bufname('%')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
414 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
415 lua bp() |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
416 call assert_equal('Xfoo1', luaeval('vim.buffer().name')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
417 call assert_equal('Xfoo1', bufname('%')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
418 |
14239
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
419 lua bn, bp = nil |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
420 %bwipe! |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
421 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
422 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
423 " Test vim.buffer():isvalid() |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
424 func Test_lua_buffer_isvalid() |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
425 new Xfoo |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
426 lua b = vim.buffer() |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
427 call assert_true(luaeval('b:isvalid()')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
428 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
429 " FIXME: how to test the case when isvalid() returns v:false? |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
430 " isvalid() gives errors when the buffer is wiped. Is it a bug? |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
431 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
432 lua b = nil |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
433 bwipe! |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
434 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
435 |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
436 func Test_lua_list() |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
437 call assert_equal([], luaeval('vim.list()')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
438 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
439 let l = [] |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
440 lua l = vim.eval('l') |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
441 lua l:add(123) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
442 lua l:add('abc') |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
443 lua l:add(true) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
444 lua l:add(false) |
15328
f7130bc17248
patch 8.1.0672: the Lua interface doesn't know about v:null
Bram Moolenaar <Bram@vim.org>
parents:
14395
diff
changeset
|
445 lua l:add(nil) |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
446 lua l:add(vim.eval("[1, 2, 3]")) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
447 lua l:add(vim.eval("{'a':1, 'b':2, 'c':3}")) |
20441
86dde5c4b375
patch 8.2.0775: not easy to call a Vim function from Lua
Bram Moolenaar <Bram@vim.org>
parents:
20233
diff
changeset
|
448 call assert_equal([123, 'abc', v:true, v:false, v:null, [1, 2, 3], {'a': 1, 'b': 2, 'c': 3}], l) |
86dde5c4b375
patch 8.2.0775: not easy to call a Vim function from Lua
Bram Moolenaar <Bram@vim.org>
parents:
20233
diff
changeset
|
449 call assert_equal(7, luaeval('#l')) |
14245
f445c5edb6af
patch 8.1.0139: Lua tests fail on some platforms
Christian Brabandt <cb@256bit.org>
parents:
14239
diff
changeset
|
450 call assert_match('^list: \%(0x\)\?\x\+$', luaeval('tostring(l)')) |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
451 |
21030
08e284594211
patch 8.2.1066: Lua arrays are zero based
Bram Moolenaar <Bram@vim.org>
parents:
21006
diff
changeset
|
452 lua l[1] = 124 |
08e284594211
patch 8.2.1066: Lua arrays are zero based
Bram Moolenaar <Bram@vim.org>
parents:
21006
diff
changeset
|
453 lua l[6] = nil |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
454 lua l:insert('first') |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
455 lua l:insert('xx', 3) |
21108
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
456 call assert_fails('lua l:insert("xx", -20)', |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
457 \ '[string "vim chunk"]:1: invalid position') |
20441
86dde5c4b375
patch 8.2.0775: not easy to call a Vim function from Lua
Bram Moolenaar <Bram@vim.org>
parents:
20233
diff
changeset
|
458 call assert_equal(['first', 124, 'abc', 'xx', v:true, v:false, v:null, {'a': 1, 'b': 2, 'c': 3}], l) |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
459 |
14239
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
460 lockvar 1 l |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
461 call assert_fails('lua l:add("x")', '[string "vim chunk"]:1: list is locked') |
21108
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
462 call assert_fails('lua l:insert(2)', '[string "vim chunk"]:1: list is locked') |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
463 call assert_fails('lua l[9] = 1', '[string "vim chunk"]:1: list is locked') |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
464 |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
465 unlockvar l |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
466 let l = [1, 2] |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
467 lua ll = vim.eval('l') |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
468 let x = luaeval("ll[3]") |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
469 call assert_equal(v:null, x) |
27430
da3a39fd0964
patch 8.2.4243: Lua tests fail with Lua 5.4.4
Bram Moolenaar <Bram@vim.org>
parents:
25527
diff
changeset
|
470 if s:lua_543 |
24311
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
471 let msg = "[string \"luaeval\"]:1: method 'xyz' is not callable (a nil value)" |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
472 elseif s:lua_53_or_later |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
473 let msg = "[string \"luaeval\"]:1: attempt to call a nil value (method 'xyz')" |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
474 else |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
475 let msg = "[string \"luaeval\"]:1: attempt to call method 'xyz' (a nil value)" |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
476 endif |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
477 call assert_fails('let x = luaeval("ll:xyz(3)")', msg) |
21108
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
478 let y = luaeval("ll[{}]") |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
479 call assert_equal(v:null, y) |
14239
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
480 |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
481 lua l = nil |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
482 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
483 |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
484 func Test_lua_list_table() |
14239
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
485 " See :help lua-vim |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
486 " Non-numeric keys should not be used to initialize the list |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
487 " so say = 'hi' should be ignored. |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
488 lua t = {3.14, 'hello', false, true, say = 'hi'} |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
489 call assert_equal([3.14, 'hello', v:false, v:true], luaeval('vim.list(t)')) |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
490 lua t = nil |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
491 |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
492 call assert_fails('lua vim.list(1)', '[string "vim chunk"]:1: table expected, got number') |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
493 call assert_fails('lua vim.list("x")', '[string "vim chunk"]:1: table expected, got string') |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
494 call assert_fails('lua vim.list(print)', '[string "vim chunk"]:1: table expected, got function') |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
495 call assert_fails('lua vim.list(true)', '[string "vim chunk"]:1: table expected, got boolean') |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
496 endfunc |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
497 |
21060
89aba7895bb2
patch 8.2.1081: Lua: cannot use table.insert() and table.remove()
Bram Moolenaar <Bram@vim.org>
parents:
21030
diff
changeset
|
498 func Test_lua_list_table_insert_remove() |
21108
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
499 if !s:lua_53_or_later |
21060
89aba7895bb2
patch 8.2.1081: Lua: cannot use table.insert() and table.remove()
Bram Moolenaar <Bram@vim.org>
parents:
21030
diff
changeset
|
500 throw 'Skipped: Lua version < 5.3' |
89aba7895bb2
patch 8.2.1081: Lua: cannot use table.insert() and table.remove()
Bram Moolenaar <Bram@vim.org>
parents:
21030
diff
changeset
|
501 endif |
89aba7895bb2
patch 8.2.1081: Lua: cannot use table.insert() and table.remove()
Bram Moolenaar <Bram@vim.org>
parents:
21030
diff
changeset
|
502 |
24311
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
503 let l = [1, 2] |
21060
89aba7895bb2
patch 8.2.1081: Lua: cannot use table.insert() and table.remove()
Bram Moolenaar <Bram@vim.org>
parents:
21030
diff
changeset
|
504 lua t = vim.eval('l') |
89aba7895bb2
patch 8.2.1081: Lua: cannot use table.insert() and table.remove()
Bram Moolenaar <Bram@vim.org>
parents:
21030
diff
changeset
|
505 lua table.insert(t, 10) |
89aba7895bb2
patch 8.2.1081: Lua: cannot use table.insert() and table.remove()
Bram Moolenaar <Bram@vim.org>
parents:
21030
diff
changeset
|
506 lua t[#t + 1] = 20 |
89aba7895bb2
patch 8.2.1081: Lua: cannot use table.insert() and table.remove()
Bram Moolenaar <Bram@vim.org>
parents:
21030
diff
changeset
|
507 lua table.insert(t, 2, 30) |
89aba7895bb2
patch 8.2.1081: Lua: cannot use table.insert() and table.remove()
Bram Moolenaar <Bram@vim.org>
parents:
21030
diff
changeset
|
508 call assert_equal(l, [1, 30, 2, 10, 20]) |
89aba7895bb2
patch 8.2.1081: Lua: cannot use table.insert() and table.remove()
Bram Moolenaar <Bram@vim.org>
parents:
21030
diff
changeset
|
509 lua table.remove(t, 2) |
89aba7895bb2
patch 8.2.1081: Lua: cannot use table.insert() and table.remove()
Bram Moolenaar <Bram@vim.org>
parents:
21030
diff
changeset
|
510 call assert_equal(l, [1, 2, 10, 20]) |
89aba7895bb2
patch 8.2.1081: Lua: cannot use table.insert() and table.remove()
Bram Moolenaar <Bram@vim.org>
parents:
21030
diff
changeset
|
511 lua t[3] = nil |
89aba7895bb2
patch 8.2.1081: Lua: cannot use table.insert() and table.remove()
Bram Moolenaar <Bram@vim.org>
parents:
21030
diff
changeset
|
512 call assert_equal(l, [1, 2, 20]) |
89aba7895bb2
patch 8.2.1081: Lua: cannot use table.insert() and table.remove()
Bram Moolenaar <Bram@vim.org>
parents:
21030
diff
changeset
|
513 lua removed_value = table.remove(t, 3) |
89aba7895bb2
patch 8.2.1081: Lua: cannot use table.insert() and table.remove()
Bram Moolenaar <Bram@vim.org>
parents:
21030
diff
changeset
|
514 call assert_equal(luaeval('removed_value'), 20) |
89aba7895bb2
patch 8.2.1081: Lua: cannot use table.insert() and table.remove()
Bram Moolenaar <Bram@vim.org>
parents:
21030
diff
changeset
|
515 lua t = nil |
89aba7895bb2
patch 8.2.1081: Lua: cannot use table.insert() and table.remove()
Bram Moolenaar <Bram@vim.org>
parents:
21030
diff
changeset
|
516 lua removed_value = nil |
89aba7895bb2
patch 8.2.1081: Lua: cannot use table.insert() and table.remove()
Bram Moolenaar <Bram@vim.org>
parents:
21030
diff
changeset
|
517 unlet l |
89aba7895bb2
patch 8.2.1081: Lua: cannot use table.insert() and table.remove()
Bram Moolenaar <Bram@vim.org>
parents:
21030
diff
changeset
|
518 endfunc |
89aba7895bb2
patch 8.2.1081: Lua: cannot use table.insert() and table.remove()
Bram Moolenaar <Bram@vim.org>
parents:
21030
diff
changeset
|
519 |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
520 " Test l() i.e. iterator on list |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
521 func Test_lua_list_iter() |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
522 lua l = vim.list():add('foo'):add('bar') |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
523 lua str = '' |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
524 lua for v in l() do str = str .. v end |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
525 call assert_equal('foobar', luaeval('str')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
526 |
14239
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
527 lua str, l = nil |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
528 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
529 |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
530 func Test_lua_recursive_list() |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
531 lua l = vim.list():add(1):add(2) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
532 lua l = l:add(l) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
533 |
21030
08e284594211
patch 8.2.1066: Lua arrays are zero based
Bram Moolenaar <Bram@vim.org>
parents:
21006
diff
changeset
|
534 call assert_equal(1, luaeval('l[1]')) |
08e284594211
patch 8.2.1066: Lua arrays are zero based
Bram Moolenaar <Bram@vim.org>
parents:
21006
diff
changeset
|
535 call assert_equal(2, luaeval('l[2]')) |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
536 |
21030
08e284594211
patch 8.2.1066: Lua arrays are zero based
Bram Moolenaar <Bram@vim.org>
parents:
21006
diff
changeset
|
537 call assert_equal(1, luaeval('l[3][1]')) |
08e284594211
patch 8.2.1066: Lua arrays are zero based
Bram Moolenaar <Bram@vim.org>
parents:
21006
diff
changeset
|
538 call assert_equal(2, luaeval('l[3][2]')) |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
539 |
21030
08e284594211
patch 8.2.1066: Lua arrays are zero based
Bram Moolenaar <Bram@vim.org>
parents:
21006
diff
changeset
|
540 call assert_equal(1, luaeval('l[3][3][1]')) |
08e284594211
patch 8.2.1066: Lua arrays are zero based
Bram Moolenaar <Bram@vim.org>
parents:
21006
diff
changeset
|
541 call assert_equal(2, luaeval('l[3][3][2]')) |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
542 |
20441
86dde5c4b375
patch 8.2.0775: not easy to call a Vim function from Lua
Bram Moolenaar <Bram@vim.org>
parents:
20233
diff
changeset
|
543 call assert_equal('[1, 2, [...]]', string(luaeval('l'))) |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
544 |
14245
f445c5edb6af
patch 8.1.0139: Lua tests fail on some platforms
Christian Brabandt <cb@256bit.org>
parents:
14239
diff
changeset
|
545 call assert_match('^list: \%(0x\)\?\x\+$', luaeval('tostring(l)')) |
21030
08e284594211
patch 8.2.1066: Lua arrays are zero based
Bram Moolenaar <Bram@vim.org>
parents:
21006
diff
changeset
|
546 call assert_equal(luaeval('tostring(l)'), luaeval('tostring(l[3])')) |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
547 |
21030
08e284594211
patch 8.2.1066: Lua arrays are zero based
Bram Moolenaar <Bram@vim.org>
parents:
21006
diff
changeset
|
548 call assert_equal(luaeval('l'), luaeval('l[3]')) |
08e284594211
patch 8.2.1066: Lua arrays are zero based
Bram Moolenaar <Bram@vim.org>
parents:
21006
diff
changeset
|
549 call assert_equal(luaeval('l'), luaeval('l[3][3]')) |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
550 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
551 lua l = nil |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
552 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
553 |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
554 func Test_lua_dict() |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
555 call assert_equal({}, luaeval('vim.dict()')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
556 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
557 let d = {} |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
558 lua d = vim.eval('d') |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
559 lua d[0] = 123 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
560 lua d[1] = "abc" |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
561 lua d[2] = true |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
562 lua d[3] = false |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
563 lua d[4] = vim.eval("[1, 2, 3]") |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
564 lua d[5] = vim.eval("{'a':1, 'b':2, 'c':3}") |
20441
86dde5c4b375
patch 8.2.0775: not easy to call a Vim function from Lua
Bram Moolenaar <Bram@vim.org>
parents:
20233
diff
changeset
|
565 call assert_equal({'0':123, '1':'abc', '2':v:true, '3':v:false, '4': [1, 2, 3], '5': {'a':1, 'b':2, 'c':3}}, d) |
86dde5c4b375
patch 8.2.0775: not easy to call a Vim function from Lua
Bram Moolenaar <Bram@vim.org>
parents:
20233
diff
changeset
|
566 call assert_equal(6, luaeval('#d')) |
14245
f445c5edb6af
patch 8.1.0139: Lua tests fail on some platforms
Christian Brabandt <cb@256bit.org>
parents:
14239
diff
changeset
|
567 call assert_match('^dict: \%(0x\)\?\x\+$', luaeval('tostring(d)')) |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
568 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
569 call assert_equal('abc', luaeval('d[1]')) |
21108
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
570 call assert_equal(v:null, luaeval('d[22]')) |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
571 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
572 lua d[0] = 124 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
573 lua d[4] = nil |
20441
86dde5c4b375
patch 8.2.0775: not easy to call a Vim function from Lua
Bram Moolenaar <Bram@vim.org>
parents:
20233
diff
changeset
|
574 call assert_equal({'0':124, '1':'abc', '2':v:true, '3':v:false, '5': {'a':1, 'b':2, 'c':3}}, d) |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
575 |
14239
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
576 lockvar 1 d |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
577 call assert_fails('lua d[6] = 1', '[string "vim chunk"]:1: dict is locked') |
21108
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
578 unlockvar d |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
579 |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
580 " Error case |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
581 lua d = {} |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
582 lua d[''] = 10 |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
583 call assert_fails("let t = luaeval('vim.dict(d)')", |
21283
1d2c814f4bed
patch 8.2.1192: Lua test fails with older Lua version
Bram Moolenaar <Bram@vim.org>
parents:
21269
diff
changeset
|
584 \ s:lua_53_or_later |
1d2c814f4bed
patch 8.2.1192: Lua test fails with older Lua version
Bram Moolenaar <Bram@vim.org>
parents:
21269
diff
changeset
|
585 \ ? '[string "luaeval"]:1: table has empty key' |
1d2c814f4bed
patch 8.2.1192: Lua test fails with older Lua version
Bram Moolenaar <Bram@vim.org>
parents:
21269
diff
changeset
|
586 \ : 'table has empty key') |
21108
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
587 let d = {} |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
588 lua x = vim.eval('d') |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
589 call assert_fails("lua x[''] = 10", '[string "vim chunk"]:1: empty key') |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
590 lua x['a'] = nil |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
591 call assert_equal({}, d) |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
592 |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
593 " cannot assign funcrefs in the global scope |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
594 lua x = vim.eval('g:') |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
595 call assert_fails("lua x['min'] = vim.funcref('max')", |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
596 \ '[string "vim chunk"]:1: cannot assign funcref to builtin scope') |
14239
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
597 |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
598 lua d = nil |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
599 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
600 |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
601 func Test_lua_dict_table() |
14239
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
602 lua t = {key1 = 'x', key2 = 3.14, key3 = true, key4 = false} |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
603 call assert_equal({'key1': 'x', 'key2': 3.14, 'key3': v:true, 'key4': v:false}, |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
604 \ luaeval('vim.dict(t)')) |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
605 |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
606 " Same example as in :help lua-vim. |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
607 lua t = {math.pi, false, say = 'hi'} |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
608 " FIXME: commented out as it currently does not work as documented: |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
609 " Expected {'say': 'hi'} |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
610 " but got {'1': 3.141593, '2': v:false, 'say': 'hi'} |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
611 " Is the documentation or the code wrong? |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
612 "call assert_equal({'say' : 'hi'}, luaeval('vim.dict(t)')) |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
613 lua t = nil |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
614 |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
615 call assert_fails('lua vim.dict(1)', '[string "vim chunk"]:1: table expected, got number') |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
616 call assert_fails('lua vim.dict("x")', '[string "vim chunk"]:1: table expected, got string') |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
617 call assert_fails('lua vim.dict(print)', '[string "vim chunk"]:1: table expected, got function') |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
618 call assert_fails('lua vim.dict(true)', '[string "vim chunk"]:1: table expected, got boolean') |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
619 endfunc |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
620 |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
621 " Test d() i.e. iterator on dictionary |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
622 func Test_lua_dict_iter() |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
623 let d = {'a': 1, 'b':2} |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
624 lua d = vim.eval('d') |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
625 lua str = '' |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
626 lua for k,v in d() do str = str .. k ..':' .. v .. ',' end |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
627 call assert_equal('a:1,b:2,', luaeval('str')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
628 |
14239
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
629 lua str, d = nil |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
630 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
631 |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
632 func Test_lua_blob() |
16076
a2f0e93a5857
patch 8.1.1043: Lua interface does not support Blob
Bram Moolenaar <Bram@vim.org>
parents:
16028
diff
changeset
|
633 call assert_equal(0z, luaeval('vim.blob("")')) |
a2f0e93a5857
patch 8.1.1043: Lua interface does not support Blob
Bram Moolenaar <Bram@vim.org>
parents:
16028
diff
changeset
|
634 call assert_equal(0z31326162, luaeval('vim.blob("12ab")')) |
32721 | 635 call assert_equal(0z00010203, luaeval('vim.blob("\000\001\002\003")')) |
636 call assert_equal(0z8081FEFF, luaeval('vim.blob("\128\129\254\255")')) | |
16076
a2f0e93a5857
patch 8.1.1043: Lua interface does not support Blob
Bram Moolenaar <Bram@vim.org>
parents:
16028
diff
changeset
|
637 |
32721 | 638 lua b = vim.blob("\000\000\000\000") |
16076
a2f0e93a5857
patch 8.1.1043: Lua interface does not support Blob
Bram Moolenaar <Bram@vim.org>
parents:
16028
diff
changeset
|
639 call assert_equal(0z00000000, luaeval('b')) |
20441
86dde5c4b375
patch 8.2.0775: not easy to call a Vim function from Lua
Bram Moolenaar <Bram@vim.org>
parents:
20233
diff
changeset
|
640 call assert_equal(4, luaeval('#b')) |
16076
a2f0e93a5857
patch 8.1.1043: Lua interface does not support Blob
Bram Moolenaar <Bram@vim.org>
parents:
16028
diff
changeset
|
641 lua b[0], b[1], b[2], b[3] = 1, 32, 256, 0xff |
a2f0e93a5857
patch 8.1.1043: Lua interface does not support Blob
Bram Moolenaar <Bram@vim.org>
parents:
16028
diff
changeset
|
642 call assert_equal(0z012000ff, luaeval('b')) |
a2f0e93a5857
patch 8.1.1043: Lua interface does not support Blob
Bram Moolenaar <Bram@vim.org>
parents:
16028
diff
changeset
|
643 lua b[4] = string.byte("z", 1) |
a2f0e93a5857
patch 8.1.1043: Lua interface does not support Blob
Bram Moolenaar <Bram@vim.org>
parents:
16028
diff
changeset
|
644 call assert_equal(0z012000ff.7a, luaeval('b')) |
20441
86dde5c4b375
patch 8.2.0775: not easy to call a Vim function from Lua
Bram Moolenaar <Bram@vim.org>
parents:
20233
diff
changeset
|
645 call assert_equal(5, luaeval('#b')) |
16076
a2f0e93a5857
patch 8.1.1043: Lua interface does not support Blob
Bram Moolenaar <Bram@vim.org>
parents:
16028
diff
changeset
|
646 call assert_fails('lua b[#b+1] = 0x80', '[string "vim chunk"]:1: index out of range') |
a2f0e93a5857
patch 8.1.1043: Lua interface does not support Blob
Bram Moolenaar <Bram@vim.org>
parents:
16028
diff
changeset
|
647 lua b:add("12ab") |
a2f0e93a5857
patch 8.1.1043: Lua interface does not support Blob
Bram Moolenaar <Bram@vim.org>
parents:
16028
diff
changeset
|
648 call assert_equal(0z012000ff.7a313261.62, luaeval('b')) |
20441
86dde5c4b375
patch 8.2.0775: not easy to call a Vim function from Lua
Bram Moolenaar <Bram@vim.org>
parents:
20233
diff
changeset
|
649 call assert_equal(9, luaeval('#b')) |
16076
a2f0e93a5857
patch 8.1.1043: Lua interface does not support Blob
Bram Moolenaar <Bram@vim.org>
parents:
16028
diff
changeset
|
650 call assert_fails('lua b:add(nil)', '[string "vim chunk"]:1: string expected, got nil') |
a2f0e93a5857
patch 8.1.1043: Lua interface does not support Blob
Bram Moolenaar <Bram@vim.org>
parents:
16028
diff
changeset
|
651 call assert_fails('lua b:add(true)', '[string "vim chunk"]:1: string expected, got boolean') |
a2f0e93a5857
patch 8.1.1043: Lua interface does not support Blob
Bram Moolenaar <Bram@vim.org>
parents:
16028
diff
changeset
|
652 call assert_fails('lua b:add({})', '[string "vim chunk"]:1: string expected, got table') |
a2f0e93a5857
patch 8.1.1043: Lua interface does not support Blob
Bram Moolenaar <Bram@vim.org>
parents:
16028
diff
changeset
|
653 lua b = nil |
21108
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
654 |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
655 let b = 0z0102 |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
656 lua lb = vim.eval('b') |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
657 let n = luaeval('lb[1]') |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
658 call assert_equal(2, n) |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
659 let n = luaeval('lb[6]') |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
660 call assert_equal(v:null, n) |
27430
da3a39fd0964
patch 8.2.4243: Lua tests fail with Lua 5.4.4
Bram Moolenaar <Bram@vim.org>
parents:
25527
diff
changeset
|
661 if s:lua_543 |
24311
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
662 let msg = "[string \"luaeval\"]:1: method 'xyz' is not callable (a nil value)" |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
663 elseif s:lua_53_or_later |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
664 let msg = "[string \"luaeval\"]:1: attempt to call a nil value (method 'xyz')" |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
665 else |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
666 let msg = "[string \"luaeval\"]:1: attempt to call method 'xyz' (a nil value)" |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
667 endif |
e3d72ea162c3
patch 8.2.2696: Lua test fails with Lua 5.4.3 and later
Bram Moolenaar <Bram@vim.org>
parents:
24073
diff
changeset
|
668 call assert_fails('let x = luaeval("lb:xyz(3)")', msg) |
21108
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
669 let y = luaeval("lb[{}]") |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
670 call assert_equal(v:null, y) |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
671 |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
672 lockvar b |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
673 call assert_fails('lua lb[1] = 2', '[string "vim chunk"]:1: blob is locked') |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
674 call assert_fails('lua lb:add("12")', '[string "vim chunk"]:1: blob is locked') |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
675 |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
676 " Error cases |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
677 lua t = {} |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
678 call assert_fails('lua b = vim.blob(t)', |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
679 \ '[string "vim chunk"]:1: string expected, got table') |
16076
a2f0e93a5857
patch 8.1.1043: Lua interface does not support Blob
Bram Moolenaar <Bram@vim.org>
parents:
16028
diff
changeset
|
680 endfunc |
a2f0e93a5857
patch 8.1.1043: Lua interface does not support Blob
Bram Moolenaar <Bram@vim.org>
parents:
16028
diff
changeset
|
681 |
29196
e391590249a1
patch 8.2.5117: crash when calling a Lua callback from a :def function
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
682 def Vim9Test(Callback: func()) |
e391590249a1
patch 8.2.5117: crash when calling a Lua callback from a :def function
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
683 Callback() |
e391590249a1
patch 8.2.5117: crash when calling a Lua callback from a :def function
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
684 enddef |
e391590249a1
patch 8.2.5117: crash when calling a Lua callback from a :def function
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
685 |
e391590249a1
patch 8.2.5117: crash when calling a Lua callback from a :def function
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
686 func Test_call_lua_func_from_vim9_func() |
e391590249a1
patch 8.2.5117: crash when calling a Lua callback from a :def function
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
687 " this only tests that Vim doesn't crash |
e391590249a1
patch 8.2.5117: crash when calling a Lua callback from a :def function
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
688 lua << EOF |
e391590249a1
patch 8.2.5117: crash when calling a Lua callback from a :def function
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
689 vim.fn.Vim9Test(function () print('Hello') end) |
e391590249a1
patch 8.2.5117: crash when calling a Lua callback from a :def function
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
690 EOF |
e391590249a1
patch 8.2.5117: crash when calling a Lua callback from a :def function
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
691 endfunc |
e391590249a1
patch 8.2.5117: crash when calling a Lua callback from a :def function
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
692 |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
693 func Test_lua_funcref() |
14235
e3bc8cdc94dd
patch 8.1.0134: Lua interface does not support funcref
Christian Brabandt <cb@256bit.org>
parents:
14230
diff
changeset
|
694 function I(x) |
e3bc8cdc94dd
patch 8.1.0134: Lua interface does not support funcref
Christian Brabandt <cb@256bit.org>
parents:
14230
diff
changeset
|
695 return a:x |
e3bc8cdc94dd
patch 8.1.0134: Lua interface does not support funcref
Christian Brabandt <cb@256bit.org>
parents:
14230
diff
changeset
|
696 endfunction |
e3bc8cdc94dd
patch 8.1.0134: Lua interface does not support funcref
Christian Brabandt <cb@256bit.org>
parents:
14230
diff
changeset
|
697 let R = function('I') |
e3bc8cdc94dd
patch 8.1.0134: Lua interface does not support funcref
Christian Brabandt <cb@256bit.org>
parents:
14230
diff
changeset
|
698 lua i1 = vim.funcref"I" |
e3bc8cdc94dd
patch 8.1.0134: Lua interface does not support funcref
Christian Brabandt <cb@256bit.org>
parents:
14230
diff
changeset
|
699 lua i2 = vim.eval"R" |
e3bc8cdc94dd
patch 8.1.0134: Lua interface does not support funcref
Christian Brabandt <cb@256bit.org>
parents:
14230
diff
changeset
|
700 lua msg = "funcref|test|" .. (#i2(i1) == #i1(i2) and "OK" or "FAIL") |
e3bc8cdc94dd
patch 8.1.0134: Lua interface does not support funcref
Christian Brabandt <cb@256bit.org>
parents:
14230
diff
changeset
|
701 lua msg = vim.funcref"tr"(msg, "|", " ") |
e3bc8cdc94dd
patch 8.1.0134: Lua interface does not support funcref
Christian Brabandt <cb@256bit.org>
parents:
14230
diff
changeset
|
702 call assert_equal("funcref test OK", luaeval('msg')) |
e3bc8cdc94dd
patch 8.1.0134: Lua interface does not support funcref
Christian Brabandt <cb@256bit.org>
parents:
14230
diff
changeset
|
703 |
21108
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
704 " Error cases |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
705 call assert_fails('lua f1 = vim.funcref("")', |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
706 \ '[string "vim chunk"]:1: invalid function name: ') |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
707 call assert_fails('lua f1 = vim.funcref("10")', |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
708 \ '[string "vim chunk"]:1: invalid function name: 10') |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
709 let fname = test_null_string() |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
710 call assert_fails('lua f1 = vim.funcref(fname)', |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
711 \ "[string \"vim chunk\"]:1: bad argument #1 to 'funcref' (string expected, got nil)") |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
712 call assert_fails('lua vim.funcref("abc")()', |
21269
0a8322506058
patch 8.2.1185: some other tests fail
Bram Moolenaar <Bram@vim.org>
parents:
21108
diff
changeset
|
713 \ ['E117:', '\[string "vim chunk"]:1: cannot call funcref']) |
21108
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
714 |
14235
e3bc8cdc94dd
patch 8.1.0134: Lua interface does not support funcref
Christian Brabandt <cb@256bit.org>
parents:
14230
diff
changeset
|
715 " dict funcref |
e3bc8cdc94dd
patch 8.1.0134: Lua interface does not support funcref
Christian Brabandt <cb@256bit.org>
parents:
14230
diff
changeset
|
716 function Mylen() dict |
e3bc8cdc94dd
patch 8.1.0134: Lua interface does not support funcref
Christian Brabandt <cb@256bit.org>
parents:
14230
diff
changeset
|
717 return len(self.data) |
e3bc8cdc94dd
patch 8.1.0134: Lua interface does not support funcref
Christian Brabandt <cb@256bit.org>
parents:
14230
diff
changeset
|
718 endfunction |
e3bc8cdc94dd
patch 8.1.0134: Lua interface does not support funcref
Christian Brabandt <cb@256bit.org>
parents:
14230
diff
changeset
|
719 let l = [0, 1, 2, 3] |
e3bc8cdc94dd
patch 8.1.0134: Lua interface does not support funcref
Christian Brabandt <cb@256bit.org>
parents:
14230
diff
changeset
|
720 let mydict = {'data': l} |
e3bc8cdc94dd
patch 8.1.0134: Lua interface does not support funcref
Christian Brabandt <cb@256bit.org>
parents:
14230
diff
changeset
|
721 lua d = vim.eval"mydict" |
e3bc8cdc94dd
patch 8.1.0134: Lua interface does not support funcref
Christian Brabandt <cb@256bit.org>
parents:
14230
diff
changeset
|
722 lua d.len = vim.funcref"Mylen" -- assign d as 'self' |
e3bc8cdc94dd
patch 8.1.0134: Lua interface does not support funcref
Christian Brabandt <cb@256bit.org>
parents:
14230
diff
changeset
|
723 lua res = (d.len() == vim.funcref"len"(vim.eval"l")) and "OK" or "FAIL" |
e3bc8cdc94dd
patch 8.1.0134: Lua interface does not support funcref
Christian Brabandt <cb@256bit.org>
parents:
14230
diff
changeset
|
724 call assert_equal("OK", luaeval('res')) |
16028
8ad2cda3757d
patch 8.1.1019: Lua: may garbage collect function reference in use
Bram Moolenaar <Bram@vim.org>
parents:
15997
diff
changeset
|
725 call assert_equal(function('Mylen', {'data': l, 'len': function('Mylen')}), mydict.len) |
14239
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
726 |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
727 lua i1, i2, msg, d, res = nil |
14235
e3bc8cdc94dd
patch 8.1.0134: Lua interface does not support funcref
Christian Brabandt <cb@256bit.org>
parents:
14230
diff
changeset
|
728 endfunc |
e3bc8cdc94dd
patch 8.1.0134: Lua interface does not support funcref
Christian Brabandt <cb@256bit.org>
parents:
14230
diff
changeset
|
729 |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
730 " Test vim.type() |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
731 func Test_lua_type() |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
732 " The following values are identical to Lua's type function. |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
733 call assert_equal('string', luaeval('vim.type("foo")')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
734 call assert_equal('number', luaeval('vim.type(1)')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
735 call assert_equal('number', luaeval('vim.type(1.2)')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
736 call assert_equal('function', luaeval('vim.type(print)')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
737 call assert_equal('table', luaeval('vim.type({})')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
738 call assert_equal('boolean', luaeval('vim.type(true)')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
739 call assert_equal('boolean', luaeval('vim.type(false)')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
740 call assert_equal('nil', luaeval('vim.type(nil)')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
741 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
742 " The following values are specific to Vim. |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
743 call assert_equal('window', luaeval('vim.type(vim.window())')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
744 call assert_equal('buffer', luaeval('vim.type(vim.buffer())')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
745 call assert_equal('list', luaeval('vim.type(vim.list())')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
746 call assert_equal('dict', luaeval('vim.type(vim.dict())')) |
14235
e3bc8cdc94dd
patch 8.1.0134: Lua interface does not support funcref
Christian Brabandt <cb@256bit.org>
parents:
14230
diff
changeset
|
747 call assert_equal('funcref', luaeval('vim.type(vim.funcref("Test_type"))')) |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
748 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
749 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
750 " Test vim.open() |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
751 func Test_lua_open() |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
752 call assert_notmatch('XOpen', execute('ls')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
753 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
754 " Open a buffer XOpen1, but do not jump to it. |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
755 lua b = vim.open('XOpen1') |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
756 call assert_equal('XOpen1', luaeval('b.name')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
757 call assert_equal('', bufname('%')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
758 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
759 call assert_match('XOpen1', execute('ls')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
760 call assert_notequal('XOpen2', bufname('%')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
761 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
762 " Open a buffer XOpen2 and jump to it. |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
763 lua b = vim.open('XOpen2')() |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
764 call assert_equal('XOpen2', luaeval('b.name')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
765 call assert_equal('XOpen2', bufname('%')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
766 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
767 lua b = nil |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
768 %bwipe! |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
769 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
770 |
20609
054ba681412d
patch 8.2.0858: not easy to require Lua modules
Bram Moolenaar <Bram@vim.org>
parents:
20441
diff
changeset
|
771 func Test_update_package_paths() |
054ba681412d
patch 8.2.0858: not easy to require Lua modules
Bram Moolenaar <Bram@vim.org>
parents:
20441
diff
changeset
|
772 set runtimepath+=./testluaplugin |
054ba681412d
patch 8.2.0858: not easy to require Lua modules
Bram Moolenaar <Bram@vim.org>
parents:
20441
diff
changeset
|
773 call assert_equal("hello from lua", luaeval("require('testluaplugin').hello()")) |
054ba681412d
patch 8.2.0858: not easy to require Lua modules
Bram Moolenaar <Bram@vim.org>
parents:
20441
diff
changeset
|
774 endfunc |
054ba681412d
patch 8.2.0858: not easy to require Lua modules
Bram Moolenaar <Bram@vim.org>
parents:
20441
diff
changeset
|
775 |
21006
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
776 func Vim_func_call_lua_callback(Concat, Cb) |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
777 let l:message = a:Concat("hello", "vim") |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
778 call a:Cb(l:message) |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
779 endfunc |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
780 |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
781 func Test_pass_lua_callback_to_vim_from_lua() |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
782 lua pass_lua_callback_to_vim_from_lua_result = "" |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
783 call assert_equal("", luaeval("pass_lua_callback_to_vim_from_lua_result")) |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
784 lua <<EOF |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
785 vim.funcref('Vim_func_call_lua_callback')( |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
786 function(greeting, message) |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
787 return greeting .. " " .. message |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
788 end, |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
789 function(message) |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
790 pass_lua_callback_to_vim_from_lua_result = message |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
791 end) |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
792 EOF |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
793 call assert_equal("hello vim", luaeval("pass_lua_callback_to_vim_from_lua_result")) |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
794 endfunc |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
795 |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
796 func Vim_func_call_metatable_lua_callback(Greet) |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
797 return a:Greet("world") |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
798 endfunc |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
799 |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
800 func Test_pass_lua_metatable_callback_to_vim_from_lua() |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
801 let result = luaeval("vim.funcref('Vim_func_call_metatable_lua_callback')(setmetatable({ space = ' '}, { __call = function(tbl, msg) return 'hello' .. tbl.space .. msg end }) )") |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
802 call assert_equal("hello world", result) |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
803 endfunc |
ae185f35e256
patch 8.2.1054: not so easy to pass a lua function to Vim
Bram Moolenaar <Bram@vim.org>
parents:
20609
diff
changeset
|
804 |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
805 " Test vim.line() |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
806 func Test_lua_line() |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
807 new |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
808 call setline(1, ['first line', 'second line']) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
809 1 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
810 call assert_equal('first line', luaeval('vim.line()')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
811 2 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
812 call assert_equal('second line', luaeval('vim.line()')) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
813 bwipe! |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
814 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
815 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
816 " Test vim.beep() |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
817 func Test_lua_beep() |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
818 call assert_beeps('lua vim.beep()') |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
819 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
820 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
821 " Test errors in luaeval() |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
822 func Test_luaeval_error() |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
823 " Compile error |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
824 call assert_fails("call luaeval('-nil')", |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
825 \ '[string "luaeval"]:1: attempt to perform arithmetic on a nil value') |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
826 call assert_fails("call luaeval(']')", |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
827 \ "[string \"luaeval\"]:1: unexpected symbol near ']'") |
21108
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
828 lua co = coroutine.create(function () print("hi") end) |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
829 call assert_fails('let i = luaeval("co")', 'luaeval: cannot convert value') |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
830 lua co = nil |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
831 call assert_fails('let m = luaeval("{}")', 'luaeval: cannot convert value') |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
832 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
833 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
834 " Test :luafile foo.lua |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
835 func Test_luafile() |
30580
f08ed0738f7a
patch 9.0.0625: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents:
30310
diff
changeset
|
836 call writefile(["str = 'hello'", "num = 123" ], 'Xlua_file', 'D') |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
837 call setfperm('Xlua_file', 'r-xr-xr-x') |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
838 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
839 luafile Xlua_file |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
840 call assert_equal('hello', luaeval('str')) |
20441
86dde5c4b375
patch 8.2.0775: not easy to call a Vim function from Lua
Bram Moolenaar <Bram@vim.org>
parents:
20233
diff
changeset
|
841 call assert_equal(123, luaeval('num')) |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
842 |
14239
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
843 lua str, num = nil |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
844 endfunc |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
845 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
846 " Test :luafile % |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
847 func Test_luafile_percent() |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
848 new Xlua_file |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
849 append |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
850 str, num = 'foo', 321.0 |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
851 print(string.format('str=%s, num=%d', str, num)) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
852 . |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
853 w! |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
854 luafile % |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
855 let msg = split(execute('message'), "\n")[-1] |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
856 call assert_equal('str=foo, num=321', msg) |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
857 |
14239
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
858 lua str, num = nil |
14230
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
859 call delete('Xlua_file') |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
860 bwipe! |
2e95ea9afa1e
patch 8.1.0132: lua tests are old style
Christian Brabandt <cb@256bit.org>
parents:
10757
diff
changeset
|
861 endfunc |
14239
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
862 |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
863 " Test :luafile with syntax error |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
864 func Test_luafile_error() |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
865 new Xlua_file |
30580
f08ed0738f7a
patch 9.0.0625: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents:
30310
diff
changeset
|
866 call writefile(['nil = 0' ], 'Xlua_file', 'D') |
14239
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
867 call setfperm('Xlua_file', 'r-xr-xr-x') |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
868 |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
869 call assert_fails('luafile Xlua_file', "Xlua_file:1: unexpected symbol near 'nil'") |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
870 |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
871 bwipe! |
7457bf2db968
patch 8.1.0136: Lua tests don't cover new features
Christian Brabandt <cb@256bit.org>
parents:
14235
diff
changeset
|
872 endfunc |
14395
c15bef307de6
patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents:
14296
diff
changeset
|
873 |
25394
3a8b61b31724
patch 8.2.3234: crash when printing long string with Lua
Bram Moolenaar <Bram@vim.org>
parents:
24385
diff
changeset
|
874 " Test :luafile printing a long string |
3a8b61b31724
patch 8.2.3234: crash when printing long string with Lua
Bram Moolenaar <Bram@vim.org>
parents:
24385
diff
changeset
|
875 func Test_luafile_print() |
3a8b61b31724
patch 8.2.3234: crash when printing long string with Lua
Bram Moolenaar <Bram@vim.org>
parents:
24385
diff
changeset
|
876 new Xlua_file |
3a8b61b31724
patch 8.2.3234: crash when printing long string with Lua
Bram Moolenaar <Bram@vim.org>
parents:
24385
diff
changeset
|
877 let lines =<< trim END |
3a8b61b31724
patch 8.2.3234: crash when printing long string with Lua
Bram Moolenaar <Bram@vim.org>
parents:
24385
diff
changeset
|
878 local data = '' |
3a8b61b31724
patch 8.2.3234: crash when printing long string with Lua
Bram Moolenaar <Bram@vim.org>
parents:
24385
diff
changeset
|
879 for i = 1, 130 do |
3a8b61b31724
patch 8.2.3234: crash when printing long string with Lua
Bram Moolenaar <Bram@vim.org>
parents:
24385
diff
changeset
|
880 data = data .. 'xxxxx asd as as dad sad sad xz cxz czxcxzczxc ad ad asd asd asd asd asd' |
3a8b61b31724
patch 8.2.3234: crash when printing long string with Lua
Bram Moolenaar <Bram@vim.org>
parents:
24385
diff
changeset
|
881 end |
3a8b61b31724
patch 8.2.3234: crash when printing long string with Lua
Bram Moolenaar <Bram@vim.org>
parents:
24385
diff
changeset
|
882 print(data) |
3a8b61b31724
patch 8.2.3234: crash when printing long string with Lua
Bram Moolenaar <Bram@vim.org>
parents:
24385
diff
changeset
|
883 END |
3a8b61b31724
patch 8.2.3234: crash when printing long string with Lua
Bram Moolenaar <Bram@vim.org>
parents:
24385
diff
changeset
|
884 call setline(1, lines) |
3a8b61b31724
patch 8.2.3234: crash when printing long string with Lua
Bram Moolenaar <Bram@vim.org>
parents:
24385
diff
changeset
|
885 w |
3a8b61b31724
patch 8.2.3234: crash when printing long string with Lua
Bram Moolenaar <Bram@vim.org>
parents:
24385
diff
changeset
|
886 luafile % |
3a8b61b31724
patch 8.2.3234: crash when printing long string with Lua
Bram Moolenaar <Bram@vim.org>
parents:
24385
diff
changeset
|
887 |
3a8b61b31724
patch 8.2.3234: crash when printing long string with Lua
Bram Moolenaar <Bram@vim.org>
parents:
24385
diff
changeset
|
888 call delete('Xlua_file') |
3a8b61b31724
patch 8.2.3234: crash when printing long string with Lua
Bram Moolenaar <Bram@vim.org>
parents:
24385
diff
changeset
|
889 bwipe! |
3a8b61b31724
patch 8.2.3234: crash when printing long string with Lua
Bram Moolenaar <Bram@vim.org>
parents:
24385
diff
changeset
|
890 endfunc |
3a8b61b31724
patch 8.2.3234: crash when printing long string with Lua
Bram Moolenaar <Bram@vim.org>
parents:
24385
diff
changeset
|
891 |
21108
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
892 " Test for dealing with strings containing newlines and null character |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
893 func Test_lua_string_with_newline() |
25407
241d26b17192
patch 8.2.3240: Lua print() does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
25394
diff
changeset
|
894 let x = execute('lua print("Hello\nWorld", 2)') |
241d26b17192
patch 8.2.3240: Lua print() does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
25394
diff
changeset
|
895 call assert_equal("\nHello\nWorld 2", x) |
21108
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
896 new |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
897 lua k = vim.buffer(vim.eval('bufnr()')) |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
898 lua k:insert("Hello\0World", 0) |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
899 call assert_equal(["Hello\nWorld", ''], getline(1, '$')) |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
900 close! |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
901 endfunc |
43e82e8133b9
patch 8.2.1105: insufficient test coverage for Lua
Bram Moolenaar <Bram@vim.org>
parents:
21060
diff
changeset
|
902 |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17916
diff
changeset
|
903 func Test_lua_set_cursor() |
14395
c15bef307de6
patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents:
14296
diff
changeset
|
904 " Check that setting the cursor position works. |
c15bef307de6
patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents:
14296
diff
changeset
|
905 new |
c15bef307de6
patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents:
14296
diff
changeset
|
906 call setline(1, ['first line', 'second line']) |
c15bef307de6
patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents:
14296
diff
changeset
|
907 normal gg |
20045
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
908 lua << trim EOF |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
909 w = vim.window() |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
910 w.line = 1 |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
911 w.col = 5 |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
912 EOF |
14395
c15bef307de6
patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents:
14296
diff
changeset
|
913 call assert_equal([1, 5], [line('.'), col('.')]) |
c15bef307de6
patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents:
14296
diff
changeset
|
914 |
c15bef307de6
patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents:
14296
diff
changeset
|
915 " Check that movement after setting cursor position keeps current column. |
c15bef307de6
patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents:
14296
diff
changeset
|
916 normal j |
c15bef307de6
patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents:
14296
diff
changeset
|
917 call assert_equal([2, 5], [line('.'), col('.')]) |
c15bef307de6
patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents:
14296
diff
changeset
|
918 endfunc |
20045
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
919 |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
920 " Test for various heredoc syntax |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
921 func Test_lua_heredoc() |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
922 lua << END |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
923 vim.command('let s = "A"') |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
924 END |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
925 lua << |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
926 vim.command('let s ..= "B"') |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
927 . |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
928 lua << trim END |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
929 vim.command('let s ..= "C"') |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
930 END |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
931 lua << trim |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
932 vim.command('let s ..= "D"') |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
933 . |
20233
5f9c2c7d3d73
patch 8.2.0672: heredoc in scripts does not accept lower case marker
Bram Moolenaar <Bram@vim.org>
parents:
20045
diff
changeset
|
934 lua << trim eof |
5f9c2c7d3d73
patch 8.2.0672: heredoc in scripts does not accept lower case marker
Bram Moolenaar <Bram@vim.org>
parents:
20045
diff
changeset
|
935 vim.command('let s ..= "E"') |
5f9c2c7d3d73
patch 8.2.0672: heredoc in scripts does not accept lower case marker
Bram Moolenaar <Bram@vim.org>
parents:
20045
diff
changeset
|
936 eof |
5f9c2c7d3d73
patch 8.2.0672: heredoc in scripts does not accept lower case marker
Bram Moolenaar <Bram@vim.org>
parents:
20045
diff
changeset
|
937 call assert_equal('ABCDE', s) |
20045
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
938 endfunc |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
939 |
25503
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
940 " Test for adding, accessing and removing global variables using the vim.g |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
941 " Lua table |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
942 func Test_lua_global_var_table() |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
943 " Access global variables with different types of values |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
944 let g:Var1 = 10 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
945 let g:Var2 = 'Hello' |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
946 let g:Var3 = ['a', 'b'] |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
947 let g:Var4 = #{x: 'edit', y: 'run'} |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
948 let g:Var5 = function('min') |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
949 call assert_equal(10, luaeval('vim.g.Var1')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
950 call assert_equal('Hello', luaeval('vim.g.Var2')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
951 call assert_equal(['a', 'b'], luaeval('vim.g.Var3')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
952 call assert_equal(#{x: 'edit', y: 'run'}, luaeval('vim.g.Var4')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
953 call assert_equal(2, luaeval('vim.g.Var5')([5, 9, 2])) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
954 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
955 " Access list of dictionaries and dictionary of lists |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
956 let g:Var1 = [#{a: 10}, #{b: 20}] |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
957 let g:Var2 = #{p: [5, 6], q: [1.1, 2.2]} |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
958 call assert_equal([#{a: 10}, #{b: 20}], luaeval('vim.g.Var1')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
959 call assert_equal(#{p: [5, 6], q: [1.1, 2.2]}, luaeval('vim.g.Var2')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
960 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
961 " Create new global variables with different types of values |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
962 unlet g:Var1 g:Var2 g:Var3 g:Var4 g:Var5 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
963 lua << trim END |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
964 vim.g.Var1 = 34 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
965 vim.g.Var2 = 'World' |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
966 vim.g.Var3 = vim.list({'#', '$'}) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
967 vim.g.Var4 = vim.dict({model='honda', year=2020}) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
968 vim.g.Var5 = vim.funcref('max') |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
969 END |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
970 call assert_equal(34, g:Var1) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
971 call assert_equal('World', g:Var2) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
972 call assert_equal(['#', '$'], g:Var3) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
973 call assert_equal(#{model: 'honda', year: 2020}, g:Var4) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
974 call assert_equal(10, g:Var5([5, 10, 9])) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
975 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
976 " Create list of dictionaries and dictionary of lists |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
977 unlet g:Var1 g:Var2 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
978 lua << trim END |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
979 vim.g.Var1 = vim.list({vim.dict({a=10}), vim.dict({b=20})}) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
980 vim.g.Var2 = vim.dict({p=vim.list({5, 6}), q=vim.list({1.1, 2.2})}) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
981 END |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
982 call assert_equal([#{a: 10}, #{b: 20}], luaeval('vim.g.Var1')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
983 call assert_equal(#{p: [5, 6], q: [1.1, 2.2]}, luaeval('vim.g.Var2')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
984 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
985 " Modify a global variable with a list value or a dictionary value |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
986 let g:Var1 = [10, 20] |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
987 let g:Var2 = #{one: 'mercury', two: 'mars'} |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
988 lua << trim END |
33339
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
989 vim.g.Var1[2] = nil |
25503
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
990 vim.g.Var1[3] = 15 |
33339
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
991 vim.g.Var2['two'] = nil |
25503
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
992 vim.g.Var2['three'] = 'earth' |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
993 END |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
994 call assert_equal([10, 15], g:Var1) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
995 call assert_equal(#{one: 'mercury', three: 'earth'}, g:Var2) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
996 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
997 " Remove global variables with different types of values |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
998 let g:Var1 = 10 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
999 let g:Var2 = 'Hello' |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1000 let g:Var3 = ['a', 'b'] |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1001 let g:Var4 = #{x: 'edit', y: 'run'} |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1002 let g:Var5 = function('min') |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1003 lua << trim END |
33339
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1004 vim.g.Var1 = nil |
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1005 vim.g.Var2 = nil |
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1006 vim.g.Var3 = nil |
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1007 vim.g.Var4 = nil |
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1008 vim.g.Var5 = nil |
25503
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1009 END |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1010 call assert_false(exists('g:Var1')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1011 call assert_false(exists('g:Var2')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1012 call assert_false(exists('g:Var3')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1013 call assert_false(exists('g:Var4')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1014 call assert_false(exists('g:Var5')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1015 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1016 " Try to modify and remove a locked global variable |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1017 let g:Var1 = 10 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1018 lockvar g:Var1 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1019 call assert_fails('lua vim.g.Var1 = 20', 'variable is locked') |
33339
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1020 call assert_fails('lua vim.g.Var1 = nil', 'variable is locked') |
25503
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1021 unlockvar g:Var1 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1022 let g:Var2 = [7, 14] |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1023 lockvar 0 g:Var2 |
33339
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1024 lua vim.g.Var2[2] = nil |
25503
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1025 lua vim.g.Var2[3] = 21 |
33339
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1026 call assert_fails('lua vim.g.Var2 = nil', 'variable is locked') |
25503
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1027 call assert_equal([7, 21], g:Var2) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1028 lockvar 1 g:Var2 |
33339
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1029 call assert_fails('lua vim.g.Var2[2] = nil', 'list is locked') |
25503
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1030 call assert_fails('lua vim.g.Var2[3] = 21', 'list is locked') |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1031 unlockvar g:Var2 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1032 |
25509
7ed54019fbb8
patch 8.2.3291: Coverity warns for not checking return value
Bram Moolenaar <Bram@vim.org>
parents:
25503
diff
changeset
|
1033 let g:TestFunc = function('len') |
7ed54019fbb8
patch 8.2.3291: Coverity warns for not checking return value
Bram Moolenaar <Bram@vim.org>
parents:
25503
diff
changeset
|
1034 call assert_fails('lua vim.g.func = vim.g.TestFunc', ['E704:', 'Couldn''t add to dictionary']) |
7ed54019fbb8
patch 8.2.3291: Coverity warns for not checking return value
Bram Moolenaar <Bram@vim.org>
parents:
25503
diff
changeset
|
1035 unlet g:TestFunc |
7ed54019fbb8
patch 8.2.3291: Coverity warns for not checking return value
Bram Moolenaar <Bram@vim.org>
parents:
25503
diff
changeset
|
1036 |
25503
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1037 " Attempt to access a non-existing global variable |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1038 call assert_equal(v:null, luaeval('vim.g.NonExistingVar')) |
33339
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1039 lua vim.g.NonExisting = nil |
25503
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1040 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1041 unlet! g:Var1 g:Var2 g:Var3 g:Var4 g:Var5 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1042 endfunc |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1043 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1044 " Test for accessing and modifying predefined vim variables using the vim.v |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1045 " Lua table |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1046 func Test_lua_predefined_var_table() |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1047 call assert_equal(v:progpath, luaeval('vim.v.progpath')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1048 let v:errmsg = 'SomeError' |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1049 call assert_equal('SomeError', luaeval('vim.v.errmsg')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1050 lua vim.v.errmsg = 'OtherError' |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1051 call assert_equal('OtherError', v:errmsg) |
33339
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1052 lua vim.v.errmsg = 42 |
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1053 call assert_equal('42', v:errmsg) |
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1054 call assert_fails('lua vim.v.errmsg = nil', 'variable is fixed') |
25503
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1055 let v:oldfiles = ['one', 'two'] |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1056 call assert_equal(['one', 'two'], luaeval('vim.v.oldfiles')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1057 lua vim.v.oldfiles = vim.list({}) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1058 call assert_equal([], v:oldfiles) |
33339
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1059 call assert_fails('lua vim.v.oldfiles = "a"', |
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1060 \ 'Setting v:oldfiles to value with wrong type') |
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1061 call assert_equal([], v:oldfiles) |
25503
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1062 call assert_equal(v:null, luaeval('vim.v.null')) |
33339
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1063 call assert_fails('lua vim.v.argv[1] = nil', 'list is locked') |
25503
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1064 call assert_fails('lua vim.v.newvar = 1', 'Dictionary is locked') |
33339
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1065 |
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1066 new |
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1067 call setline(1, ' foo foo foo') |
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1068 /foo |
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1069 call assert_equal([0, 1, 2, 0, 2], getcurpos()) |
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1070 call assert_equal(1, v:searchforward) |
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1071 normal! n |
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1072 call assert_equal([0, 1, 6, 0, 6], getcurpos()) |
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1073 lua vim.v.searchforward = 0 |
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1074 call assert_equal(0, v:searchforward) |
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1075 normal! n |
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1076 call assert_equal([0, 1, 2, 0, 2], getcurpos()) |
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1077 lua vim.v.searchforward = 1 |
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1078 call assert_equal(1, v:searchforward) |
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1079 normal! n |
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1080 call assert_equal([0, 1, 6, 0, 6], getcurpos()) |
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1081 bwipe! |
25503
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1082 endfunc |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1083 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1084 " Test for adding, accessing and modifying window-local variables using the |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1085 " vim.w Lua table |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1086 func Test_lua_window_var_table() |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1087 " Access window variables with different types of values |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1088 new |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1089 let w:wvar1 = 10 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1090 let w:wvar2 = 'edit' |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1091 let w:wvar3 = 3.14 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1092 let w:wvar4 = 0zdeadbeef |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1093 let w:wvar5 = ['a', 'b'] |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1094 let w:wvar6 = #{action: 'run'} |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1095 call assert_equal(10, luaeval('vim.w.wvar1')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1096 call assert_equal('edit', luaeval('vim.w.wvar2')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1097 call assert_equal(3.14, luaeval('vim.w.wvar3')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1098 call assert_equal(0zdeadbeef, luaeval('vim.w.wvar4')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1099 call assert_equal(['a', 'b'], luaeval('vim.w.wvar5')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1100 call assert_equal(#{action: 'run'}, luaeval('vim.w.wvar6')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1101 call assert_equal(v:null, luaeval('vim.w.NonExisting')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1102 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1103 " modify a window variable |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1104 lua vim.w.wvar2 = 'paste' |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1105 call assert_equal('paste', w:wvar2) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1106 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1107 " change the type stored in a variable |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1108 let w:wvar2 = [1, 2] |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1109 lua vim.w.wvar2 = vim.dict({a=10, b=20}) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1110 call assert_equal(#{a: 10, b: 20}, w:wvar2) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1111 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1112 " create a new window variable |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1113 lua vim.w.wvar7 = vim.dict({a=vim.list({1, 2}), b=20}) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1114 call assert_equal(#{a: [1, 2], b: 20}, w:wvar7) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1115 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1116 " delete a window variable |
33339
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1117 lua vim.w.wvar2 = nil |
25503
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1118 call assert_false(exists('w:wvar2')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1119 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1120 new |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1121 call assert_equal(v:null, luaeval('vim.w.wvar1')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1122 call assert_equal(v:null, luaeval('vim.w.wvar2')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1123 %bw! |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1124 endfunc |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1125 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1126 " Test for adding, accessing and modifying buffer-local variables using the |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1127 " vim.b Lua table |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1128 func Test_lua_buffer_var_table() |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1129 " Access buffer variables with different types of values |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1130 let b:bvar1 = 10 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1131 let b:bvar2 = 'edit' |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1132 let b:bvar3 = 3.14 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1133 let b:bvar4 = 0zdeadbeef |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1134 let b:bvar5 = ['a', 'b'] |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1135 let b:bvar6 = #{action: 'run'} |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1136 call assert_equal(10, luaeval('vim.b.bvar1')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1137 call assert_equal('edit', luaeval('vim.b.bvar2')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1138 call assert_equal(3.14, luaeval('vim.b.bvar3')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1139 call assert_equal(0zdeadbeef, luaeval('vim.b.bvar4')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1140 call assert_equal(['a', 'b'], luaeval('vim.b.bvar5')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1141 call assert_equal(#{action: 'run'}, luaeval('vim.b.bvar6')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1142 call assert_equal(v:null, luaeval('vim.b.NonExisting')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1143 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1144 " modify a buffer variable |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1145 lua vim.b.bvar2 = 'paste' |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1146 call assert_equal('paste', b:bvar2) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1147 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1148 " change the type stored in a variable |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1149 let b:bvar2 = [1, 2] |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1150 lua vim.b.bvar2 = vim.dict({a=10, b=20}) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1151 call assert_equal(#{a: 10, b: 20}, b:bvar2) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1152 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1153 " create a new buffer variable |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1154 lua vim.b.bvar7 = vim.dict({a=vim.list({1, 2}), b=20}) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1155 call assert_equal(#{a: [1, 2], b: 20}, b:bvar7) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1156 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1157 " delete a buffer variable |
33339
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1158 lua vim.b.bvar2 = nil |
25503
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1159 call assert_false(exists('b:bvar2')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1160 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1161 new |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1162 call assert_equal(v:null, luaeval('vim.b.bvar1')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1163 call assert_equal(v:null, luaeval('vim.b.bvar2')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1164 %bw! |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1165 endfunc |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1166 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1167 " Test for adding, accessing and modifying tabpage-local variables using the |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1168 " vim.t Lua table |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1169 func Test_lua_tabpage_var_table() |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1170 " Access tabpage variables with different types of values |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1171 let t:tvar1 = 10 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1172 let t:tvar2 = 'edit' |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1173 let t:tvar3 = 3.14 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1174 let t:tvar4 = 0zdeadbeef |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1175 let t:tvar5 = ['a', 'b'] |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1176 let t:tvar6 = #{action: 'run'} |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1177 call assert_equal(10, luaeval('vim.t.tvar1')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1178 call assert_equal('edit', luaeval('vim.t.tvar2')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1179 call assert_equal(3.14, luaeval('vim.t.tvar3')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1180 call assert_equal(0zdeadbeef, luaeval('vim.t.tvar4')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1181 call assert_equal(['a', 'b'], luaeval('vim.t.tvar5')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1182 call assert_equal(#{action: 'run'}, luaeval('vim.t.tvar6')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1183 call assert_equal(v:null, luaeval('vim.t.NonExisting')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1184 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1185 " modify a tabpage variable |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1186 lua vim.t.tvar2 = 'paste' |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1187 call assert_equal('paste', t:tvar2) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1188 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1189 " change the type stored in a variable |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1190 let t:tvar2 = [1, 2] |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1191 lua vim.t.tvar2 = vim.dict({a=10, b=20}) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1192 call assert_equal(#{a: 10, b: 20}, t:tvar2) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1193 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1194 " create a new tabpage variable |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1195 lua vim.t.tvar7 = vim.dict({a=vim.list({1, 2}), b=20}) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1196 call assert_equal(#{a: [1, 2], b: 20}, t:tvar7) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1197 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1198 " delete a tabpage variable |
33339
441ceb1c45c1
patch 9.0.1933: Can change the type of a v: variable using if_lua
Christian Brabandt <cb@256bit.org>
parents:
32807
diff
changeset
|
1199 lua vim.t.tvar2 = nil |
25503
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1200 call assert_false(exists('t:tvar2')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1201 |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1202 tabnew |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1203 call assert_equal(v:null, luaeval('vim.t.tvar1')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1204 call assert_equal(v:null, luaeval('vim.t.tvar2')) |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1205 %bw! |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1206 endfunc |
9947b7e4b319
patch 8.2.3288: cannot easily access namespace dictionaries from Lua
Bram Moolenaar <Bram@vim.org>
parents:
25407
diff
changeset
|
1207 |
25527
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1208 " Test for vim.version() |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1209 func Test_lua_vim_version() |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1210 lua << trim END |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1211 vimver = vim.version() |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1212 vimver_n = vimver.major * 100 + vimver.minor |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1213 END |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1214 call assert_equal(v:version, luaeval('vimver_n')) |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1215 endfunc |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1216 |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1217 " Test for running multiple commands using vim.command() |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1218 func Test_lua_multiple_commands() |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1219 lua << trim END |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1220 vim.command([[ |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1221 let Var1 = [] |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1222 for i in range(3) |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1223 let Var1 += [#{name: 'x'}] |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1224 endfor |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1225 augroup Luagroup |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1226 autocmd! |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1227 autocmd User Luatest echo 'Hello' |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1228 augroup END |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1229 ]]) |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1230 END |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1231 call assert_equal([{'name': 'x'}, {'name': 'x'}, {'name': 'x'}], Var1) |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1232 call assert_true(exists('#Luagroup')) |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1233 call assert_true(exists('#Luagroup#User#Luatest')) |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1234 augroup Luagroup |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1235 autocmd! |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1236 augroup END |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1237 augroup! Luagroup |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1238 endfunc |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25509
diff
changeset
|
1239 |
28146
483a8d6cf8b0
patch 8.2.4597: LuaV_debug() not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27430
diff
changeset
|
1240 func Test_lua_debug() |
483a8d6cf8b0
patch 8.2.4597: LuaV_debug() not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27430
diff
changeset
|
1241 CheckRunVimInTerminal |
483a8d6cf8b0
patch 8.2.4597: LuaV_debug() not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27430
diff
changeset
|
1242 |
483a8d6cf8b0
patch 8.2.4597: LuaV_debug() not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27430
diff
changeset
|
1243 let buf = RunVimInTerminal('', {'rows': 10}) |
483a8d6cf8b0
patch 8.2.4597: LuaV_debug() not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27430
diff
changeset
|
1244 call term_sendkeys(buf, ":lua debug.debug()\n") |
483a8d6cf8b0
patch 8.2.4597: LuaV_debug() not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27430
diff
changeset
|
1245 call WaitForAssert({-> assert_equal('lua_debug> ', term_getline(buf, 10))}) |
483a8d6cf8b0
patch 8.2.4597: LuaV_debug() not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27430
diff
changeset
|
1246 |
483a8d6cf8b0
patch 8.2.4597: LuaV_debug() not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27430
diff
changeset
|
1247 call term_sendkeys(buf, "foo = 42\n") |
483a8d6cf8b0
patch 8.2.4597: LuaV_debug() not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27430
diff
changeset
|
1248 call WaitForAssert({-> assert_equal('lua_debug> foo = 42', term_getline(buf, 9))}) |
483a8d6cf8b0
patch 8.2.4597: LuaV_debug() not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27430
diff
changeset
|
1249 call WaitForAssert({-> assert_equal('lua_debug> ', term_getline(buf, 10))}) |
483a8d6cf8b0
patch 8.2.4597: LuaV_debug() not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27430
diff
changeset
|
1250 |
483a8d6cf8b0
patch 8.2.4597: LuaV_debug() not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27430
diff
changeset
|
1251 call term_sendkeys(buf, "print(foo)\n") |
483a8d6cf8b0
patch 8.2.4597: LuaV_debug() not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27430
diff
changeset
|
1252 call WaitForAssert({-> assert_equal('lua_debug> print(foo)', term_getline(buf, 8))}) |
483a8d6cf8b0
patch 8.2.4597: LuaV_debug() not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27430
diff
changeset
|
1253 call WaitForAssert({-> assert_equal('42', term_getline(buf, 9))}) |
483a8d6cf8b0
patch 8.2.4597: LuaV_debug() not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27430
diff
changeset
|
1254 call WaitForAssert({-> assert_equal('lua_debug> ', term_getline(buf, 10))}) |
483a8d6cf8b0
patch 8.2.4597: LuaV_debug() not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27430
diff
changeset
|
1255 |
28171
b4c111ea83b1
patch 8.2.4611: typos in tests; one lua line not covered by test
Bram Moolenaar <Bram@vim.org>
parents:
28146
diff
changeset
|
1256 call term_sendkeys(buf, "-\n") |
b4c111ea83b1
patch 8.2.4611: typos in tests; one lua line not covered by test
Bram Moolenaar <Bram@vim.org>
parents:
28146
diff
changeset
|
1257 call WaitForAssert({-> assert_equal("(debug command):1: unexpected symbol near '-'", |
b4c111ea83b1
patch 8.2.4611: typos in tests; one lua line not covered by test
Bram Moolenaar <Bram@vim.org>
parents:
28146
diff
changeset
|
1258 \ term_getline(buf, 9))}) |
b4c111ea83b1
patch 8.2.4611: typos in tests; one lua line not covered by test
Bram Moolenaar <Bram@vim.org>
parents:
28146
diff
changeset
|
1259 call WaitForAssert({-> assert_equal('lua_debug> ', term_getline(buf, 10))}) |
b4c111ea83b1
patch 8.2.4611: typos in tests; one lua line not covered by test
Bram Moolenaar <Bram@vim.org>
parents:
28146
diff
changeset
|
1260 |
28146
483a8d6cf8b0
patch 8.2.4597: LuaV_debug() not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27430
diff
changeset
|
1261 call term_sendkeys(buf, "cont\n") |
483a8d6cf8b0
patch 8.2.4597: LuaV_debug() not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27430
diff
changeset
|
1262 call WaitForAssert({-> assert_match(' All$', term_getline(buf, 10))}) |
483a8d6cf8b0
patch 8.2.4597: LuaV_debug() not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27430
diff
changeset
|
1263 |
28171
b4c111ea83b1
patch 8.2.4611: typos in tests; one lua line not covered by test
Bram Moolenaar <Bram@vim.org>
parents:
28146
diff
changeset
|
1264 " Entering an empty line also exits the debugger. |
b4c111ea83b1
patch 8.2.4611: typos in tests; one lua line not covered by test
Bram Moolenaar <Bram@vim.org>
parents:
28146
diff
changeset
|
1265 call term_sendkeys(buf, ":lua debug.debug()\n") |
b4c111ea83b1
patch 8.2.4611: typos in tests; one lua line not covered by test
Bram Moolenaar <Bram@vim.org>
parents:
28146
diff
changeset
|
1266 call WaitForAssert({-> assert_equal('lua_debug> ', term_getline(buf, 10))}) |
b4c111ea83b1
patch 8.2.4611: typos in tests; one lua line not covered by test
Bram Moolenaar <Bram@vim.org>
parents:
28146
diff
changeset
|
1267 call term_sendkeys(buf, "\n") |
b4c111ea83b1
patch 8.2.4611: typos in tests; one lua line not covered by test
Bram Moolenaar <Bram@vim.org>
parents:
28146
diff
changeset
|
1268 call WaitForAssert({-> assert_match(' All$', term_getline(buf, 10))}) |
b4c111ea83b1
patch 8.2.4611: typos in tests; one lua line not covered by test
Bram Moolenaar <Bram@vim.org>
parents:
28146
diff
changeset
|
1269 |
28146
483a8d6cf8b0
patch 8.2.4597: LuaV_debug() not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27430
diff
changeset
|
1270 call StopVimInTerminal(buf) |
483a8d6cf8b0
patch 8.2.4597: LuaV_debug() not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27430
diff
changeset
|
1271 endfunc |
483a8d6cf8b0
patch 8.2.4597: LuaV_debug() not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27430
diff
changeset
|
1272 |
32807
0582b3b40319
patch 9.0.1719: if_lua: crash for for Lua functions invoked via Vim callbacks
Christian Brabandt <cb@256bit.org>
parents:
32721
diff
changeset
|
1273 " Test for a crash when a Lua funcref is invoked with parameters from Vim |
0582b3b40319
patch 9.0.1719: if_lua: crash for for Lua functions invoked via Vim callbacks
Christian Brabandt <cb@256bit.org>
parents:
32721
diff
changeset
|
1274 func Test_lua_funcref_with_params() |
0582b3b40319
patch 9.0.1719: if_lua: crash for for Lua functions invoked via Vim callbacks
Christian Brabandt <cb@256bit.org>
parents:
32721
diff
changeset
|
1275 let Lua_funcref = luaeval('function(d) local s = "in Lua callback" end') |
0582b3b40319
patch 9.0.1719: if_lua: crash for for Lua functions invoked via Vim callbacks
Christian Brabandt <cb@256bit.org>
parents:
32721
diff
changeset
|
1276 call Lua_funcref({'a' : 'b'}) |
0582b3b40319
patch 9.0.1719: if_lua: crash for for Lua functions invoked via Vim callbacks
Christian Brabandt <cb@256bit.org>
parents:
32721
diff
changeset
|
1277 call assert_true(v:true) |
0582b3b40319
patch 9.0.1719: if_lua: crash for for Lua functions invoked via Vim callbacks
Christian Brabandt <cb@256bit.org>
parents:
32721
diff
changeset
|
1278 endfunc |
0582b3b40319
patch 9.0.1719: if_lua: crash for for Lua functions invoked via Vim callbacks
Christian Brabandt <cb@256bit.org>
parents:
32721
diff
changeset
|
1279 |
20045
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1280 " vim: shiftwidth=2 sts=2 expandtab |