Patch 8.2.2696
Problem:    Lua test fails with Lua 5.4.3 and later.
Solution:   Check for different error messages. (Yegappan Lakshmanan,
            closes #8050)
Files:      src/testdir/test_lua.vim


*** ../vim-8.2.2695/src/testdir/test_lua.vim    2021-03-08 19:50:20.452224854 
+0100
--- src/testdir/test_lua.vim    2021-04-03 14:08:42.225650912 +0200
***************
*** 12,24 ****
  CheckFeature lua
  CheckFeature float
  
! let s:luaver = split(split(luaeval('_VERSION'), ' ')[1], '\.')
  let s:major = str2nr(s:luaver[0])
  let s:minor = str2nr(s:luaver[1])
! if s:major < 5 || (s:major == 5 && s:minor < 3)
!   let s:lua_53_or_later = 0
! else
    let s:lua_53_or_later = 1
  endif
  
  func TearDown()
--- 12,31 ----
  CheckFeature lua
  CheckFeature float
  
! " Depending on the lua version, the error messages are different.
! let s:luaver = split(split(systemlist('lua -v')[0], ' ')[1], '\.')
  let s:major = str2nr(s:luaver[0])
  let s:minor = str2nr(s:luaver[1])
! let s:patch = str2nr(s:luaver[2])
! let s:lua_53_or_later = 0
! let s:lua_543_or_later = 0
! if (s:major == 5 && s:minor >= 3) || s:major > 5
    let s:lua_53_or_later = 1
+   if (s:major == 5
+         \ && ((s:minor == 4 && s:patch >= 3) || s:minor > 4))
+         \ || s:major > 5
+     let s:lua_543_or_later = 1
+   endif
  endif
  
  func TearDown()
***************
*** 55,64 ****
    " Error cases
    call assert_fails('luado string.format()',
          \ "[string \"vim chunk\"]:1: bad argument #1 to 'format' (string 
expected, got no value)")
!   call assert_fails('luado func()',
!         \ s:lua_53_or_later
!         \ ? "[string \"vim chunk\"]:1: attempt to call a nil value (global 
'func')"
!         \ : "[string \"vim chunk\"]:1: attempt to call global 'func' (a nil 
value)")
    call assert_fails('luado error("failed")', "[string \"vim chunk\"]:1: 
failed")
  endfunc
  
--- 62,75 ----
    " Error cases
    call assert_fails('luado string.format()',
          \ "[string \"vim chunk\"]:1: bad argument #1 to 'format' (string 
expected, got no value)")
!   if s:lua_543_or_later
!     let msg = "[string \"vim chunk\"]:1: global 'func' is not callable (a nil 
value)"
!   elseif s:lua_53_or_later
!     let msg = "[string \"vim chunk\"]:1: attempt to call a nil value (global 
'func')"
!   else
!     let msg = "[string \"vim chunk\"]:1: attempt to call global 'func' (a nil 
value)"
!   endif
!   call assert_fails('luado func()', msg)
    call assert_fails('luado error("failed")', "[string \"vim chunk\"]:1: 
failed")
  endfunc
  
***************
*** 143,152 ****
    " Window 3 does not exist so vim.window(3) should return nil
    call assert_equal('nil', luaeval('tostring(vim.window(3))'))
  
!   call assert_fails("let n = luaeval('vim.window().xyz()')",
!         \ s:lua_53_or_later
!         \ ? "[string \"luaeval\"]:1: attempt to call a nil value (field 
'xyz')"
!         \ : "[string \"luaeval\"]:1: attempt to call field 'xyz' (a nil 
value)")
    call assert_fails('lua vim.window().xyz = 1',
          \ "[string \"vim chunk\"]:1: invalid window property: `xyz'")
  
--- 154,167 ----
    " Window 3 does not exist so vim.window(3) should return nil
    call assert_equal('nil', luaeval('tostring(vim.window(3))'))
  
!   if s:lua_543_or_later
!     let msg = "[string \"luaeval\"]:1: field 'xyz' is not callable (a nil 
value)"
!   elseif s:lua_53_or_later
!     let msg = "[string \"luaeval\"]:1: attempt to call a nil value (field 
'xyz')"
!   else
!     let msg = "[string \"luaeval\"]:1: attempt to call field 'xyz' (a nil 
value)"
!   endif
!   call assert_fails("let n = luaeval('vim.window().xyz()')", msg)
    call assert_fails('lua vim.window().xyz = 1',
          \ "[string \"vim chunk\"]:1: invalid window property: `xyz'")
  
***************
*** 331,340 ****
    call assert_equal('4', luaeval('vim.buffer()[4]'))
    call assert_equal(v:null, luaeval('vim.buffer()[5]'))
    call assert_equal(v:null, luaeval('vim.buffer()[{}]'))
!   call assert_fails('lua vim.buffer():xyz()',
!         \ s:lua_53_or_later
!         \ ? "[string \"vim chunk\"]:1: attempt to call a nil value (method 
'xyz')"
!         \ : "[string \"vim chunk\"]:1: attempt to call method 'xyz' (a nil 
value)")
    call assert_fails('lua vim.buffer()[1] = {}',
          \ '[string "vim chunk"]:1: wrong argument to change')
    bwipe!
--- 346,359 ----
    call assert_equal('4', luaeval('vim.buffer()[4]'))
    call assert_equal(v:null, luaeval('vim.buffer()[5]'))
    call assert_equal(v:null, luaeval('vim.buffer()[{}]'))
!   if s:lua_543_or_later
!     let msg = "[string \"vim chunk\"]:1: method 'xyz' is not callable (a nil 
value)"
!   elseif s:lua_53_or_later
!     let msg = "[string \"vim chunk\"]:1: attempt to call a nil value (method 
'xyz')"
!   else
!     let msg = "[string \"vim chunk\"]:1: attempt to call method 'xyz' (a nil 
value)"
!   endif
!   call assert_fails('lua vim.buffer():xyz()', msg)
    call assert_fails('lua vim.buffer()[1] = {}',
          \ '[string "vim chunk"]:1: wrong argument to change')
    bwipe!
***************
*** 438,447 ****
    lua ll = vim.eval('l')
    let x = luaeval("ll[3]")
    call assert_equal(v:null, x)
!   call assert_fails('let x = luaeval("ll:xyz(3)")',
!         \ s:lua_53_or_later
!         \ ? "[string \"luaeval\"]:1: attempt to call a nil value (method 
'xyz')"
!         \ : "[string \"luaeval\"]:1: attempt to call method 'xyz' (a nil 
value)")
    let y = luaeval("ll[{}]")
    call assert_equal(v:null, y)
  
--- 457,470 ----
    lua ll = vim.eval('l')
    let x = luaeval("ll[3]")
    call assert_equal(v:null, x)
!   if s:lua_543_or_later
!     let msg = "[string \"luaeval\"]:1: method 'xyz' is not callable (a nil 
value)"
!   elseif s:lua_53_or_later
!     let msg = "[string \"luaeval\"]:1: attempt to call a nil value (method 
'xyz')"
!   else
!     let msg = "[string \"luaeval\"]:1: attempt to call method 'xyz' (a nil 
value)"
!   endif
!   call assert_fails('let x = luaeval("ll:xyz(3)")', msg)
    let y = luaeval("ll[{}]")
    call assert_equal(v:null, y)
  
***************
*** 467,473 ****
      throw 'Skipped: Lua version < 5.3'
    endif
  
!   let l = [1, 2] 
    lua t = vim.eval('l')
    lua table.insert(t, 10)
    lua t[#t + 1] = 20
--- 490,496 ----
      throw 'Skipped: Lua version < 5.3'
    endif
  
!   let l = [1, 2]
    lua t = vim.eval('l')
    lua table.insert(t, 10)
    lua t[#t + 1] = 20
***************
*** 625,634 ****
    call assert_equal(2, n)
    let n = luaeval('lb[6]')
    call assert_equal(v:null, n)
!   call assert_fails('let x = luaeval("lb:xyz(3)")',
!         \ s:lua_53_or_later
!         \ ? "[string \"luaeval\"]:1: attempt to call a nil value (method 
'xyz')"
!         \ : "[string \"luaeval\"]:1: attempt to call method 'xyz' (a nil 
value)")
    let y = luaeval("lb[{}]")
    call assert_equal(v:null, y)
  
--- 648,661 ----
    call assert_equal(2, n)
    let n = luaeval('lb[6]')
    call assert_equal(v:null, n)
!   if s:lua_543_or_later
!     let msg = "[string \"luaeval\"]:1: method 'xyz' is not callable (a nil 
value)"
!   elseif s:lua_53_or_later
!     let msg = "[string \"luaeval\"]:1: attempt to call a nil value (method 
'xyz')"
!   else
!     let msg = "[string \"luaeval\"]:1: attempt to call method 'xyz' (a nil 
value)"
!   endif
!   call assert_fails('let x = luaeval("lb:xyz(3)")', msg)
    let y = luaeval("lb[{}]")
    call assert_equal(v:null, y)
  
*** ../vim-8.2.2695/src/version.c       2021-04-03 13:19:23.106814487 +0200
--- src/version.c       2021-04-03 14:09:56.749425070 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2696,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
42. Your virtual girlfriend finds a new net sweetheart with a larger bandwidth.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202104031214.133CEVOv2502731%40masaka.moolenaar.net.

Raspunde prin e-mail lui