]> granicus.if.org Git - vim/commitdiff
patch 8.2.0406: FileReadCmd event not well tested v8.2.0406
authorBram Moolenaar <Bram@vim.org>
Thu, 19 Mar 2020 12:55:03 +0000 (13:55 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 19 Mar 2020 12:55:03 +0000 (13:55 +0100)
Problem:    FileReadCmd event not well tested.
Solution:   Add a test.

src/testdir/test_autocmd.vim
src/version.c

index e5dec890c6e40cc70afd469abe9ad01b74c9b662..02b56a73bb1b5119f670981e2c3b8d74858b0f44 100644 (file)
@@ -2408,4 +2408,45 @@ func Test_TermChanged()
   bwipe!
 endfunc
 
+" Test for FileReadCmd autocmd
+func Test_autocmd_FileReadCmd()
+  func ReadFileCmd()
+    call append(line('$'), "v:cmdarg = " .. v:cmdarg)
+  endfunc
+  augroup FileReadCmdTest
+    au!
+    au FileReadCmd Xtest call ReadFileCmd()
+  augroup END
+
+  new
+  read ++bin Xtest
+  read ++nobin Xtest
+  read ++edit Xtest
+  read ++bad=keep Xtest
+  read ++bad=drop Xtest
+  read ++bad=- Xtest
+  read ++ff=unix Xtest
+  read ++ff=dos Xtest
+  read ++ff=mac Xtest
+  read ++enc=utf-8 Xtest
+
+  call assert_equal(['',
+        \ 'v:cmdarg =  ++bin',
+        \ 'v:cmdarg =  ++nobin',
+        \ 'v:cmdarg =  ++edit',
+        \ 'v:cmdarg =  ++bad=keep',
+        \ 'v:cmdarg =  ++bad=drop',
+        \ 'v:cmdarg =  ++bad=-',
+        \ 'v:cmdarg =  ++ff=unix',
+        \ 'v:cmdarg =  ++ff=dos',
+        \ 'v:cmdarg =  ++ff=mac',
+        \ 'v:cmdarg =  ++enc=utf-8'], getline(1, '$'))
+
+  close!
+  augroup FileReadCmdTest
+    au!
+  augroup END
+  delfunc ReadFileCmd
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index ed2f86dcbdf064a9f276bf046e829aef86d0c240..f90a4278054384f753323dbdc64e652bbb31a396 100644 (file)
@@ -738,6 +738,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    406,
 /**/
     405,
 /**/