Mercurial > vim
view src/testdir/test_eval.in @ 19015:a3d9a5e14c1f v8.2.0068
patch 8.2.0068: crash when using Python 3 with "utf32" encoding
Commit: https://github.com/vim/vim/commit/556684ff71e044a642879d759373a7ebc5047fad
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Dec 31 21:59:01 2019 +0100
patch 8.2.0068: crash when using Python 3 with "utf32" encoding
Problem: Crash when using Python 3 with "utf32" encoding. (Dominique Pelle)
Solution: Use "utf-8" whenever enc_utf8 is set. (closes https://github.com/vim/vim/issues/5423)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 31 Dec 2019 22:00:03 +0100 |
parents | 30f9a62f5f51 |
children | 0da696bd7352 |
line wrap: on
line source
Test for various eval features. vim: set ft=vim : NOTE: Do not add more here, use new style test test_eval_stuff.vim Note: system clipboard is saved, changed and restored. clipboard contents something else STARTTEST :so small.vim :set encoding=latin1 :set noswapfile :lang C :fun AppendRegContents(reg) call AppendRegParts(a:reg, getregtype(a:reg), getreg(a:reg), string(getreg(a:reg, 0, 1)), getreg(a:reg, 1), string(getreg(a:reg, 1, 1))) :endfun :fun AppendRegParts(reg, type, cont, strcont, cont1, strcont1) call append('$', printf('%s: type %s; value: %s (%s), expr: %s (%s)', a:reg, a:type, a:cont, a:strcont, a:cont1, a:strcont1)) endfun :command -nargs=? AR :call AppendRegContents(<q-args>) :fun SetReg(...) call call('setreg', a:000) call append('$', printf('{{{2 setreg(%s)', string(a:000)[1:-2])) call AppendRegContents(a:1) if a:1 isnot# '=' execute "silent normal! Go==\n==\e\"".a:1."P" endif endfun :fun ErrExe(str) call append('$', 'Executing '.a:str) try execute a:str catch $put =v:exception endtry endfun :fun Test() $put ='{{{1 let tests' let @" = 'abc' AR " let @" = "abc\n" AR " let @" = "abc\<C-m>" AR " let @= = '"abc"' AR = $put ='{{{1 Basic setreg tests' call SetReg('a', 'abcA', 'c') call SetReg('b', 'abcB', 'v') call SetReg('c', 'abcC', 'l') call SetReg('d', 'abcD', 'V') call SetReg('e', 'abcE', 'b') call SetReg('f', 'abcF', "\<C-v>") call SetReg('g', 'abcG', 'b10') call SetReg('h', 'abcH', "\<C-v>10") call SetReg('I', 'abcI') $put ='{{{1 Appending single lines with setreg()' call SetReg('A', 'abcAc', 'c') call SetReg('A', 'abcAl', 'l') call SetReg('A', 'abcAc2','c') call SetReg('b', 'abcBc', 'ca') call SetReg('b', 'abcBb', 'ba') call SetReg('b', 'abcBc2','ca') call SetReg('b', 'abcBb2','b50a') call SetReg('C', 'abcCl', 'l') call SetReg('C', 'abcCc', 'c') call SetReg('D', 'abcDb', 'b') call SetReg('E', 'abcEb', 'b') call SetReg('E', 'abcEl', 'l') call SetReg('F', 'abcFc', 'c') $put ='{{{1 Appending NL with setreg()' call setreg('a', 'abcA2', 'c') call setreg('b', 'abcB2', 'v') call setreg('c', 'abcC2', 'l') call setreg('d', 'abcD2', 'V') call setreg('e', 'abcE2', 'b') call setreg('f', 'abcF2', "\<C-v>") call setreg('g', 'abcG2', 'b10') call setreg('h', 'abcH2', "\<C-v>10") call setreg('I', 'abcI2') call SetReg('A', "\n") call SetReg('B', "\n", 'c') call SetReg('C', "\n") call SetReg('D', "\n", 'l') call SetReg('E', "\n") call SetReg('F', "\n", 'b') $put ='{{{1 Setting lists with setreg()' call SetReg('a', ['abcA3'], 'c') call SetReg('b', ['abcB3'], 'l') call SetReg('c', ['abcC3'], 'b') call SetReg('d', ['abcD3']) call SetReg('e', [1, 2, 'abc', 3]) call SetReg('f', [1, 2, 3]) $put ='{{{1 Appending lists with setreg()' call SetReg('A', ['abcA3c'], 'c') call SetReg('b', ['abcB3l'], 'la') call SetReg('C', ['abcC3b'], 'lb') call SetReg('D', ['abcD32']) call SetReg('A', ['abcA32']) call SetReg('B', ['abcB3c'], 'c') call SetReg('C', ['abcC3l'], 'l') call SetReg('D', ['abcD3b'], 'b') $put ='{{{1 Appending lists with NL with setreg()' call SetReg('A', ["\n", 'abcA3l2'], 'l') call SetReg('B', ["\n", 'abcB3c2'], 'c') call SetReg('C', ["\n", 'abcC3b2'], 'b') call SetReg('D', ["\n", 'abcD3b50'],'b50') $put ='{{{1 Setting lists with NLs with setreg()' call SetReg('a', ['abcA4-0', "\n", "abcA4-2\n", "\nabcA4-3", "abcA4-4\nabcA4-4-2"]) call SetReg('b', ['abcB4c-0', "\n", "abcB4c-2\n", "\nabcB4c-3", "abcB4c-4\nabcB4c-4-2"], 'c') call SetReg('c', ['abcC4l-0', "\n", "abcC4l-2\n", "\nabcC4l-3", "abcC4l-4\nabcC4l-4-2"], 'l') call SetReg('d', ['abcD4b-0', "\n", "abcD4b-2\n", "\nabcD4b-3", "abcD4b-4\nabcD4b-4-2"], 'b') call SetReg('e', ['abcE4b10-0', "\n", "abcE4b10-2\n", "\nabcE4b10-3", "abcE4b10-4\nabcE4b10-4-2"], 'b10') $put ='{{{1 Search and expressions' call SetReg('/', ['abc/']) call SetReg('/', ["abc/\n"]) call SetReg('=', ['"abc/"']) call SetReg('=', ["\"abc/\n\""]) $put ='{{{1 System clipboard' if has('clipboard') " Save and restore system clipboard. " If no connection to X-Server is possible, test should succeed. let _clipreg = ['*', getreg('*'), getregtype('*')] let _clipopt = &cb let &cb='unnamed' 7y AR * tabdo :windo :echo "hi" 8y AR * let &cb=_clipopt call call('setreg', _clipreg) else call AppendRegParts('*', 'V', "clipboard contents\n", "['clipboard contents']", "clipboard contents\n", "['clipboard contents']") call AppendRegParts('*', 'V', "something else\n", "['something else']", "something else\n", "['something else']") endif $put ='{{{1 Errors' call ErrExe('call setreg()') call ErrExe('call setreg(1)') call ErrExe('call setreg(1, 2, 3, 4)') call ErrExe('call setreg([], 2)') call ErrExe('call setreg(1, {})') call ErrExe('call setreg(1, 2, [])') call ErrExe('call setreg("/", ["1", "2"])') call ErrExe('call setreg("=", ["1", "2"])') call ErrExe('call setreg(1, ["", "", [], ""])') endfun :" :call Test() :" :delfunction SetReg :delfunction AppendRegContents :delfunction ErrExe :delfunction Test :delcommand AR :call garbagecollect(1) :" :" function name not starting with capital :try :func! g:test() :echo "test" :endfunc :catch :$put =v:exception :endtry :" :" function name includes a colon :try :func! b:test() :echo "test" :endfunc :catch :$put =v:exception :endtry :" :" function name folowed by # :try :func! test2() "# :echo "test2" :endfunc :catch :$put =v:exception :endtry :" :" function name starting with/without "g:", buffer-local funcref. :function! g:Foo(n) : $put ='called Foo(' . a:n . ')' :endfunction :let b:my_func = function('Foo') :call b:my_func(1) :echo g:Foo(2) :echo Foo(3) :" :" script-local function used in Funcref must exist. :so test_eval_func.vim :" :" Using $ instead of '$' must give an error :try : call append($, 'foobar') :catch :$put =v:exception :endtry :" :$put ='{{{1 getcurpos/setpos' /^012345678 6l:let sp = getcurpos() 0:call setpos('.', sp) jyl:$put :" :" substring and variable name :let str = 'abcdef' :let n = 3 :$put =str[n:] :$put =str[:n] :$put =str[n:n] :unlet n :let nn = 3 :$put =str[nn:] :$put =str[:nn] :$put =str[nn:nn] :unlet nn :let b:nn = 4 :$put =str[b:nn:] :$put =str[:b:nn] :$put =str[b:nn:b:nn] :unlet b:nn :" :/^start:/+1,$wq! test.out :" vim: et ts=4 isk-=\: fmr=???,??? :call getchar() ENDTEST 012345678 012345678 start: