Explorar el Código

Add additional tests

Yegappan Lakshmanan hace 4 años
padre
commit
a8de0345a5
Se han modificado 3 ficheros con 72 adiciones y 1 borrados
  1. 2 0
      plugin/mru.vim
  2. 1 0
      test/run_mru_tests.cmd
  3. 69 1
      test/unit_tests.vim

+ 2 - 0
plugin/mru.vim

@@ -112,6 +112,8 @@ if !exists('MRU_FuzzyMatch')
     if exists('*matchfuzzy')
       " Fuzzy matching is supported only when matchfuzzy() function is present
       let MRU_FuzzyMatch = 1
+    else
+      let MRU_FuzzyMatch = 0
     endif
 endif
 

+ 1 - 0
test/run_mru_tests.cmd

@@ -4,6 +4,7 @@ REM Script to run the unit-tests for the MRU Vim plugin on MS-Windows
 
 SETLOCAL
 SET VIM="C:\Program Files (x86)\vim\vim82\vim.exe"
+REM SET VIM="C:\Program Files (x86)\vim\vim73\vim.exe"
 SET VIM_CMD=%VIM% -N -u NONE -U NONE -i NONE
 
 %VIM_CMD% -S unit_tests.vim

+ 69 - 1
test/unit_tests.vim

@@ -1336,6 +1336,74 @@ func Test_46()
 
   call LogResult(test_name, 'pass')
 endfunc
+
+" ==========================================================================
+" Test47
+" The height of the MRU window should be MRU_Window_Height
+" ==========================================================================
+func Test_47()
+  let test_name = 'test47'
+  only
+
+  " default height is 8
+  MRU
+  if winheight(0) != 8
+    call LogResult(test_name, 'FAIL (1)')
+    return
+  endif
+  close
+
+  let g:MRU_Window_Height = 2
+  MRU
+  if winheight(0) != 2
+    call LogResult(test_name, 'FAIL (2)')
+    return
+  endif
+  close
+  let g:MRU_Window_Height = 12
+  MRU
+  if winheight(0) != 12
+    call LogResult(test_name, 'FAIL (3)')
+    return
+  endif
+  close
+
+  call LogResult(test_name, 'pass')
+  let g:MRU_Window_Height = 8
+endfunc
+
+" ==========================================================================
+" Test48
+" Fuzzy search file names with MRU_FuzzyMatch set to 1.
+" ==========================================================================
+func Test_48()
+  if !exists('*matchfuzzy')
+    return
+  endif
+
+  let test_name = 'test48'
+  enew | only
+
+  let g:MRU_FuzzyMatch = 1
+  MRU F1
+  if fnamemodify(@%, ':p:t') ==# 'file1.txt' && winnr('$') == 1
+    call LogResult(test_name, 'pass')
+  else
+    call LogResult(test_name, 'FAIL (1)')
+  endif
+
+  let g:MRU_FuzzyMatch = 0
+  redir => msg
+  MRU F1
+  redir END
+  if msg =~# "MRU file list doesn't contain files matching F1"
+    call LogResult(test_name, 'pass')
+  else
+    call LogResult(test_name, 'FAIL (2)')
+  endif
+  let g:MRU_FuzzyMatch = 1
+endfunc
+
 " ==========================================================================
 
 " Create the files used by the tests
@@ -1365,10 +1433,10 @@ endfor
 set more
 
 " TODO:
+" Add the following tests:
 " 1. When the MRU list is modified, the MRU menu should be refreshed.
 " 2. Try to jump to an already open file from the MRU window and using the
 "     MRU command.
-" 3. Open an existing file but not present in the MRU list using the MRU command
 
 " Cleanup the files used by the tests
 call delete('file1.txt')