A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/neovim/neovim/commit/cac90d2de728181edce7ba38fb9ad588d231651b below:

support converting nested Funcref back to LuaRef (#17… · neovim/neovim@cac90d2 · GitHub

@@ -14,7 +14,7 @@ local feed = helpers.feed

14 14

local pcall_err = helpers.pcall_err

15 15

local exec_lua = helpers.exec_lua

16 16

local matches = helpers.matches

17 -

local source = helpers.source

17 +

local exec = helpers.exec

18 18

local NIL = helpers.NIL

19 19

local retry = helpers.retry

20 20

local next_msg = helpers.next_msg

@@ -743,7 +743,7 @@ describe('lua stdlib', function()

743 743

-- compat: nvim_call_function uses "special" value for vimL float

744 744

eq(false, exec_lua([[return vim.api.nvim_call_function('sin', {0.0}) == 0.0 ]]))

745 745 746 -

source([[

746 +

exec([[

747 747

func! FooFunc(test)

748 748

let g:test = a:test

749 749

return {}

@@ -771,6 +771,12 @@ describe('lua stdlib', function()

771 771 772 772

-- error handling

773 773

eq({false, 'Vim:E897: List or Blob required'}, exec_lua([[return {pcall(vim.fn.add, "aa", "bb")}]]))

774 + 775 +

-- conversion between LuaRef and Vim Funcref

776 +

eq(true, exec_lua([[

777 +

local x = vim.fn.VarArg(function() return 'foo' end, function() return 'bar' end)

778 +

return #x == 2 and x[1]() == 'foo' and x[2]() == 'bar'

779 +

]]))

774 780

end)

775 781 776 782

it('vim.fn should error when calling API function', function()

@@ -993,8 +999,11 @@ describe('lua stdlib', function()

993 999 994 1000

exec_lua [[

995 1001

local counter = 0

996 -

vim.g.AddCounter = function() counter = counter + 1 end

997 -

vim.g.GetCounter = function() return counter end

1002 +

local function add_counter() counter = counter + 1 end

1003 +

local function get_counter() return counter end

1004 +

vim.g.AddCounter = add_counter

1005 +

vim.g.GetCounter = get_counter

1006 +

vim.g.funcs = {add = add_counter, get = get_counter}

998 1007

]]

999 1008 1000 1009

eq(0, eval('g:GetCounter()'))

@@ -1006,11 +1015,18 @@ describe('lua stdlib', function()

1006 1015

eq(3, exec_lua([[return vim.g.GetCounter()]]))

1007 1016

exec_lua([[vim.api.nvim_get_var('AddCounter')()]])

1008 1017

eq(4, exec_lua([[return vim.api.nvim_get_var('GetCounter')()]]))

1018 +

exec_lua([[vim.g.funcs.add()]])

1019 +

eq(5, exec_lua([[return vim.g.funcs.get()]]))

1020 +

exec_lua([[vim.api.nvim_get_var('funcs').add()]])

1021 +

eq(6, exec_lua([[return vim.api.nvim_get_var('funcs').get()]]))

1009 1022 1010 1023

exec_lua [[

1011 1024

local counter = 0

1012 -

vim.api.nvim_set_var('AddCounter', function() counter = counter + 1 end)

1013 -

vim.api.nvim_set_var('GetCounter', function() return counter end)

1025 +

local function add_counter() counter = counter + 1 end

1026 +

local function get_counter() return counter end

1027 +

vim.api.nvim_set_var('AddCounter', add_counter)

1028 +

vim.api.nvim_set_var('GetCounter', get_counter)

1029 +

vim.api.nvim_set_var('funcs', {add = add_counter, get = get_counter})

1014 1030

]]

1015 1031 1016 1032

eq(0, eval('g:GetCounter()'))

@@ -1022,6 +1038,10 @@ describe('lua stdlib', function()

1022 1038

eq(3, exec_lua([[return vim.g.GetCounter()]]))

1023 1039

exec_lua([[vim.api.nvim_get_var('AddCounter')()]])

1024 1040

eq(4, exec_lua([[return vim.api.nvim_get_var('GetCounter')()]]))

1041 +

exec_lua([[vim.g.funcs.add()]])

1042 +

eq(5, exec_lua([[return vim.g.funcs.get()]]))

1043 +

exec_lua([[vim.api.nvim_get_var('funcs').add()]])

1044 +

eq(6, exec_lua([[return vim.api.nvim_get_var('funcs').get()]]))

1025 1045 1026 1046

-- Check if autoload works properly

1027 1047

local pathsep = helpers.get_pathsep()

@@ -1072,8 +1092,11 @@ describe('lua stdlib', function()

1072 1092 1073 1093

exec_lua [[

1074 1094

local counter = 0

1075 -

vim.b.AddCounter = function() counter = counter + 1 end

1076 -

vim.b.GetCounter = function() return counter end

1095 +

local function add_counter() counter = counter + 1 end

1096 +

local function get_counter() return counter end

1097 +

vim.b.AddCounter = add_counter

1098 +

vim.b.GetCounter = get_counter

1099 +

vim.b.funcs = {add = add_counter, get = get_counter}

1077 1100

]]

1078 1101 1079 1102

eq(0, eval('b:GetCounter()'))

@@ -1085,11 +1108,18 @@ describe('lua stdlib', function()

1085 1108

eq(3, exec_lua([[return vim.b.GetCounter()]]))

1086 1109

exec_lua([[vim.api.nvim_buf_get_var(0, 'AddCounter')()]])

1087 1110

eq(4, exec_lua([[return vim.api.nvim_buf_get_var(0, 'GetCounter')()]]))

1111 +

exec_lua([[vim.b.funcs.add()]])

1112 +

eq(5, exec_lua([[return vim.b.funcs.get()]]))

1113 +

exec_lua([[vim.api.nvim_buf_get_var(0, 'funcs').add()]])

1114 +

eq(6, exec_lua([[return vim.api.nvim_buf_get_var(0, 'funcs').get()]]))

1088 1115 1089 1116

exec_lua [[

1090 1117

local counter = 0

1091 -

vim.api.nvim_buf_set_var(0, 'AddCounter', function() counter = counter + 1 end)

1092 -

vim.api.nvim_buf_set_var(0, 'GetCounter', function() return counter end)

1118 +

local function add_counter() counter = counter + 1 end

1119 +

local function get_counter() return counter end

1120 +

vim.api.nvim_buf_set_var(0, 'AddCounter', add_counter)

1121 +

vim.api.nvim_buf_set_var(0, 'GetCounter', get_counter)

1122 +

vim.api.nvim_buf_set_var(0, 'funcs', {add = add_counter, get = get_counter})

1093 1123

]]

1094 1124 1095 1125

eq(0, eval('b:GetCounter()'))

@@ -1101,6 +1131,10 @@ describe('lua stdlib', function()

1101 1131

eq(3, exec_lua([[return vim.b.GetCounter()]]))

1102 1132

exec_lua([[vim.api.nvim_buf_get_var(0, 'AddCounter')()]])

1103 1133

eq(4, exec_lua([[return vim.api.nvim_buf_get_var(0, 'GetCounter')()]]))

1134 +

exec_lua([[vim.b.funcs.add()]])

1135 +

eq(5, exec_lua([[return vim.b.funcs.get()]]))

1136 +

exec_lua([[vim.api.nvim_buf_get_var(0, 'funcs').add()]])

1137 +

eq(6, exec_lua([[return vim.api.nvim_buf_get_var(0, 'funcs').get()]]))

1104 1138 1105 1139

exec_lua [[

1106 1140

vim.cmd "vnew"

@@ -1141,8 +1175,11 @@ describe('lua stdlib', function()

1141 1175 1142 1176

exec_lua [[

1143 1177

local counter = 0

1144 -

vim.w.AddCounter = function() counter = counter + 1 end

1145 -

vim.w.GetCounter = function() return counter end

1178 +

local function add_counter() counter = counter + 1 end

1179 +

local function get_counter() return counter end

1180 +

vim.w.AddCounter = add_counter

1181 +

vim.w.GetCounter = get_counter

1182 +

vim.w.funcs = {add = add_counter, get = get_counter}

1146 1183

]]

1147 1184 1148 1185

eq(0, eval('w:GetCounter()'))

@@ -1154,11 +1191,18 @@ describe('lua stdlib', function()

1154 1191

eq(3, exec_lua([[return vim.w.GetCounter()]]))

1155 1192

exec_lua([[vim.api.nvim_win_get_var(0, 'AddCounter')()]])

1156 1193

eq(4, exec_lua([[return vim.api.nvim_win_get_var(0, 'GetCounter')()]]))

1194 +

exec_lua([[vim.w.funcs.add()]])

1195 +

eq(5, exec_lua([[return vim.w.funcs.get()]]))

1196 +

exec_lua([[vim.api.nvim_win_get_var(0, 'funcs').add()]])

1197 +

eq(6, exec_lua([[return vim.api.nvim_win_get_var(0, 'funcs').get()]]))

1157 1198 1158 1199

exec_lua [[

1159 1200

local counter = 0

1160 -

vim.api.nvim_win_set_var(0, 'AddCounter', function() counter = counter + 1 end)

1161 -

vim.api.nvim_win_set_var(0, 'GetCounter', function() return counter end)

1201 +

local function add_counter() counter = counter + 1 end

1202 +

local function get_counter() return counter end

1203 +

vim.api.nvim_win_set_var(0, 'AddCounter', add_counter)

1204 +

vim.api.nvim_win_set_var(0, 'GetCounter', get_counter)

1205 +

vim.api.nvim_win_set_var(0, 'funcs', {add = add_counter, get = get_counter})

1162 1206

]]

1163 1207 1164 1208

eq(0, eval('w:GetCounter()'))

@@ -1170,6 +1214,10 @@ describe('lua stdlib', function()

1170 1214

eq(3, exec_lua([[return vim.w.GetCounter()]]))

1171 1215

exec_lua([[vim.api.nvim_win_get_var(0, 'AddCounter')()]])

1172 1216

eq(4, exec_lua([[return vim.api.nvim_win_get_var(0, 'GetCounter')()]]))

1217 +

exec_lua([[vim.w.funcs.add()]])

1218 +

eq(5, exec_lua([[return vim.w.funcs.get()]]))

1219 +

exec_lua([[vim.api.nvim_win_get_var(0, 'funcs').add()]])

1220 +

eq(6, exec_lua([[return vim.api.nvim_win_get_var(0, 'funcs').get()]]))

1173 1221 1174 1222

exec_lua [[

1175 1223

vim.cmd "vnew"

@@ -1205,8 +1253,11 @@ describe('lua stdlib', function()

1205 1253 1206 1254

exec_lua [[

1207 1255

local counter = 0

1208 -

vim.t.AddCounter = function() counter = counter + 1 end

1209 -

vim.t.GetCounter = function() return counter end

1256 +

local function add_counter() counter = counter + 1 end

1257 +

local function get_counter() return counter end

1258 +

vim.t.AddCounter = add_counter

1259 +

vim.t.GetCounter = get_counter

1260 +

vim.t.funcs = {add = add_counter, get = get_counter}

1210 1261

]]

1211 1262 1212 1263

eq(0, eval('t:GetCounter()'))

@@ -1218,11 +1269,18 @@ describe('lua stdlib', function()

1218 1269

eq(3, exec_lua([[return vim.t.GetCounter()]]))

1219 1270

exec_lua([[vim.api.nvim_tabpage_get_var(0, 'AddCounter')()]])

1220 1271

eq(4, exec_lua([[return vim.api.nvim_tabpage_get_var(0, 'GetCounter')()]]))

1272 +

exec_lua([[vim.t.funcs.add()]])

1273 +

eq(5, exec_lua([[return vim.t.funcs.get()]]))

1274 +

exec_lua([[vim.api.nvim_tabpage_get_var(0, 'funcs').add()]])

1275 +

eq(6, exec_lua([[return vim.api.nvim_tabpage_get_var(0, 'funcs').get()]]))

1221 1276 1222 1277

exec_lua [[

1223 1278

local counter = 0

1224 -

vim.api.nvim_tabpage_set_var(0, 'AddCounter', function() counter = counter + 1 end)

1225 -

vim.api.nvim_tabpage_set_var(0, 'GetCounter', function() return counter end)

1279 +

local function add_counter() counter = counter + 1 end

1280 +

local function get_counter() return counter end

1281 +

vim.api.nvim_tabpage_set_var(0, 'AddCounter', add_counter)

1282 +

vim.api.nvim_tabpage_set_var(0, 'GetCounter', get_counter)

1283 +

vim.api.nvim_tabpage_set_var(0, 'funcs', {add = add_counter, get = get_counter})

1226 1284

]]

1227 1285 1228 1286

eq(0, eval('t:GetCounter()'))

@@ -1234,6 +1292,10 @@ describe('lua stdlib', function()

1234 1292

eq(3, exec_lua([[return vim.t.GetCounter()]]))

1235 1293

exec_lua([[vim.api.nvim_tabpage_get_var(0, 'AddCounter')()]])

1236 1294

eq(4, exec_lua([[return vim.api.nvim_tabpage_get_var(0, 'GetCounter')()]]))

1295 +

exec_lua([[vim.t.funcs.add()]])

1296 +

eq(5, exec_lua([[return vim.t.funcs.get()]]))

1297 +

exec_lua([[vim.api.nvim_tabpage_get_var(0, 'funcs').add()]])

1298 +

eq(6, exec_lua([[return vim.api.nvim_tabpage_get_var(0, 'funcs').get()]]))

1237 1299 1238 1300

exec_lua [[

1239 1301

vim.cmd "tabnew"


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