@@ -987,6 +987,38 @@ describe('lua stdlib', function()
987
987
988
988
matches([[attempt to index .* nil value]],
989
989
pcall_err(exec_lua, 'return vim.g[0].testing'))
990
+
991
+
exec_lua [[
992
+
local counter = 0
993
+
vim.g.AddCounter = function() counter = counter + 1 end
994
+
vim.g.GetCounter = function() return counter end
995
+
]]
996
+
997
+
eq(0, eval('g:GetCounter()'))
998
+
eval('g:AddCounter()')
999
+
eq(1, eval('g:GetCounter()'))
1000
+
eval('g:AddCounter()')
1001
+
eq(2, eval('g:GetCounter()'))
1002
+
exec_lua([[vim.g.AddCounter()]])
1003
+
eq(3, exec_lua([[return vim.g.GetCounter()]]))
1004
+
exec_lua([[vim.api.nvim_get_var('AddCounter')()]])
1005
+
eq(4, exec_lua([[return vim.api.nvim_get_var('GetCounter')()]]))
1006
+
1007
+
exec_lua [[
1008
+
local counter = 0
1009
+
vim.api.nvim_set_var('AddCounter', function() counter = counter + 1 end)
1010
+
vim.api.nvim_set_var('GetCounter', function() return counter end)
1011
+
]]
1012
+
1013
+
eq(0, eval('g:GetCounter()'))
1014
+
eval('g:AddCounter()')
1015
+
eq(1, eval('g:GetCounter()'))
1016
+
eval('g:AddCounter()')
1017
+
eq(2, eval('g:GetCounter()'))
1018
+
exec_lua([[vim.g.AddCounter()]])
1019
+
eq(3, exec_lua([[return vim.g.GetCounter()]]))
1020
+
exec_lua([[vim.api.nvim_get_var('AddCounter')()]])
1021
+
eq(4, exec_lua([[return vim.api.nvim_get_var('GetCounter')()]]))
990
1022
end)
991
1023
992
1024
it('vim.b', function()
@@ -1021,6 +1053,38 @@ describe('lua stdlib', function()
1021
1053
]]
1022
1054
eq(NIL, funcs.luaeval "vim.b.to_delete")
1023
1055
1056
+
exec_lua [[
1057
+
local counter = 0
1058
+
vim.b.AddCounter = function() counter = counter + 1 end
1059
+
vim.b.GetCounter = function() return counter end
1060
+
]]
1061
+
1062
+
eq(0, eval('b:GetCounter()'))
1063
+
eval('b:AddCounter()')
1064
+
eq(1, eval('b:GetCounter()'))
1065
+
eval('b:AddCounter()')
1066
+
eq(2, eval('b:GetCounter()'))
1067
+
exec_lua([[vim.b.AddCounter()]])
1068
+
eq(3, exec_lua([[return vim.b.GetCounter()]]))
1069
+
exec_lua([[vim.api.nvim_buf_get_var(0, 'AddCounter')()]])
1070
+
eq(4, exec_lua([[return vim.api.nvim_buf_get_var(0, 'GetCounter')()]]))
1071
+
1072
+
exec_lua [[
1073
+
local counter = 0
1074
+
vim.api.nvim_buf_set_var(0, 'AddCounter', function() counter = counter + 1 end)
1075
+
vim.api.nvim_buf_set_var(0, 'GetCounter', function() return counter end)
1076
+
]]
1077
+
1078
+
eq(0, eval('b:GetCounter()'))
1079
+
eval('b:AddCounter()')
1080
+
eq(1, eval('b:GetCounter()'))
1081
+
eval('b:AddCounter()')
1082
+
eq(2, eval('b:GetCounter()'))
1083
+
exec_lua([[vim.b.AddCounter()]])
1084
+
eq(3, exec_lua([[return vim.b.GetCounter()]]))
1085
+
exec_lua([[vim.api.nvim_buf_get_var(0, 'AddCounter')()]])
1086
+
eq(4, exec_lua([[return vim.api.nvim_buf_get_var(0, 'GetCounter')()]]))
1087
+
1024
1088
exec_lua [[
1025
1089
vim.cmd "vnew"
1026
1090
]]
@@ -1058,6 +1122,38 @@ describe('lua stdlib', function()
1058
1122
]]
1059
1123
eq(NIL, funcs.luaeval "vim.w.to_delete")
1060
1124
1125
+
exec_lua [[
1126
+
local counter = 0
1127
+
vim.w.AddCounter = function() counter = counter + 1 end
1128
+
vim.w.GetCounter = function() return counter end
1129
+
]]
1130
+
1131
+
eq(0, eval('w:GetCounter()'))
1132
+
eval('w:AddCounter()')
1133
+
eq(1, eval('w:GetCounter()'))
1134
+
eval('w:AddCounter()')
1135
+
eq(2, eval('w:GetCounter()'))
1136
+
exec_lua([[vim.w.AddCounter()]])
1137
+
eq(3, exec_lua([[return vim.w.GetCounter()]]))
1138
+
exec_lua([[vim.api.nvim_win_get_var(0, 'AddCounter')()]])
1139
+
eq(4, exec_lua([[return vim.api.nvim_win_get_var(0, 'GetCounter')()]]))
1140
+
1141
+
exec_lua [[
1142
+
local counter = 0
1143
+
vim.api.nvim_win_set_var(0, 'AddCounter', function() counter = counter + 1 end)
1144
+
vim.api.nvim_win_set_var(0, 'GetCounter', function() return counter end)
1145
+
]]
1146
+
1147
+
eq(0, eval('w:GetCounter()'))
1148
+
eval('w:AddCounter()')
1149
+
eq(1, eval('w:GetCounter()'))
1150
+
eval('w:AddCounter()')
1151
+
eq(2, eval('w:GetCounter()'))
1152
+
exec_lua([[vim.w.AddCounter()]])
1153
+
eq(3, exec_lua([[return vim.w.GetCounter()]]))
1154
+
exec_lua([[vim.api.nvim_win_get_var(0, 'AddCounter')()]])
1155
+
eq(4, exec_lua([[return vim.api.nvim_win_get_var(0, 'GetCounter')()]]))
1156
+
1061
1157
exec_lua [[
1062
1158
vim.cmd "vnew"
1063
1159
]]
@@ -1090,6 +1186,38 @@ describe('lua stdlib', function()
1090
1186
]]
1091
1187
eq(NIL, funcs.luaeval "vim.t.to_delete")
1092
1188
1189
+
exec_lua [[
1190
+
local counter = 0
1191
+
vim.t.AddCounter = function() counter = counter + 1 end
1192
+
vim.t.GetCounter = function() return counter end
1193
+
]]
1194
+
1195
+
eq(0, eval('t:GetCounter()'))
1196
+
eval('t:AddCounter()')
1197
+
eq(1, eval('t:GetCounter()'))
1198
+
eval('t:AddCounter()')
1199
+
eq(2, eval('t:GetCounter()'))
1200
+
exec_lua([[vim.t.AddCounter()]])
1201
+
eq(3, exec_lua([[return vim.t.GetCounter()]]))
1202
+
exec_lua([[vim.api.nvim_tabpage_get_var(0, 'AddCounter')()]])
1203
+
eq(4, exec_lua([[return vim.api.nvim_tabpage_get_var(0, 'GetCounter')()]]))
1204
+
1205
+
exec_lua [[
1206
+
local counter = 0
1207
+
vim.api.nvim_tabpage_set_var(0, 'AddCounter', function() counter = counter + 1 end)
1208
+
vim.api.nvim_tabpage_set_var(0, 'GetCounter', function() return counter end)
1209
+
]]
1210
+
1211
+
eq(0, eval('t:GetCounter()'))
1212
+
eval('t:AddCounter()')
1213
+
eq(1, eval('t:GetCounter()'))
1214
+
eval('t:AddCounter()')
1215
+
eq(2, eval('t:GetCounter()'))
1216
+
exec_lua([[vim.t.AddCounter()]])
1217
+
eq(3, exec_lua([[return vim.t.GetCounter()]]))
1218
+
exec_lua([[vim.api.nvim_tabpage_get_var(0, 'AddCounter')()]])
1219
+
eq(4, exec_lua([[return vim.api.nvim_tabpage_get_var(0, 'GetCounter')()]]))
1220
+
1093
1221
exec_lua [[
1094
1222
vim.cmd "tabnew"
1095
1223
]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4