aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-08-23 19:32:11 +0800
committerGitHub <noreply@github.com>2023-08-23 19:32:11 +0800
commit08fa71fd274530be23b6ae6b10222afee0b57522 (patch)
treec53c140547720c821d377020c9f4b007fcbbc7ee /test
parent2234b84a1b85832667ad4a23fd5dee0bd1c92b72 (diff)
downloadrneovim-08fa71fd274530be23b6ae6b10222afee0b57522.tar.gz
rneovim-08fa71fd274530be23b6ae6b10222afee0b57522.tar.bz2
rneovim-08fa71fd274530be23b6ae6b10222afee0b57522.zip
vim-patch:9.0.1773: cannot distinguish Forth and Fortran *.f files (#24841)
Problem: cannot distinguish Forth and Fortran *.f files Solution: Add Filetype detection Code Also add *.4th as a Forth filetype closes: vim/vim#12251 https://github.com/vim/vim/commit/19a3bc3addf9b4aa8150a01b11b4249c67d15d3b Don't remove filetype files from Vim patches: - filetype.vim, script.vim, ft.vim usually contain useful changes - script.vim and ft.vim don't even have their paths spelled correctly Co-authored-by: Doug Kearns <dougkearns@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/old/testdir/test_filetype.vim64
1 files changed, 62 insertions, 2 deletions
diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim
index f11c0ffc31..3ce8e49b27 100644
--- a/test/old/testdir/test_filetype.vim
+++ b/test/old/testdir/test_filetype.vim
@@ -236,7 +236,7 @@ func s:GetFilenameChecks() abort
\ 'fish': ['file.fish'],
\ 'focexec': ['file.fex', 'file.focexec'],
\ 'form': ['file.frm'],
- \ 'forth': ['file.ft', 'file.fth'],
+ \ 'forth': ['file.ft', 'file.fth', 'file.4th'],
\ 'fortran': ['file.f', 'file.for', 'file.fortran', 'file.fpp', 'file.ftn', 'file.f77', 'file.f90', 'file.f95', 'file.f03', 'file.f08'],
\ 'fpcmake': ['file.fpc'],
\ 'framescript': ['file.fsl'],
@@ -1173,6 +1173,54 @@ func Test_ex_file()
filetype off
endfunc
+func Test_f_file()
+ filetype on
+
+ call writefile(['looks like Fortran'], 'Xfile.f', 'D')
+ split Xfile.f
+ call assert_equal('fortran', &filetype)
+ bwipe!
+
+ let g:filetype_f = 'forth'
+ split Xfile.f
+ call assert_equal('forth', &filetype)
+ bwipe!
+ unlet g:filetype_f
+
+ " Test dist#ft#FTf()
+
+ " Forth
+
+ call writefile(['( Forth inline comment )'], 'Xfile.f')
+ split Xfile.f
+ call assert_equal('forth', &filetype)
+ bwipe!
+
+ call writefile(['\ Forth line comment'], 'Xfile.f')
+ split Xfile.f
+ call assert_equal('forth', &filetype)
+ bwipe!
+
+ call writefile([': squared ( n -- n^2 )', 'dup * ;'], 'Xfile.f')
+ split Xfile.f
+ call assert_equal('forth', &filetype)
+ bwipe!
+
+ " SwiftForth
+
+ call writefile(['{ ================', 'Header comment', '================ }'], 'Xfile.f')
+ split Xfile.f
+ call assert_equal('forth', &filetype)
+ bwipe!
+
+ call writefile(['OPTIONAL Maybe Descriptive text'], 'Xfile.f')
+ split Xfile.f
+ call assert_equal('forth', &filetype)
+ bwipe!
+
+ filetype off
+endfunc
+
func Test_foam_file()
filetype on
call assert_true(mkdir('0', 'pR'))
@@ -1263,7 +1311,7 @@ func Test_fs_file()
" Test dist#ft#FTfs()
- " Forth (Gforth)
+ " Forth
call writefile(['( Forth inline comment )'], 'Xfile.fs')
split Xfile.fs
@@ -1280,6 +1328,18 @@ func Test_fs_file()
call assert_equal('forth', &filetype)
bwipe!
+ " SwiftForth
+
+ call writefile(['{ ================', 'Header comment', '================ }'], 'Xfile.fs')
+ split Xfile.fs
+ call assert_equal('forth', &filetype)
+ bwipe!
+
+ call writefile(['OPTIONAL Maybe Descriptive text'], 'Xfile.fs')
+ split Xfile.fs
+ call assert_equal('forth', &filetype)
+ bwipe!
+
filetype off
endfunc