adding the first test!

This commit is contained in:
dsych 2021-01-15 00:35:24 -05:00 • committed by Ben Jackson
commit 789377eab4
3 changed files with 68 additions and 0 deletions

View file

@ -702,6 +702,7 @@ class DebugSession( object ):
'variables': utils.WindowID( vars_window, self._uiTab ),
'watches': utils.WindowID( watch_window, self._uiTab ),
'output': utils.WindowID( output_window, self._uiTab ),
'eval': None # this is going to be updated every time eval popup is opened
}
with utils.RestoreCursorPosition():
with utils.RestoreCurrentWindow():

View file

@ -307,6 +307,7 @@ class VariablesView( object ):
def _CleanUpTooltip( self ) :
# remove reference to old tooltip window
self._variable_eval_view = None
vim.vars[ 'vimspector_session_windows' ][ 'eval' ] = None
return ''
def VariableEval( self, frame, expression, is_hover ):
@ -323,6 +324,8 @@ class VariablesView( object ):
watch.result.Update( message[ 'body' ] )
float_win_id = utils.DisplayBalloon( self._is_term, [], is_hover )
# record the global eval window id
vim.vars[ 'vimspector_session_windows' ][ 'eval' ] = int( float_win_id )
float_buf_nr = int( vim.eval( "winbufnr({})".format( float_win_id ) ) )
# since vim's popup cant be focused there is no way

View file

@ -591,3 +591,67 @@ function! Test_EvaluateFailure()
call vimspector#test#setup#Reset()
%bwipe!
endfunction
function! Test_VariableEval()
let fn = 'testdata/cpp/simple/struct.cpp'
call s:StartDebugging( #{ fn: fn, line: 24, col: 1, launch: #{
\ configuration: 'run-to-breakpoint'
\ } } )
call vimspector#StepOver()
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 26, 1 )
"evaluate the prev line
" call win_gotoid( g:vimspector_session_windows.code )
call setpos('.', [ 0, 24, 8 ])
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 24, 8 )
call vimspector#ShowTooltip()
call WaitForAssert( {->
\ AssertMatchist(
\ [
\ '{...}',
\ ' - i: 0',
\ ' - c: 0 ''\\0\{1,3}''',
\ ' - fffff: 0',
\ ' + another_test: ',
\ ],
\ getbufline( winbufnr( g:vimspector_session_windows.eval ),
\ 1,
\ '$' )
\ )
\ } )
" Expand
call win_execute( g:vimspector_session_windows.eval, [
\ 'call feedkeys( ''jjjj'', ''xt'' )',
\ 'call feedkeys( "\<CR>", ''xt'' )'
\ ] )
call WaitForAssert( {->
\ AssertMatchist(
\ [
\ '{...}',
\ ' - i: 0',
\ ' - c: 0 ''\\0\{1,3}''',
\ ' - fffff: 0',
\ ' - another_test: ',
\ ' - choo: 0 ''\\0\{1,3}''',
\ ' + ints: '
\ ],
\ getbufline( winbufnr( g:vimspector_session_windows.eval ),
\ 1,
\ '$' )
\ )
\ } )
"Close
call win_execute( g:vimspector_session_windows.eval, 'call feedkeys( "\<Esc>", ''xt'')')
call WaitForAssert( {->
\ assert_equal( 0, g:vimspector_session_windows.eval )
\ } )
call vimspector#test#setup#Reset()
%bwipe!
endfunction