function! SetUp() call vimspector#test#setup#SetUpWithMappings( v:none ) endfunction function! ClearDown() call vimspector#test#setup#ClearDown() endfunction function! SetUp_Test_Mappings_Are_Added_HUMAN() let g:vimspector_enable_mappings = 'HUMAN' endfunction function! Test_Mappings_Are_Added_HUMAN() call assert_true( hasmapto( 'vimspector#Continue()' ) ) call assert_false( hasmapto( 'vimspector#Launch()' ) ) call assert_true( hasmapto( 'vimspector#Stop()' ) ) call assert_true( hasmapto( 'vimspector#Restart()' ) ) call assert_true( hasmapto( 'vimspector#ToggleBreakpoint()' ) ) call assert_true( hasmapto( 'vimspector#AddFunctionBreakpoint' ) ) call assert_true( hasmapto( 'vimspector#StepOver()' ) ) call assert_true( hasmapto( 'vimspector#StepInto()' ) ) call assert_true( hasmapto( 'vimspector#StepOut()' ) ) endfunction function! SetUp_Test_Mappings_Are_Added_VISUAL_STUDIO() let g:vimspector_enable_mappings = 'VISUAL_STUDIO' endfunction function! Test_Mappings_Are_Added_VISUAL_STUDIO() call assert_true( hasmapto( 'vimspector#Continue()' ) ) call assert_false( hasmapto( 'vimspector#Launch()' ) ) call assert_true( hasmapto( 'vimspector#Stop()' ) ) call assert_true( hasmapto( 'vimspector#Restart()' ) ) call assert_true( hasmapto( 'vimspector#ToggleBreakpoint()' ) ) call assert_true( hasmapto( 'vimspector#AddFunctionBreakpoint' ) ) call assert_true( hasmapto( 'vimspector#StepOver()' ) ) call assert_true( hasmapto( 'vimspector#StepInto()' ) ) call assert_true( hasmapto( 'vimspector#StepOut()' ) ) endfunction function! SetUp_Test_Signs_Placed_Using_API_Are_Shown() let g:vimspector_enable_mappings = 'VISUAL_STUDIO' endfunction function! Test_Signs_Placed_Using_API_Are_Shown() " We need a real file edit testdata/cpp/simple/simple.cpp call feedkeys( "/printf\", 'xt' ) " Set breakpoint call vimspector#ToggleBreakpoint() call assert_true( exists( '*vimspector#ToggleBreakpoint' ) ) call vimspector#test#signs#AssertSignGroupSingletonAtLine( 'VimspectorBP', \ line( '.' ), \ 'vimspectorBP' ) " Disable breakpoint call vimspector#ToggleBreakpoint() call vimspector#test#signs#AssertSignGroupSingletonAtLine( \ 'VimspectorBP', \ line( '.' ), \ 'vimspectorBPDisabled' ) " Remove breakpoint call vimspector#ToggleBreakpoint() call vimspector#test#signs#AssertSignGroupEmptyAtLine( 'VimspectorBP', \ line( '.' ) ) call vimspector#ClearBreakpoints() call vimspector#test#signs#AssertSignGroupEmpty( 'VimspectorBP' ) call vimspector#test#signs#AssertSignGroupEmpty( 'VimspectorCode' ) %bwipeout! endfunction function! SetUp_Test_Use_Mappings_HUMAN() let g:vimspector_enable_mappings = 'HUMAN' endfunction function! Test_Use_Mappings_HUMAN() lcd testdata/cpp/simple edit simple.cpp call setpos( '.', [ 0, 15, 1 ] ) call vimspector#test#signs#AssertCursorIsAtLineInBuffer( 'simple.cpp', 15, 1 ) call vimspector#test#signs#AssertSignGroupEmptyAtLine( 'VimspectorBP', 15 ) " Add the breakpoint call feedkeys( "\", 'xt' ) call vimspector#test#signs#AssertSignGroupSingletonAtLine( 'VimspectorBP', \ 15, \ 'vimspectorBP' ) " Disable the breakpoint call feedkeys( "\", 'xt' ) call vimspector#test#signs#AssertSignGroupSingletonAtLine( \ 'VimspectorBP', \ 15, \ 'vimspectorBPDisabled' ) " Delete the breakpoint call feedkeys( "\", 'xt' ) call vimspector#test#signs#AssertSignGroupEmptyAtLine( 'VimspectorBP', 15 ) " Add it again call feedkeys( "\", 'xt' ) call vimspector#test#signs#AssertSignGroupSingletonAtLine( \ 'VimspectorBP', \ 15, \ 'vimspectorBP' ) " Here we go. Start Debugging call feedkeys( "\", 'xt' ) call assert_equal( 2, len( gettabinfo() ) ) let cur_tabnr = tabpagenr() call assert_equal( 5, len( gettabinfo( cur_tabnr )[ 0 ].windows ) ) call vimspector#test#signs#AssertCursorIsAtLineInBuffer( 'simple.cpp', 15, 1 ) " Step call feedkeys( "\", 'xt' ) call vimspector#test#signs#AssertCursorIsAtLineInBuffer( 'simple.cpp', 16, 1 ) call WaitForAssert( {-> \ vimspector#test#signs#AssertPCIsAtLineInBuffer( 'simple.cp', 16 ) \ } ) call vimspector#test#setup#Reset() lcd - %bwipeout! endfunction function! SetUp_Test_StopAtEntry() let g:vimspector_enable_mappings = 'HUMAN' endfunction function Test_StopAtEntry() lcd testdata/cpp/simple edit simple.cpp call setpos( '.', [ 0, 1, 1 ] ) " Test stopAtEntry behaviour call feedkeys( "\", 'xt' ) call vimspector#test#signs#AssertCursorIsAtLineInBuffer( 'simple.cpp', 15, 1 ) call WaitForAssert( {-> \ vimspector#test#signs#AssertPCIsAtLineInBuffer( 'simple.cpp', 15 ) \ } ) call vimspector#test#setup#Reset() lcd - %bwipeout! endfunction function! SetUp_Test_DisableBreakpointWhileDebugging() let g:vimspector_enable_mappings = 'HUMAN' endfunction function Test_DisableBreakpointWhileDebugging() lcd testdata/cpp/simple edit simple.cpp call setpos( '.', [ 0, 15, 1 ] ) " Test stopAtEntry behaviour call feedkeys( "\", 'xt' ) call vimspector#test#signs#AssertCursorIsAtLineInBuffer( 'simple.cpp', 15, 1 ) call WaitForAssert( {-> \ vimspector#test#signs#AssertPCIsAtLineInBuffer( 'simple.cpp', 15 ) \ } ) call vimspector#test#signs#AssertSignGroupEmpty( 'VimspectorBP' ) call setpos( '.', [ 0, 16, 1 ] ) " Add the breakpoint call feedkeys( "\", 'xt' ) call WaitForAssert( {-> \ vimspector#test#signs#AssertSignGroupSingletonAtLine( \ 'VimspectorCode', \ 16, \ 'vimspectorBP' ) \ } ) " Remove the breakpoint call feedkeys( "\", 'xt' ) call WaitForAssert( {-> \ vimspector#test#signs#AssertSignGroupEmptyAtLine( 'VimspectorCode', \ 16 ) \ } ) " Add the breakpoint call feedkeys( "\", 'xt' ) call WaitForAssert( {-> \ vimspector#test#signs#AssertSignGroupSingletonAtLine( \ 'VimspectorCode', \ 16, \ 'vimspectorBP' ) \ } ) " Run to breakpoint call setpos( '.', [ 0, 15, 1 ] ) call feedkeys( "\", 'xt' ) call vimspector#test#signs#AssertCursorIsAtLineInBuffer( 'simple.cpp', 16, 1 ) call WaitForAssert( {-> \ vimspector#test#signs#AssertPCIsAtLineInBuffer( 'simple.cpp', 16 ) \ } ) call vimspector#Reset() call WaitForAssert( {-> \ assert_true ( pyxeval( '_vimspector_session._connection is None' ) ) \ } ) call WaitForAssert( {-> \ assert_true( pyxeval( '_vimspector_session._uiTab is None' ) ) \ } ) " Check breakpoint is now a user breakpoint call setpos( '.', [ bufnr( 'simple.cpp' ), 1, 1 ] ) call vimspector#test#signs#AssertSignGroupSingletonAtLine( \ 'VimspectorBP', \ 16, \ 'vimspectorBP' ) " Disable the breakpoint call setpos( '.', [ bufnr( 'simple.cpp' ), 16, 1 ] ) call feedkeys( "\", 'xt' ) call vimspector#test#signs#AssertSignGroupSingletonAtLine( \ 'VimspectorBP', \ 16, \ 'vimspectorBPDisabled' ) " And delete it call feedkeys( "\", 'xt' ) call vimspector#test#signs#AssertSignGroupEmptyAtLine( \ 'VimspectorBP', \ 16 ) call vimspector#ClearBreakpoints() call vimspector#test#signs#AssertSignGroupEmpty( 'VimspectorBP' ) call vimspector#test#signs#AssertSignGroupEmpty( 'VimspectorCode' ) lcd - %bwipeout! endfunction