view src/testdir/test_prompt_buffer.vim @ 14021:945d343d3024 v8.1.0028

patch 8.1.0028: prompt buffer test fails on MS-Windows commit https://github.com/vim/vim/commit/1149382d21402474c771862d082a541e23beb108 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jun 3 15:08:09 2018 +0200 patch 8.1.0028: prompt buffer test fails on MS-Windows Problem: Prompt buffer test fails on MS-Windows. Solution: Disable the test for now. Remove stray assert.
author Christian Brabandt <cb@256bit.org>
date Sun, 03 Jun 2018 15:15:05 +0200
parents dc67449d648c
children eb5ee7479d31
line wrap: on
line source

" Tests for setting 'buftype' to "prompt"

if !has('channel')
  finish
endif

source shared.vim
source screendump.vim

func Test_prompt_basic()
  " We need to use a terminal window to be able to feed keys without leaving
  " Insert mode.
  if !has('terminal')
    return
  endif
  if has('win32')
    " TODO: make this work on MS-Windows
    return
  endif
  call writefile([
	\ 'func TextEntered(text)',
	\ '  if a:text == "exit"',
	\ '    stopinsert',
	\ '    close',
	\ '  else',
	\ '    " Add the output above the current prompt.',
	\ '    call append(line("$") - 1, "Command: \"" . a:text . "\"")',
	\ '    " Reset &modified to allow the buffer to be closed.',
	\ '    set nomodified',
	\ '    call timer_start(20, {id -> TimerFunc(a:text)})',
	\ '  endif',
	\ 'endfunc',
	\ '',
	\ 'func TimerFunc(text)',
	\ '  " Add the output above the current prompt.',
	\ '  call append(line("$") - 1, "Result: \"" . a:text . "\"")',
	\ 'endfunc',
	\ '',
	\ 'call setline(1, "other buffer")',
	\ 'new',
	\ 'set buftype=prompt',
	\ 'call prompt_setcallback(bufnr(""), function("TextEntered"))',
	\ 'startinsert',
	\ ], 'Xpromptscript')
  let buf = RunVimInTerminal('-S Xpromptscript', {})
  call WaitForAssert({-> assert_equal('%', term_getline(buf, 1))})

  call term_sendkeys(buf, "hello\<CR>")
  call WaitForAssert({-> assert_equal('% hello', term_getline(buf, 1))})
  call WaitForAssert({-> assert_equal('Command: "hello"', term_getline(buf, 2))})
  call WaitForAssert({-> assert_equal('Result: "hello"', term_getline(buf, 3))})

  call term_sendkeys(buf, "exit\<CR>")
  call WaitForAssert({-> assert_equal('other buffer', term_getline(buf, 1))})

  call StopVimInTerminal(buf)
  call delete('Xpromptscript')
endfunc