fixit.test.vim 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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', {} )
  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( '\t\tSystem.out.println( \(x\|string\) );', getline( 35 ) )
  30. %bwipeout!
  31. delfunction SelectEntry
  32. endfunction
  33. function! Test_Unresolved_Fixit_Works()
  34. call youcompleteme#test#setup#OpenFile( '/test/testdata/cpp/fixit.c', {} )
  35. call setpos( '.', [ 0, 3, 2 ] )
  36. call assert_equal( ' printf("%s",1);', getline( '.' ) )
  37. function! SelectEntry( id ) closure
  38. redraw
  39. call test_feedinput( "2\<CR>" )
  40. endfunction
  41. call timer_start( 2000, funcref( 'SelectEntry' ) )
  42. YcmCompleter FixIt
  43. redraw
  44. call assert_equal( ' auto dummy = 1;', getline( '.' ) )
  45. call assert_equal( ' printf("%s", dummy);', getline( 4 ) )
  46. %bwipeout!
  47. delfunction SelectEntry
  48. endfunction