view src/testdir/test_eval.in @ 20109:e82996ad131f v8.2.0610

patch 8.2.0610: some tests are still old style Commit: https://github.com/vim/vim/commit/08f4157c5cabc55bcb22f04dd7c717aba40caa34 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Apr 20 16:50:00 2020 +0200 patch 8.2.0610: some tests are still old style Problem: Some tests are still old style. Solution: Convert to new style tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5957)
author Bram Moolenaar <Bram@vim.org>
date Mon, 20 Apr 2020 17:00:04 +0200
parents 0da696bd7352
children
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 Test()
$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
endfun
:"
:call Test()
:"
:delfunction SetReg
:delfunction AppendRegContents
:delfunction Test
:delcommand AR
:call garbagecollect(1)
:"
:/^start:/+1,$wq! test.out
:" vim: et ts=4 isk-=\: fmr=???,???
:call getchar()
ENDTEST

start: