patch 8.0.1007: no test for filetype detection for scripts v8.0.1007
authorBram Moolenaar <Bram@vim.org>
Sun, 27 Aug 2017 14:54:26 +0000 (16:54 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 27 Aug 2017 14:54:26 +0000 (16:54 +0200)
Problem:    No test for filetype detection for scripts.
Solution:   Add a first test file script filetype detection.

src/testdir/test_filetype.vim
src/version.c

index 9cce23a5c86dbf068cb2babc43c9c322350d16a3..061c3795adb9a623c3cb3e30b086b32a34fdc8c2 100644 (file)
@@ -527,4 +527,32 @@ func Test_filetype_detection()
   if has('fname_case')
     call CheckItems(s:filename_case_checks)
   endif
+  filetype off
+endfunc
+
+" Filetypes detected from the file contents by scripts.vim
+let s:script_checks = {
+      \ 'virata': [['% Virata'],
+      \                ['', '% Virata'],
+      \                ['', '', '% Virata'],
+      \                ['', '', '', '% Virata'],
+      \                ['', '', '', '', '% Virata']],
+      \ 'strace': [['execve("/usr/bin/pstree", ["pstree"], 0x7ff0 /* 63 vars */) = 0'],
+      \                ['15:17:47 execve("/usr/bin/pstree", ["pstree"], ... "_=/usr/bin/strace"]) = 0'],
+      \                ['__libc_start_main and something']],
+      \ }
+
+func Test_script_detection()
+  filetype on
+  for [ft, files] in items(s:script_checks)
+    for file in files
+      call writefile(file, 'Xtest')
+      split Xtest
+      call assert_equal(ft, &filetype)
+      bwipe!
+    endfor
+  endfor
+  call delete('Xtest')
+  filetype off
 endfunc
+
index 5df1fc36ac10cc1c2fe06b0c75c325568336f26d..7b23a9a9fdbf035e07600a5c9aa54b4e43b6f2b3 100644 (file)
@@ -769,6 +769,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1007,
 /**/
     1006,
 /**/