To: vim_dev@googlegroups.com Subject: Patch 8.2.4306 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4306 Problem: No test for fixed perl filetype check. Solution: Add a test. Sort test functions. Files: src/testdir/test_filetype.vim *** ../vim-8.2.4305/src/testdir/test_filetype.vim 2022-02-05 19:49:29.947540471 +0000 --- src/testdir/test_filetype.vim 2022-02-05 20:20:44.169028996 +0000 *************** *** 756,856 **** close endfunc ! func Test_hook_file() filetype on ! call writefile(['[Trigger]', 'this is pacman config'], 'Xfile.hook') ! split Xfile.hook ! call assert_equal('dosini', &filetype) bwipe! ! call writefile(['not pacman'], 'Xfile.hook') ! split Xfile.hook ! call assert_notequal('dosini', &filetype) bwipe! ! call delete('Xfile.hook') ! filetype off ! endfunc ! func Test_tf_file() ! filetype on ! call writefile([';;; TF MUD client is super duper cool'], 'Xfile.tf') ! split Xfile.tf ! call assert_equal('tf', &filetype) bwipe! ! call writefile(['provider "azurerm" {'], 'Xfile.tf') ! split Xfile.tf ! call assert_equal('terraform', &filetype) bwipe! ! call delete('Xfile.tf') ! filetype off ! endfunc ! func Test_ts_file() ! filetype on ! call writefile([''], 'Xfile.ts') ! split Xfile.ts ! call assert_equal('xml', &filetype) bwipe! ! call writefile(['// looks like Typescript'], 'Xfile.ts') ! split Xfile.ts ! call assert_equal('typescript', &filetype) bwipe! ! call delete('Xfile.ts') filetype off endfunc ! func Test_ttl_file() filetype on ! call writefile(['@base .'], 'Xfile.ttl') ! split Xfile.ttl ! call assert_equal('turtle', &filetype) ! bwipe! ! call writefile(['looks like Tera Term Language'], 'Xfile.ttl') ! split Xfile.ttl ! call assert_equal('teraterm', &filetype) bwipe! ! call delete('Xfile.ttl') ! filetype off ! endfunc ! func Test_pp_file() ! filetype on ! call writefile(['looks like puppet'], 'Xfile.pp') ! split Xfile.pp ! call assert_equal('puppet', &filetype) bwipe! ! let g:filetype_pp = 'pascal' ! split Xfile.pp ! call assert_equal('pascal', &filetype) bwipe! - unlet g:filetype_pp ! " Test dist#ft#FTpp() ! call writefile(['{ pascal comment'], 'Xfile.pp') ! split Xfile.pp ! call assert_equal('pascal', &filetype) bwipe! ! call writefile(['procedure pascal'], 'Xfile.pp') ! split Xfile.pp ! call assert_equal('pascal', &filetype) bwipe! ! call delete('Xfile.pp') filetype off endfunc --- 756,881 ---- close endfunc ! """"""""""""""""""""""""""""""""""""""""""""""""" ! " Tests for specific extentions and filetypes. ! " Keep sorted. ! """"""""""""""""""""""""""""""""""""""""""""""""" ! ! func Test_bas_file() filetype on ! call writefile(['looks like BASIC'], 'Xfile.bas') ! split Xfile.bas ! call assert_equal('basic', &filetype) bwipe! ! " Test dist#ft#FTbas() ! ! let g:filetype_bas = 'freebasic' ! split Xfile.bas ! call assert_equal('freebasic', &filetype) bwipe! + unlet g:filetype_bas ! " FreeBASIC ! call writefile(["/' FreeBASIC multiline comment '/"], 'Xfile.bas') ! split Xfile.bas ! call assert_equal('freebasic', &filetype) ! bwipe! ! call writefile(['#define TESTING'], 'Xfile.bas') ! split Xfile.bas ! call assert_equal('freebasic', &filetype) bwipe! ! call writefile(['option byval'], 'Xfile.bas') ! split Xfile.bas ! call assert_equal('freebasic', &filetype) bwipe! ! call writefile(['extern "C"'], 'Xfile.bas') ! split Xfile.bas ! call assert_equal('freebasic', &filetype) ! bwipe! + " QB64 ! call writefile(['$LET TESTING = 1'], 'Xfile.bas') ! split Xfile.bas ! call assert_equal('qb64', &filetype) ! bwipe! ! call writefile(['OPTION _EXPLICIT'], 'Xfile.bas') ! split Xfile.bas ! call assert_equal('qb64', &filetype) bwipe! ! " Visual Basic ! ! call writefile(['Attribute VB_NAME = "Testing"'], 'Xfile.bas') ! split Xfile.bas ! call assert_equal('vb', &filetype) bwipe! ! call delete('Xfile.bas') filetype off endfunc ! func Test_dep3patch_file() filetype on ! call assert_true(mkdir('debian/patches', 'p')) ! " series files are not patches ! call writefile(['Description: some awesome patch'], 'debian/patches/series') ! split debian/patches/series ! call assert_notequal('dep3patch', &filetype) bwipe! ! " diff/patch files without the right headers should still show up as ft=diff ! call writefile([], 'debian/patches/foo.diff') ! split debian/patches/foo.diff ! call assert_equal('diff', &filetype) ! bwipe! ! " Files with the right headers are detected as dep3patch, even if they don't ! " have a diff/patch extension ! call writefile(['Subject: dep3patches'], 'debian/patches/bar') ! split debian/patches/bar ! call assert_equal('dep3patch', &filetype) ! bwipe! ! " Files in sub-directories are detected ! call assert_true(mkdir('debian/patches/s390x', 'p')) ! call writefile(['Subject: dep3patches'], 'debian/patches/s390x/bar') ! split debian/patches/s390x/bar ! call assert_equal('dep3patch', &filetype) bwipe! ! " The detection stops when seeing the "header end" marker ! call writefile(['---', 'Origin: the cloud'], 'debian/patches/baz') ! split debian/patches/baz ! call assert_notequal('dep3patch', &filetype) bwipe! ! call delete('debian', 'rf') ! endfunc ! ! func Test_dsl_file() ! filetype on ! ! call writefile([' '], 'Xfile.m') ! split Xfile.m ! call assert_equal('objc', &filetype) bwipe! ! call writefile(['#define FORTY_TWO'], 'Xfile.m') ! split Xfile.m ! call assert_equal('objc', &filetype) bwipe! ! " Octave ! ! call writefile(['# Octave line comment'], 'Xfile.m') ! split Xfile.m ! call assert_equal('octave', &filetype) bwipe! ! call writefile(['%!test "Octave test"'], 'Xfile.m') ! split Xfile.m ! call assert_equal('octave', &filetype) bwipe! ! call writefile(['unwind_protect'], 'Xfile.m') ! split Xfile.m ! call assert_equal('octave', &filetype) bwipe! ! call writefile(['try; 42; end_try_catch'], 'Xfile.m') ! split Xfile.m ! call assert_equal('octave', &filetype) bwipe! ! " Mathematica ! ! call writefile(['(* Mathematica comment'], 'Xfile.m') ! split Xfile.m ! call assert_equal('mma', &filetype) bwipe! ! " MATLAB ! ! call writefile(['% MATLAB line comment'], 'Xfile.m') ! split Xfile.m ! call assert_equal('matlab', &filetype) ! bwipe! ! " Murphi ! call writefile(['-- Murphi comment'], 'Xfile.m') ! split Xfile.m ! call assert_equal('murphi', &filetype) bwipe! ! call writefile(['/* Murphi block comment */', 'Type'], 'Xfile.m') ! split Xfile.m ! call assert_equal('murphi', &filetype) ! bwipe! ! call writefile(['Type'], 'Xfile.m') ! split Xfile.m ! call assert_equal('murphi', &filetype) bwipe! ! call delete('Xfile.m') ! filetype off ! endfunc ! ! func Test_xpm_file() ! filetype on ! call writefile(['this is XPM2'], 'file.xpm') ! split file.xpm ! call assert_equal('xpm2', &filetype) bwipe! ! call delete('file.xpm') filetype off endfunc --- 916,999 ---- filetype off endfunc ! func Test_foam_file() filetype on + call assert_true(mkdir('0', 'p')) + call assert_true(mkdir('0.orig', 'p')) ! call writefile(['FoamFile {', ' object something;'], 'Xfile1Dict') ! split Xfile1Dict ! call assert_equal('foam', &filetype) bwipe! ! call writefile(['FoamFile {', ' object something;'], 'Xfile1Dict.something') ! split Xfile1Dict.something ! call assert_equal('foam', &filetype) bwipe! ! call writefile(['FoamFile {', ' object something;'], 'XfileProperties') ! split XfileProperties ! call assert_equal('foam', &filetype) bwipe! ! call writefile(['FoamFile {', ' object something;'], 'XfileProperties.something') ! split XfileProperties.something ! call assert_equal('foam', &filetype) bwipe! ! call writefile(['FoamFile {', ' object something;'], 'XfileProperties') ! split XfileProperties ! call assert_equal('foam', &filetype) bwipe! ! call writefile(['FoamFile {', ' object something;'], 'XfileProperties.something') ! split XfileProperties.something ! call assert_equal('foam', &filetype) bwipe! ! call writefile(['FoamFile {', ' object something;'], '0/Xfile') ! split 0/Xfile ! call assert_equal('foam', &filetype) bwipe! ! call writefile(['FoamFile {', ' object something;'], '0.orig/Xfile') ! split 0.orig/Xfile ! call assert_equal('foam', &filetype) bwipe! ! call delete('0', 'rf') ! call delete('0.orig', 'rf') ! call delete('Xfile1Dict') ! call delete('Xfile1Dict.something') ! call delete('XfileProperties') ! call delete('XfileProperties.something') ! filetype off ! endfunc ! func Test_frm_file() ! filetype on ! call writefile(['looks like FORM'], 'Xfile.frm') ! split Xfile.frm ! call assert_equal('form', &filetype) bwipe! ! " Test dist#ft#FTfrm() ! let g:filetype_frm = 'form' ! split Xfile.frm ! call assert_equal('form', &filetype) bwipe! + unlet g:filetype_frm ! " Visual Basic ! call writefile(['Begin VB.Form Form1'], 'Xfile.frm') ! split Xfile.frm ! call assert_equal('vb', &filetype) bwipe! ! call delete('Xfile.frm') filetype off endfunc *************** *** 1073,1140 **** filetype off endfunc - func Test_dep3patch_file() - filetype on - - call assert_true(mkdir('debian/patches', 'p')) - - " series files are not patches - call writefile(['Description: some awesome patch'], 'debian/patches/series') - split debian/patches/series - call assert_notequal('dep3patch', &filetype) - bwipe! - - " diff/patch files without the right headers should still show up as ft=diff - call writefile([], 'debian/patches/foo.diff') - split debian/patches/foo.diff - call assert_equal('diff', &filetype) - bwipe! - - " Files with the right headers are detected as dep3patch, even if they don't - " have a diff/patch extension - call writefile(['Subject: dep3patches'], 'debian/patches/bar') - split debian/patches/bar - call assert_equal('dep3patch', &filetype) - bwipe! - - " Files in sub-directories are detected - call assert_true(mkdir('debian/patches/s390x', 'p')) - call writefile(['Subject: dep3patches'], 'debian/patches/s390x/bar') - split debian/patches/s390x/bar - call assert_equal('dep3patch', &filetype) - bwipe! - - " The detection stops when seeing the "header end" marker - call writefile(['---', 'Origin: the cloud'], 'debian/patches/baz') - split debian/patches/baz - call assert_notequal('dep3patch', &filetype) - bwipe! - - call delete('debian', 'rf') - endfunc - - func Test_patch_file() - filetype on - - call writefile([], 'Xfile.patch') - split Xfile.patch - call assert_equal('diff', &filetype) - bwipe! - - call writefile(['From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001'], 'Xfile.patch') - split Xfile.patch - call assert_equal('gitsendemail', &filetype) - bwipe! - - call writefile(['From 0000000000000000000000000000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001'], 'Xfile.patch') - split Xfile.patch - call assert_equal('gitsendemail', &filetype) - bwipe! - - call delete('Xfile.patch') - filetype off - endfunc - func Test_git_file() filetype on --- 1050,1055 ---- *************** *** 1164,1308 **** filetype off endfunc ! func Test_foam_file() filetype on - call assert_true(mkdir('0', 'p')) - call assert_true(mkdir('0.orig', 'p')) ! call writefile(['FoamFile {', ' object something;'], 'Xfile1Dict') ! split Xfile1Dict ! call assert_equal('foam', &filetype) bwipe! ! call writefile(['FoamFile {', ' object something;'], 'Xfile1Dict.something') ! split Xfile1Dict.something ! call assert_equal('foam', &filetype) bwipe! ! call writefile(['FoamFile {', ' object something;'], 'XfileProperties') ! split XfileProperties ! call assert_equal('foam', &filetype) bwipe! ! call writefile(['FoamFile {', ' object something;'], 'XfileProperties.something') ! split XfileProperties.something ! call assert_equal('foam', &filetype) bwipe! ! call writefile(['FoamFile {', ' object something;'], 'XfileProperties') ! split XfileProperties ! call assert_equal('foam', &filetype) bwipe! ! call writefile(['FoamFile {', ' object something;'], 'XfileProperties.something') ! split XfileProperties.something ! call assert_equal('foam', &filetype) bwipe! ! call writefile(['FoamFile {', ' object something;'], '0/Xfile') ! split 0/Xfile ! call assert_equal('foam', &filetype) bwipe! ! call writefile(['FoamFile {', ' object something;'], '0.orig/Xfile') ! split 0.orig/Xfile ! call assert_equal('foam', &filetype) bwipe! ! call delete('0', 'rf') ! call delete('0.orig', 'rf') ! call delete('Xfile1Dict') ! call delete('Xfile1Dict.something') ! call delete('XfileProperties') ! call delete('XfileProperties.something') ! filetype off ! endfunc ! func Test_bas_file() ! filetype on ! call writefile(['looks like BASIC'], 'Xfile.bas') ! split Xfile.bas ! call assert_equal('basic', &filetype) bwipe! ! " Test dist#ft#FTbas() ! ! let g:filetype_bas = 'freebasic' ! split Xfile.bas ! call assert_equal('freebasic', &filetype) bwipe! - unlet g:filetype_bas ! " FreeBASIC ! call writefile(["/' FreeBASIC multiline comment '/"], 'Xfile.bas') ! split Xfile.bas ! call assert_equal('freebasic', &filetype) bwipe! ! call writefile(['#define TESTING'], 'Xfile.bas') ! split Xfile.bas ! call assert_equal('freebasic', &filetype) bwipe! ! call writefile(['option byval'], 'Xfile.bas') ! split Xfile.bas ! call assert_equal('freebasic', &filetype) bwipe! ! call writefile(['extern "C"'], 'Xfile.bas') ! split Xfile.bas ! call assert_equal('freebasic', &filetype) bwipe! ! " QB64 ! call writefile(['$LET TESTING = 1'], 'Xfile.bas') ! split Xfile.bas ! call assert_equal('qb64', &filetype) bwipe! ! call writefile(['OPTION _EXPLICIT'], 'Xfile.bas') ! split Xfile.bas ! call assert_equal('qb64', &filetype) bwipe! ! " Visual Basic ! call writefile(['Attribute VB_NAME = "Testing"'], 'Xfile.bas') ! split Xfile.bas ! call assert_equal('vb', &filetype) bwipe! ! call delete('Xfile.bas') filetype off endfunc ! func Test_frm_file() filetype on ! call writefile(['looks like FORM'], 'Xfile.frm') ! split Xfile.frm ! call assert_equal('form', &filetype) ! bwipe! ! " Test dist#ft#FTfrm() ! let g:filetype_frm = 'form' ! split Xfile.frm ! call assert_equal('form', &filetype) bwipe! - unlet g:filetype_frm ! " Visual Basic ! call writefile(['Begin VB.Form Form1'], 'Xfile.frm') ! split Xfile.frm ! call assert_equal('vb', &filetype) bwipe! ! call delete('Xfile.frm') filetype off endfunc --- 1079,1266 ---- filetype off endfunc ! func Test_hook_file() filetype on ! call writefile(['[Trigger]', 'this is pacman config'], 'Xfile.hook') ! split Xfile.hook ! call assert_equal('dosini', &filetype) bwipe! ! call writefile(['not pacman'], 'Xfile.hook') ! split Xfile.hook ! call assert_notequal('dosini', &filetype) bwipe! ! call delete('Xfile.hook') ! filetype off ! endfunc ! ! func Test_m_file() ! filetype on ! ! call writefile(['looks like Matlab'], 'Xfile.m') ! split Xfile.m ! call assert_equal('matlab', &filetype) bwipe! ! let g:filetype_m = 'octave' ! split Xfile.m ! call assert_equal('octave', &filetype) bwipe! + unlet g:filetype_m ! " Test dist#ft#FTm() ! ! " Objective-C ! ! call writefile(['// Objective-C line comment'], 'Xfile.m') ! split Xfile.m ! call assert_equal('objc', &filetype) bwipe! ! call writefile(['/* Objective-C block comment */'], 'Xfile.m') ! split Xfile.m ! call assert_equal('objc', &filetype) bwipe! ! call writefile(['#import "test.m"'], 'Xfile.m') ! split Xfile.m ! call assert_equal('objc', &filetype) bwipe! ! call writefile(['#include '], 'Xfile.m') ! split Xfile.m ! call assert_equal('objc', &filetype) bwipe! ! call writefile(['#define FORTY_TWO'], 'Xfile.m') ! split Xfile.m ! call assert_equal('objc', &filetype) ! bwipe! ! " Octave ! call writefile(['# Octave line comment'], 'Xfile.m') ! split Xfile.m ! call assert_equal('octave', &filetype) bwipe! ! call writefile(['%!test "Octave test"'], 'Xfile.m') ! split Xfile.m ! call assert_equal('octave', &filetype) bwipe! ! call writefile(['unwind_protect'], 'Xfile.m') ! split Xfile.m ! call assert_equal('octave', &filetype) ! bwipe! ! call writefile(['try; 42; end_try_catch'], 'Xfile.m') ! split Xfile.m ! call assert_equal('octave', &filetype) bwipe! ! " Mathematica ! ! call writefile(['(* Mathematica comment'], 'Xfile.m') ! split Xfile.m ! call assert_equal('mma', &filetype) bwipe! ! " MATLAB ! ! call writefile(['% MATLAB line comment'], 'Xfile.m') ! split Xfile.m ! call assert_equal('matlab', &filetype) bwipe! ! " Murphi ! ! call writefile(['-- Murphi comment'], 'Xfile.m') ! split Xfile.m ! call assert_equal('murphi', &filetype) bwipe! ! call writefile(['/* Murphi block comment */', 'Type'], 'Xfile.m') ! split Xfile.m ! call assert_equal('murphi', &filetype) ! bwipe! ! call writefile(['Type'], 'Xfile.m') ! split Xfile.m ! call assert_equal('murphi', &filetype) bwipe! ! call delete('Xfile.m') ! filetype off ! endfunc ! ! func Test_patch_file() ! filetype on ! ! call writefile([], 'Xfile.patch') ! split Xfile.patch ! call assert_equal('diff', &filetype) bwipe! ! call writefile(['From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001'], 'Xfile.patch') ! split Xfile.patch ! call assert_equal('gitsendemail', &filetype) ! bwipe! ! call writefile(['From 0000000000000000000000000000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001'], 'Xfile.patch') ! split Xfile.patch ! call assert_equal('gitsendemail', &filetype) bwipe! ! call delete('Xfile.patch') filetype off endfunc ! func Test_perl_file() filetype on ! " only tests one case, should do more ! let lines =<< trim END ! use a ! END ! call writefile(lines, "Xfile.t") ! split Xfile.t ! call assert_equal('perl', &filetype) ! bwipe ! call delete('Xfile.t') ! filetype off ! endfunc ! ! func Test_pp_file() ! filetype on ! ! call writefile(['looks like puppet'], 'Xfile.pp') ! split Xfile.pp ! call assert_equal('puppet', &filetype) bwipe! ! let g:filetype_pp = 'pascal' ! split Xfile.pp ! call assert_equal('pascal', &filetype) ! bwipe! ! unlet g:filetype_pp ! " Test dist#ft#FTpp() ! call writefile(['{ pascal comment'], 'Xfile.pp') ! split Xfile.pp ! call assert_equal('pascal', &filetype) bwipe! ! call writefile(['procedure pascal'], 'Xfile.pp') ! split Xfile.pp ! call assert_equal('pascal', &filetype) ! bwipe! ! ! call delete('Xfile.pp') filetype off endfunc *************** *** 1324,1328 **** --- 1282,1349 ---- filetype off endfunc + func Test_tf_file() + filetype on + + call writefile([';;; TF MUD client is super duper cool'], 'Xfile.tf') + split Xfile.tf + call assert_equal('tf', &filetype) + bwipe! + + call writefile(['provider "azurerm" {'], 'Xfile.tf') + split Xfile.tf + call assert_equal('terraform', &filetype) + bwipe! + + call delete('Xfile.tf') + filetype off + endfunc + + func Test_ts_file() + filetype on + + call writefile([''], 'Xfile.ts') + split Xfile.ts + call assert_equal('xml', &filetype) + bwipe! + + call writefile(['// looks like Typescript'], 'Xfile.ts') + split Xfile.ts + call assert_equal('typescript', &filetype) + bwipe! + + call delete('Xfile.ts') + filetype off + endfunc + + func Test_ttl_file() + filetype on + + call writefile(['@base .'], 'Xfile.ttl') + split Xfile.ttl + call assert_equal('turtle', &filetype) + bwipe! + + call writefile(['looks like Tera Term Language'], 'Xfile.ttl') + split Xfile.ttl + call assert_equal('teraterm', &filetype) + bwipe! + + call delete('Xfile.ttl') + filetype off + endfunc + + func Test_xpm_file() + filetype on + + call writefile(['this is XPM2'], 'file.xpm') + split file.xpm + call assert_equal('xpm2', &filetype) + bwipe! + + call delete('file.xpm') + filetype off + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.4305/src/version.c 2022-02-05 19:49:29.947540471 +0000 --- src/version.c 2022-02-05 20:21:24.940966668 +0000 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 4306, /**/ -- The goal of science is to build better mousetraps. The goal of nature is to build better mice. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///