view src/testdir/vim9.vim @ 22796:d3694e3685d3 v8.2.1946

patch 8.2.1946: sort() with NULL string not tested Commit: https://github.com/vim/vim/commit/35efa22ff2b98126363098db9304796b5624f97f Author: Bram Moolenaar <Bram@vim.org> Date: Tue Nov 3 18:51:54 2020 +0100 patch 8.2.1946: sort() with NULL string not tested Problem: sort() with NULL string not tested. Solution: Add a test. use v:collate. (Dominique Pell?, closes https://github.com/vim/vim/issues/7247)
author Bram Moolenaar <Bram@vim.org>
date Tue, 03 Nov 2020 19:00:03 +0100
parents ef8a3177edc1
children c713358da074
line wrap: on
line source

" Utility functions for testing vim9 script

" Check that "lines" inside ":def" has no error.
func CheckDefSuccess(lines)
  call writefile(['def Func()'] + a:lines + ['enddef', 'defcompile'], 'Xdef')
  so Xdef
  call Func()
  call delete('Xdef')
endfunc

" Check that "lines" inside ":def" results in an "error" message.
" If "lnum" is given check that the error is reported for this line.
" Add a line before and after to make it less likely that the line number is
" accidentally correct.
func CheckDefFailure(lines, error, lnum = -3)
  call writefile(['def Func()', '# comment'] + a:lines + ['#comment', 'enddef', 'defcompile'], 'Xdef')
  call assert_fails('so Xdef', a:error, a:lines, a:lnum + 1)
  call delete('Xdef')
endfunc

" Check that "lines" inside ":def" results in an "error" message when executed.
" If "lnum" is given check that the error is reported for this line.
" Add a line before and after to make it less likely that the line number is
" accidentally correct.
func CheckDefExecFailure(lines, error, lnum = -3)
  call writefile(['def Func()', '# comment'] + a:lines + ['#comment', 'enddef'], 'Xdef')
  so Xdef
  call assert_fails('call Func()', a:error, a:lines, a:lnum + 1)
  call delete('Xdef')
endfunc

def CheckScriptFailure(lines: list<string>, error: string, lnum = -3)
  writefile(lines, 'Xdef')
  assert_fails('so Xdef', error, lines, lnum)
  delete('Xdef')
enddef

def CheckScriptSuccess(lines: list<string>)
  writefile(lines, 'Xdef')
  so Xdef
  delete('Xdef')
enddef

def CheckDefAndScriptSuccess(lines: list<string>)
  CheckDefSuccess(lines)
  CheckScriptSuccess(['vim9script'] + lines)
enddef

" Check that a command fails both when used in a :def function and when used
" in Vim9 script.
def CheckDefAndScriptFailure(lines: list<string>, error: string, lnum = -3)
  CheckDefFailure(lines, error, lnum)
  CheckScriptFailure(['vim9script'] + lines, error, lnum + 1)
enddef

" Check that a command fails both when executed in a :def function and when
" used in Vim9 script.
def CheckDefExecAndScriptFailure(lines: list<string>, error: string, lnum = -3)
  CheckDefExecFailure(lines, error, lnum)
  CheckScriptFailure(['vim9script'] + lines, error, lnum + 1)
enddef