Browse Source

Add additional tests and add a LICENSE file

Yegappan Lakshmanan 4 years ago
parent
commit
3f59d1f5bb
4 changed files with 110 additions and 3 deletions
  1. 20 0
      LICENSE
  2. 13 0
      README
  3. 1 1
      doc/mru.txt
  4. 76 2
      test/unit_tests.vim

+ 20 - 0
LICENSE

@@ -0,0 +1,20 @@
+License: MIT License
+Copyright (c) 2003-2021 Yegappan Lakshmanan
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to
+deal in the Software without restriction, including without limitation the
+rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+IN THE SOFTWARE.

+ 13 - 0
README

@@ -9,5 +9,18 @@ This plugin will work on all the platforms where Vim is supported. This
 plugin will work in both console and GUI Vim. This version of the MRU 
 plugin needs Vim 7.0 and above.
 
+## Installation
+
+You can install this plugin directly from github using the following steps (in
+Vim 8.0 and above):
+
+```
+    $ mkdir -p $HOME/.vim/pack/downloads/start/mru
+    $ cd $HOME/.vim/pack/downloads/start/mru
+    $ git clone https://github.com/yegappan/mru
+```
+
+or you can use any one of the Vim plugin managers (dein.vim, pathogen, vam, vim-plug, volt, Vundle, etc.) to install and manage this plugin.
+
 The user manual is available at:
 http://github.com/yegappan/mru/wiki/User-Manual

+ 1 - 1
doc/mru.txt

@@ -7,7 +7,7 @@ Last change: Jan 30, 2021
 ==============================================================================
 						*mru-license*
 License: MIT License
-Copyright (c) 2003-2020 Yegappan Lakshmanan
+Copyright (c) 2003-2021 Yegappan Lakshmanan
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to

+ 76 - 2
test/unit_tests.vim

@@ -231,7 +231,7 @@ endfunc
 
 " ==========================================================================
 " Test9
-" Use 'O' in the MRU window to open a file in a veritcally split window
+" Use 'O' in the MRU window to open a file in a vertically split window
 " ==========================================================================
 func Test_09()
   let test_name = 'test9'
@@ -738,7 +738,7 @@ endfunc
 " ==========================================================================
 " Test26
 " When trying to complete filenames for the MRU command without specifying
-" any text should return the the entire MRU list.
+" any text should return the entire MRU list.
 " ==========================================================================
 func Test_26()
   let test_name = 'test26'
@@ -1205,6 +1205,80 @@ func Test_42()
   enew | only
 endfunc
 
+" ==========================================================================
+" Test43
+" Opening a file using the MRU command should jump to the window containing
+" the file (if it is already opened).
+" ==========================================================================
+func Test_43()
+  let test_name = 'test43'
+  only
+  edit file3.txt
+  below split file2.txt
+  below split file1.txt
+  wincmd t
+  MRU file1.txt
+  if winnr() != 3 || fnamemodify(@%, ':p:t') !=# 'file1.txt'
+    call LogResult(test_name, 'FAIL (1)')
+  else
+    MRU file2.txt
+    if winnr() != 2 && fnamemodify(@%, ':p:t') !=# 'file2.txt'
+      call LogResult(test_name, 'FAIL (2)')
+    else
+      MRU file3.txt
+      if winnr() != 1 && fnamemodify(@%, ':p:t') !=# 'file3.txt'
+        call LogResult(test_name, 'FAIL (3)')
+      else
+        call LogResult(test_name, 'pass')
+      endif
+    endif
+  endif
+  enew | only
+endfunc
+
+" ==========================================================================
+" Test44
+" Opening a file using the MRU command should open the file in a new window if
+" the current buffer has unsaved changes.
+" ==========================================================================
+func Test_44()
+  let test_name = 'test44'
+  only
+  set modified
+  MRU file2.txt
+  if winnr('$') == 2 && winnr() == 1 &&
+        \ fnamemodify(@%, ':p:t') ==# 'file2.txt'
+    call LogResult(test_name, 'pass')
+  else
+    call LogResult(test_name, 'FAIL')
+  endif
+  close
+  set nomodified
+endfunc
+
+" ==========================================================================
+" Test45
+" Opening a file from the MRU window using 'v' should open the file in a new
+" window if the current buffer has unsaved changes.
+" ==========================================================================
+func Test_45()
+  let test_name = 'test45'
+  only
+  set modified
+  MRU
+  call search('file3.txt')
+  normal v
+  if winnr('$') == 2 && winnr() == 1
+        \ && fnamemodify(@%, ':p:t') ==# 'file3.txt'
+        \ && &readonly
+    call LogResult(test_name, 'pass')
+  else
+    call LogResult(test_name, 'FAIL')
+  endif
+  close
+  set nomodified
+endfunc
+
 " ==========================================================================
 
 " Create the files used by the tests