fixit.test.vim 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. function! SetUp()
  2. let g:ycm_confirm_extra_conf = 0
  3. let g:ycm_auto_trigger = 1
  4. let g:ycm_keep_logfiles = 1
  5. let g:ycm_log_level = 'DEBUG'
  6. call youcompleteme#test#setup#SetUp()
  7. endfunction
  8. function! TearDown()
  9. call youcompleteme#test#setup#CleanUp()
  10. endfunction
  11. function! Test_Ranged_Fixit_Works()
  12. call youcompleteme#test#setup#OpenFile(
  13. \ '/third_party/ycmd/ycmd/tests/java/testdata/simple_eclipse_project' .
  14. \ '/src/com/test/TestLauncher.java', { 'delay': 15 } )
  15. call setpos( '.', [ 0, 34, 50 ] )
  16. redraw
  17. call assert_equal( ' System.out.println( "Did something useful: ' .
  18. \ '" + w.getWidgetInfo() );', getline( '.' ) )
  19. call feedkeys( "vib\<esc>", 'xt' )
  20. function! SelectEntry( id ) closure
  21. redraw
  22. call test_feedinput( "4\<CR>" )
  23. endfunction
  24. call timer_start( 5000, funcref( 'SelectEntry' ) )
  25. '<,'>YcmCompleter FixIt
  26. redraw
  27. call assert_match( ' String \(x\|string\) = "Did something useful: "' .
  28. \ ' + w.getWidgetInfo();', getline( 34 ) )
  29. call assert_match( ' System.out.println( \(x\|string\) );', getline( 35 ) )
  30. delfunction SelectEntry
  31. endfunction
  32. function! Test_Unresolved_Fixit_Works()
  33. call youcompleteme#test#setup#OpenFile( '/test/testdata/cpp/fixit.cpp', {} )
  34. call setpos( '.', [ 0, 3, 15 ] )
  35. call assert_equal( ' printf("%s",1);', getline( '.' ) )
  36. function! SelectEntry( id ) closure
  37. redraw
  38. call test_feedinput( "2\<CR>" )
  39. endfunction
  40. call timer_start( 2000, funcref( 'SelectEntry' ) )
  41. YcmCompleter FixIt
  42. redraw
  43. call assert_equal( ' auto placeholder = 1;', getline( 3 ) )
  44. call assert_equal( ' printf("%s", placeholder);', getline( 4 ) )
  45. %bwipeout!
  46. delfunction SelectEntry
  47. endfunction