view src/testdir/test_makeencoding.vim @ 19701:9412cc889072 v8.2.0407

patch 8.2.0407: no early check if :find and :sfind have an argument Commit: https://github.com/vim/vim/commit/2d10cd478047df8ba144d4b0fcc46480993af57f Author: Bram Moolenaar <Bram@vim.org> Date: Thu Mar 19 14:37:30 2020 +0100 patch 8.2.0407: no early check if :find and :sfind have an argument Problem: No early check if :find and :sfind have an argument. Solution: Add EX_NEEDARG.
author Bram Moolenaar <Bram@vim.org>
date Thu, 19 Mar 2020 14:45:04 +0100
parents 068337e86133
children 08940efa6b4e
line wrap: on
line source

" Tests for 'makeencoding'.

source shared.vim
source check.vim

CheckFeature quickfix
let s:python = PythonProg()
if s:python == ''
  throw 'Skipped: python program missing'
endif

let s:script = 'test_makeencoding.py'

let s:message_tbl = {
      \ 'utf-8': 'ÀÈÌÒÙ こんにちは 你好',
      \ 'latin1': 'ÀÈÌÒÙ',
      \ 'cp932': 'こんにちは',
      \ 'cp936': '你好',
      \}


" Tests for :cgetfile and :lgetfile.
func Test_getfile()
  set errorfile=Xerror.txt
  set errorformat=%f(%l)\ :\ %m

  " :cgetfile
  for enc in keys(s:message_tbl)
    let &makeencoding = enc
    exec "silent !" . s:python . " " . s:script . " " . enc . " > " . &errorfile
    cgetfile
    copen
    call assert_equal("Xfoobar.c|10| " . s:message_tbl[enc] . " (" . enc . ")",
          \ getline('.'))
    cclose
  endfor

  " :lgetfile
  for enc in keys(s:message_tbl)
    let &makeencoding = enc
    exec "silent !" . s:python . " " . s:script . " " . enc . " > " . &errorfile
    lgetfile
    lopen
    call assert_equal("Xfoobar.c|10| " . s:message_tbl[enc] . " (" . enc . ")",
          \ getline('.'))
    lclose
  endfor

  call delete(&errorfile)
endfunc


" Tests for :grep and :lgrep.
func Test_grep()
  let &grepprg = s:python
  set grepformat=%f(%l)\ :\ %m

  " :grep
  for enc in keys(s:message_tbl)
    let &makeencoding = enc
    exec "silent grep! " . s:script . " " . enc
    copen
    call assert_equal("Xfoobar.c|10| " . s:message_tbl[enc] . " (" . enc . ")",
          \ getline('.'))
    cclose
  endfor

  " :lgrep
  for enc in keys(s:message_tbl)
    let &makeencoding = enc
    exec "silent lgrep! " . s:script . " " . enc
    lopen
    call assert_equal("Xfoobar.c|10| " . s:message_tbl[enc] . " (" . enc . ")",
          \ getline('.'))
    lclose
  endfor
endfunc


" Tests for :make and :lmake.
func Test_make()
  let &makeprg = s:python
  set errorformat=%f(%l)\ :\ %m

  " :make
  for enc in keys(s:message_tbl)
    let &makeencoding = enc
    exec "silent make! " . s:script . " " . enc
    copen
    call assert_equal("Xfoobar.c|10| " . s:message_tbl[enc] . " (" . enc . ")",
          \ getline('.'))
    cclose
  endfor

  " :lmake
  for enc in keys(s:message_tbl)
    let &makeencoding = enc
    exec "silent lmake! " . s:script . " " . enc
    lopen
    call assert_equal("Xfoobar.c|10| " . s:message_tbl[enc] . " (" . enc . ")",
          \ getline('.'))
    lclose
  endfor
endfunc