comparison src/testdir/test_vimscript.vim @ 21110:8fb0e507491d v8.2.1106

patch 8.2.1106: crash when trying to use s: variable in typed command Commit: https://github.com/vim/vim/commit/8e6cbb72324b6fb25d1a9abd6cc4d102d0e5f14e Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jul 1 14:38:12 2020 +0200 patch 8.2.1106: crash when trying to use s: variable in typed command Problem: Crash when trying to use s: variable in typed command. Solution: Don't use the script index when not set. (Ken Takata, closes #6366)
author Bram Moolenaar <Bram@vim.org>
date Wed, 01 Jul 2020 14:45:05 +0200
parents 116c7bd5e980
children 792398a9fe39
comparison
equal deleted inserted replaced
21109:35e5bb8acfc9 21110:8fb0e507491d
2005 call assert_fails('echo 3.2 == v:true', 'E362:') 2005 call assert_fails('echo 3.2 == v:true', 'E362:')
2006 call assert_fails('echo 3.2 == v:none', 'E907:') 2006 call assert_fails('echo 3.2 == v:none', 'E907:')
2007 endif 2007 endif
2008 endfunc 2008 endfunc
2009 2009
2010 " invalid function names {{{1
2010 func Test_invalid_function_names() 2011 func Test_invalid_function_names()
2011 " function name not starting with capital 2012 " function name not starting with capital
2012 let caught_e128 = 0 2013 let caught_e128 = 0
2013 try 2014 try
2014 func! g:test() 2015 func! g:test()
2065 call writefile(lines, 'Xscript') 2066 call writefile(lines, 'Xscript')
2066 source Xscript 2067 source Xscript
2067 call delete('Xscript') 2068 call delete('Xscript')
2068 endfunc 2069 endfunc
2069 2070
2070 " substring and variable name 2071 " substring and variable name {{{1
2071 func Test_substring_var() 2072 func Test_substring_var()
2072 let str = 'abcdef' 2073 let str = 'abcdef'
2073 let n = 3 2074 let n = 3
2074 call assert_equal('def', str[n:]) 2075 call assert_equal('def', str[n:])
2075 call assert_equal('abcd', str[:n]) 2076 call assert_equal('abcd', str[:n])
2085 call assert_equal('abcde', str[:b:nn]) 2086 call assert_equal('abcde', str[:b:nn])
2086 call assert_equal('e', str[b:nn:b:nn]) 2087 call assert_equal('e', str[b:nn:b:nn])
2087 unlet b:nn 2088 unlet b:nn
2088 endfunc 2089 endfunc
2089 2090
2091 " Test using s: with a typed command {{{1
2092 func Test_typed_script_var()
2093 CheckRunVimInTerminal
2094
2095 let buf = RunVimInTerminal('', {'rows': 6})
2096
2097 " Deep nesting of if ... endif
2098 call term_sendkeys(buf, ":echo get(s:, 'foo', 'x')\n")
2099 call TermWait(buf)
2100 call WaitForAssert({-> assert_match('^E116:', term_getline(buf, 5))})
2101
2102 call StopVimInTerminal(buf)
2103 endfunc
2104
2090 "------------------------------------------------------------------------------- 2105 "-------------------------------------------------------------------------------
2091 " Modelines {{{1 2106 " Modelines {{{1
2092 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker 2107 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
2093 "------------------------------------------------------------------------------- 2108 "-------------------------------------------------------------------------------