comparison src/testdir/test_lua.vim @ 27430:da3a39fd0964 v8.2.4243

patch 8.2.4243: Lua tests fail with Lua 5.4.4 Commit: https://github.com/vim/vim/commit/57ff2b7068c03c89fbfc8930e1325274e72d22a3 Author: =?UTF-8?q?Jakub=20Kul=C3=ADk?= <kulikjak@gmail.com> Date: Fri Jan 28 17:20:03 2022 +0000 patch 8.2.4243: Lua tests fail with Lua 5.4.4 Problem: Lua tests fail with Lua 5.4.4. Solution: Check messages like before Lua 5.4.3. (Jakub Kul?k, closes https://github.com/vim/vim/issues/9652)
author Bram Moolenaar <Bram@vim.org>
date Fri, 28 Jan 2022 18:30:03 +0100
parents d5e9c05b4811
children 483a8d6cf8b0
comparison
equal deleted inserted replaced
27429:15d6dce19850 27430:da3a39fd0964
13 CheckFeature float 13 CheckFeature float
14 14
15 " Depending on the lua version, the error messages are different. 15 " Depending on the lua version, the error messages are different.
16 let [s:major, s:minor, s:patch] = luaeval('vim.lua_version')->split('\.')->map({-> str2nr(v:val)}) 16 let [s:major, s:minor, s:patch] = luaeval('vim.lua_version')->split('\.')->map({-> str2nr(v:val)})
17 let s:lua_53_or_later = 0 17 let s:lua_53_or_later = 0
18 let s:lua_543_or_later = 0 18 let s:lua_543 = 0
19 if (s:major == 5 && s:minor >= 3) || s:major > 5 19 if (s:major == 5 && s:minor >= 3) || s:major > 5
20 let s:lua_53_or_later = 1 20 let s:lua_53_or_later = 1
21 if (s:major == 5 21 if s:major == 5 && s:minor == 4 && s:patch == 3
22 \ && ((s:minor == 4 && s:patch >= 3) || s:minor > 4)) 22 let s:lua_543 = 1
23 \ || s:major > 5
24 let s:lua_543_or_later = 1
25 endif 23 endif
26 endif 24 endif
27 25
28 func TearDown() 26 func TearDown()
29 " Run garbage collection after each test to exercise luaV_setref(). 27 " Run garbage collection after each test to exercise luaV_setref().
57 close! 55 close!
58 56
59 " Error cases 57 " Error cases
60 call assert_fails('luado string.format()', 58 call assert_fails('luado string.format()',
61 \ "[string \"vim chunk\"]:1: bad argument #1 to 'format' (string expected, got no value)") 59 \ "[string \"vim chunk\"]:1: bad argument #1 to 'format' (string expected, got no value)")
62 if s:lua_543_or_later 60 if s:lua_543
63 let msg = "[string \"vim chunk\"]:1: global 'func' is not callable (a nil value)" 61 let msg = "[string \"vim chunk\"]:1: global 'func' is not callable (a nil value)"
64 elseif s:lua_53_or_later 62 elseif s:lua_53_or_later
65 let msg = "[string \"vim chunk\"]:1: attempt to call a nil value (global 'func')" 63 let msg = "[string \"vim chunk\"]:1: attempt to call a nil value (global 'func')"
66 else 64 else
67 let msg = "[string \"vim chunk\"]:1: attempt to call global 'func' (a nil value)" 65 let msg = "[string \"vim chunk\"]:1: attempt to call global 'func' (a nil value)"
149 call assert_equal('Xfoo2', luaeval('vim.window(2):buffer().name')) 147 call assert_equal('Xfoo2', luaeval('vim.window(2):buffer().name'))
150 148
151 " Window 3 does not exist so vim.window(3) should return nil 149 " Window 3 does not exist so vim.window(3) should return nil
152 call assert_equal('nil', luaeval('tostring(vim.window(3))')) 150 call assert_equal('nil', luaeval('tostring(vim.window(3))'))
153 151
154 if s:lua_543_or_later 152 if s:lua_543
155 let msg = "[string \"luaeval\"]:1: field 'xyz' is not callable (a nil value)" 153 let msg = "[string \"luaeval\"]:1: field 'xyz' is not callable (a nil value)"
156 elseif s:lua_53_or_later 154 elseif s:lua_53_or_later
157 let msg = "[string \"luaeval\"]:1: attempt to call a nil value (field 'xyz')" 155 let msg = "[string \"luaeval\"]:1: attempt to call a nil value (field 'xyz')"
158 else 156 else
159 let msg = "[string \"luaeval\"]:1: attempt to call field 'xyz' (a nil value)" 157 let msg = "[string \"luaeval\"]:1: attempt to call field 'xyz' (a nil value)"
341 339
342 call assert_equal(['1', '2', '3', '4'], getline(1, '$')) 340 call assert_equal(['1', '2', '3', '4'], getline(1, '$'))
343 call assert_equal('4', luaeval('vim.buffer()[4]')) 341 call assert_equal('4', luaeval('vim.buffer()[4]'))
344 call assert_equal(v:null, luaeval('vim.buffer()[5]')) 342 call assert_equal(v:null, luaeval('vim.buffer()[5]'))
345 call assert_equal(v:null, luaeval('vim.buffer()[{}]')) 343 call assert_equal(v:null, luaeval('vim.buffer()[{}]'))
346 if s:lua_543_or_later 344 if s:lua_543
347 let msg = "[string \"vim chunk\"]:1: method 'xyz' is not callable (a nil value)" 345 let msg = "[string \"vim chunk\"]:1: method 'xyz' is not callable (a nil value)"
348 elseif s:lua_53_or_later 346 elseif s:lua_53_or_later
349 let msg = "[string \"vim chunk\"]:1: attempt to call a nil value (method 'xyz')" 347 let msg = "[string \"vim chunk\"]:1: attempt to call a nil value (method 'xyz')"
350 else 348 else
351 let msg = "[string \"vim chunk\"]:1: attempt to call method 'xyz' (a nil value)" 349 let msg = "[string \"vim chunk\"]:1: attempt to call method 'xyz' (a nil value)"
452 unlockvar l 450 unlockvar l
453 let l = [1, 2] 451 let l = [1, 2]
454 lua ll = vim.eval('l') 452 lua ll = vim.eval('l')
455 let x = luaeval("ll[3]") 453 let x = luaeval("ll[3]")
456 call assert_equal(v:null, x) 454 call assert_equal(v:null, x)
457 if s:lua_543_or_later 455 if s:lua_543
458 let msg = "[string \"luaeval\"]:1: method 'xyz' is not callable (a nil value)" 456 let msg = "[string \"luaeval\"]:1: method 'xyz' is not callable (a nil value)"
459 elseif s:lua_53_or_later 457 elseif s:lua_53_or_later
460 let msg = "[string \"luaeval\"]:1: attempt to call a nil value (method 'xyz')" 458 let msg = "[string \"luaeval\"]:1: attempt to call a nil value (method 'xyz')"
461 else 459 else
462 let msg = "[string \"luaeval\"]:1: attempt to call method 'xyz' (a nil value)" 460 let msg = "[string \"luaeval\"]:1: attempt to call method 'xyz' (a nil value)"
643 lua lb = vim.eval('b') 641 lua lb = vim.eval('b')
644 let n = luaeval('lb[1]') 642 let n = luaeval('lb[1]')
645 call assert_equal(2, n) 643 call assert_equal(2, n)
646 let n = luaeval('lb[6]') 644 let n = luaeval('lb[6]')
647 call assert_equal(v:null, n) 645 call assert_equal(v:null, n)
648 if s:lua_543_or_later 646 if s:lua_543
649 let msg = "[string \"luaeval\"]:1: method 'xyz' is not callable (a nil value)" 647 let msg = "[string \"luaeval\"]:1: method 'xyz' is not callable (a nil value)"
650 elseif s:lua_53_or_later 648 elseif s:lua_53_or_later
651 let msg = "[string \"luaeval\"]:1: attempt to call a nil value (method 'xyz')" 649 let msg = "[string \"luaeval\"]:1: attempt to call a nil value (method 'xyz')"
652 else 650 else
653 let msg = "[string \"luaeval\"]:1: attempt to call method 'xyz' (a nil value)" 651 let msg = "[string \"luaeval\"]:1: attempt to call method 'xyz' (a nil value)"