comparison src/testdir/test_filetype.vim @ 27559:663dece3743a v8.2.4306

patch 8.2.4306: no test for fixed perl filetype check Commit: https://github.com/vim/vim/commit/500761b1cf666f030009d2dcdacfdce28f68f43d Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 5 20:23:59 2022 +0000 patch 8.2.4306: no test for fixed perl filetype check Problem: No test for fixed perl filetype check. Solution: Add a test. Sort test functions.
author Bram Moolenaar <Bram@vim.org>
date Sat, 05 Feb 2022 21:30:03 +0100
parents ce72087b601f
children 52bbe3590f50
comparison
equal deleted inserted replaced
27558:fe527f3590ed 27559:663dece3743a
754 call assert_equal(['filetype detection:ON plugin:OFF indent:OFF'], 754 call assert_equal(['filetype detection:ON plugin:OFF indent:OFF'],
755 \ execute('filetype')->split("\n")) 755 \ execute('filetype')->split("\n"))
756 close 756 close
757 endfunc 757 endfunc
758 758
759 func Test_hook_file() 759 """""""""""""""""""""""""""""""""""""""""""""""""
760 filetype on 760 " Tests for specific extentions and filetypes.
761 761 " Keep sorted.
762 call writefile(['[Trigger]', 'this is pacman config'], 'Xfile.hook') 762 """""""""""""""""""""""""""""""""""""""""""""""""
763 split Xfile.hook 763
764 call assert_equal('dosini', &filetype) 764 func Test_bas_file()
765 bwipe! 765 filetype on
766 766
767 call writefile(['not pacman'], 'Xfile.hook') 767 call writefile(['looks like BASIC'], 'Xfile.bas')
768 split Xfile.hook 768 split Xfile.bas
769 call assert_notequal('dosini', &filetype) 769 call assert_equal('basic', &filetype)
770 bwipe! 770 bwipe!
771 771
772 call delete('Xfile.hook') 772 " Test dist#ft#FTbas()
773 filetype off 773
774 endfunc 774 let g:filetype_bas = 'freebasic'
775 775 split Xfile.bas
776 func Test_tf_file() 776 call assert_equal('freebasic', &filetype)
777 filetype on 777 bwipe!
778 778 unlet g:filetype_bas
779 call writefile([';;; TF MUD client is super duper cool'], 'Xfile.tf') 779
780 split Xfile.tf 780 " FreeBASIC
781 call assert_equal('tf', &filetype) 781
782 bwipe! 782 call writefile(["/' FreeBASIC multiline comment '/"], 'Xfile.bas')
783 783 split Xfile.bas
784 call writefile(['provider "azurerm" {'], 'Xfile.tf') 784 call assert_equal('freebasic', &filetype)
785 split Xfile.tf 785 bwipe!
786 call assert_equal('terraform', &filetype) 786
787 bwipe! 787 call writefile(['#define TESTING'], 'Xfile.bas')
788 788 split Xfile.bas
789 call delete('Xfile.tf') 789 call assert_equal('freebasic', &filetype)
790 filetype off 790 bwipe!
791 endfunc 791
792 792 call writefile(['option byval'], 'Xfile.bas')
793 793 split Xfile.bas
794 func Test_ts_file() 794 call assert_equal('freebasic', &filetype)
795 filetype on 795 bwipe!
796 796
797 call writefile(['<?xml version="1.0" encoding="utf-8"?>'], 'Xfile.ts') 797 call writefile(['extern "C"'], 'Xfile.bas')
798 split Xfile.ts 798 split Xfile.bas
799 call assert_equal('xml', &filetype) 799 call assert_equal('freebasic', &filetype)
800 bwipe! 800 bwipe!
801 801
802 call writefile(['// looks like Typescript'], 'Xfile.ts') 802 " QB64
803 split Xfile.ts 803
804 call assert_equal('typescript', &filetype) 804 call writefile(['$LET TESTING = 1'], 'Xfile.bas')
805 bwipe! 805 split Xfile.bas
806 806 call assert_equal('qb64', &filetype)
807 call delete('Xfile.ts') 807 bwipe!
808 filetype off 808
809 endfunc 809 call writefile(['OPTION _EXPLICIT'], 'Xfile.bas')
810 810 split Xfile.bas
811 func Test_ttl_file() 811 call assert_equal('qb64', &filetype)
812 filetype on 812 bwipe!
813 813
814 call writefile(['@base <http://example.org/> .'], 'Xfile.ttl') 814 " Visual Basic
815 split Xfile.ttl 815
816 call assert_equal('turtle', &filetype) 816 call writefile(['Attribute VB_NAME = "Testing"'], 'Xfile.bas')
817 bwipe! 817 split Xfile.bas
818 818 call assert_equal('vb', &filetype)
819 call writefile(['looks like Tera Term Language'], 'Xfile.ttl') 819 bwipe!
820 split Xfile.ttl 820
821 call assert_equal('teraterm', &filetype) 821 call delete('Xfile.bas')
822 bwipe!
823
824 call delete('Xfile.ttl')
825 filetype off
826 endfunc
827
828 func Test_pp_file()
829 filetype on
830
831 call writefile(['looks like puppet'], 'Xfile.pp')
832 split Xfile.pp
833 call assert_equal('puppet', &filetype)
834 bwipe!
835
836 let g:filetype_pp = 'pascal'
837 split Xfile.pp
838 call assert_equal('pascal', &filetype)
839 bwipe!
840 unlet g:filetype_pp
841
842 " Test dist#ft#FTpp()
843 call writefile(['{ pascal comment'], 'Xfile.pp')
844 split Xfile.pp
845 call assert_equal('pascal', &filetype)
846 bwipe!
847
848 call writefile(['procedure pascal'], 'Xfile.pp')
849 split Xfile.pp
850 call assert_equal('pascal', &filetype)
851 bwipe!
852
853 call delete('Xfile.pp')
854 filetype off
855 endfunc
856
857 func Test_ex_file()
858 filetype on
859
860 call writefile(['arbitrary content'], 'Xfile.ex')
861 split Xfile.ex
862 call assert_equal('elixir', &filetype)
863 bwipe!
864 let g:filetype_euphoria = 'euphoria4'
865 split Xfile.ex
866 call assert_equal('euphoria4', &filetype)
867 bwipe!
868 unlet g:filetype_euphoria
869
870 call writefile(['-- filetype euphoria comment'], 'Xfile.ex')
871 split Xfile.ex
872 call assert_equal('euphoria3', &filetype)
873 bwipe!
874
875 call writefile(['--filetype euphoria comment'], 'Xfile.ex')
876 split Xfile.ex
877 call assert_equal('euphoria3', &filetype)
878 bwipe!
879
880 call writefile(['ifdef '], 'Xfile.ex')
881 split Xfile.ex
882 call assert_equal('euphoria3', &filetype)
883 bwipe!
884
885 call writefile(['include '], 'Xfile.ex')
886 split Xfile.ex
887 call assert_equal('euphoria3', &filetype)
888 bwipe!
889
890 call delete('Xfile.ex')
891 filetype off
892 endfunc
893
894 func Test_dsl_file()
895 filetype on
896
897 call writefile([' <!doctype dsssl-spec ['], 'dslfile.dsl')
898 split dslfile.dsl
899 call assert_equal('dsl', &filetype)
900 bwipe!
901
902 call writefile(['workspace {'], 'dslfile.dsl')
903 split dslfile.dsl
904 call assert_equal('structurizr', &filetype)
905 bwipe!
906
907 call delete('dslfile.dsl')
908 filetype off
909 endfunc
910
911 func Test_m_file()
912 filetype on
913
914 call writefile(['looks like Matlab'], 'Xfile.m')
915 split Xfile.m
916 call assert_equal('matlab', &filetype)
917 bwipe!
918
919 let g:filetype_m = 'octave'
920 split Xfile.m
921 call assert_equal('octave', &filetype)
922 bwipe!
923 unlet g:filetype_m
924
925 " Test dist#ft#FTm()
926
927 " Objective-C
928
929 call writefile(['// Objective-C line comment'], 'Xfile.m')
930 split Xfile.m
931 call assert_equal('objc', &filetype)
932 bwipe!
933
934 call writefile(['/* Objective-C block comment */'], 'Xfile.m')
935 split Xfile.m
936 call assert_equal('objc', &filetype)
937 bwipe!
938
939 call writefile(['#import "test.m"'], 'Xfile.m')
940 split Xfile.m
941 call assert_equal('objc', &filetype)
942 bwipe!
943
944 call writefile(['#include <header.h>'], 'Xfile.m')
945 split Xfile.m
946 call assert_equal('objc', &filetype)
947 bwipe!
948
949 call writefile(['#define FORTY_TWO'], 'Xfile.m')
950 split Xfile.m
951 call assert_equal('objc', &filetype)
952 bwipe!
953
954 " Octave
955
956 call writefile(['# Octave line comment'], 'Xfile.m')
957 split Xfile.m
958 call assert_equal('octave', &filetype)
959 bwipe!
960
961 call writefile(['%!test "Octave test"'], 'Xfile.m')
962 split Xfile.m
963 call assert_equal('octave', &filetype)
964 bwipe!
965
966 call writefile(['unwind_protect'], 'Xfile.m')
967 split Xfile.m
968 call assert_equal('octave', &filetype)
969 bwipe!
970
971 call writefile(['try; 42; end_try_catch'], 'Xfile.m')
972 split Xfile.m
973 call assert_equal('octave', &filetype)
974 bwipe!
975
976 " Mathematica
977
978 call writefile(['(* Mathematica comment'], 'Xfile.m')
979 split Xfile.m
980 call assert_equal('mma', &filetype)
981 bwipe!
982
983 " MATLAB
984
985 call writefile(['% MATLAB line comment'], 'Xfile.m')
986 split Xfile.m
987 call assert_equal('matlab', &filetype)
988 bwipe!
989
990 " Murphi
991
992 call writefile(['-- Murphi comment'], 'Xfile.m')
993 split Xfile.m
994 call assert_equal('murphi', &filetype)
995 bwipe!
996
997 call writefile(['/* Murphi block comment */', 'Type'], 'Xfile.m')
998 split Xfile.m
999 call assert_equal('murphi', &filetype)
1000 bwipe!
1001
1002 call writefile(['Type'], 'Xfile.m')
1003 split Xfile.m
1004 call assert_equal('murphi', &filetype)
1005 bwipe!
1006
1007 call delete('Xfile.m')
1008 filetype off
1009 endfunc
1010
1011 func Test_xpm_file()
1012 filetype on
1013
1014 call writefile(['this is XPM2'], 'file.xpm')
1015 split file.xpm
1016 call assert_equal('xpm2', &filetype)
1017 bwipe!
1018
1019 call delete('file.xpm')
1020 filetype off
1021 endfunc
1022
1023 func Test_fs_file()
1024 filetype on
1025
1026 call writefile(['looks like F#'], 'Xfile.fs')
1027 split Xfile.fs
1028 call assert_equal('fsharp', &filetype)
1029 bwipe!
1030
1031 let g:filetype_fs = 'forth'
1032 split Xfile.fs
1033 call assert_equal('forth', &filetype)
1034 bwipe!
1035 unlet g:filetype_fs
1036
1037 " Test dist#ft#FTfs()
1038
1039 " Forth (Gforth)
1040
1041 call writefile(['( Forth inline comment )'], 'Xfile.fs')
1042 split Xfile.fs
1043 call assert_equal('forth', &filetype)
1044 bwipe!
1045
1046 call writefile(['.( Forth displayed inline comment )'], 'Xfile.fs')
1047 split Xfile.fs
1048 call assert_equal('forth', &filetype)
1049 bwipe!
1050
1051 call writefile(['\ Forth line comment'], 'Xfile.fs')
1052 split Xfile.fs
1053 call assert_equal('forth', &filetype)
1054 bwipe!
1055
1056 " empty line comment - no space required
1057 call writefile(['\'], 'Xfile.fs')
1058 split Xfile.fs
1059 call assert_equal('forth', &filetype)
1060 bwipe!
1061
1062 call writefile(['\G Forth documentation comment '], 'Xfile.fs')
1063 split Xfile.fs
1064 call assert_equal('forth', &filetype)
1065 bwipe!
1066
1067 call writefile([': squared ( n -- n^2 )', 'dup * ;'], 'Xfile.fs')
1068 split Xfile.fs
1069 call assert_equal('forth', &filetype)
1070 bwipe!
1071
1072 call delete('Xfile.fs')
1073 filetype off 822 filetype off
1074 endfunc 823 endfunc
1075 824
1076 func Test_dep3patch_file() 825 func Test_dep3patch_file()
1077 filetype on 826 filetype on
1111 bwipe! 860 bwipe!
1112 861
1113 call delete('debian', 'rf') 862 call delete('debian', 'rf')
1114 endfunc 863 endfunc
1115 864
1116 func Test_patch_file() 865 func Test_dsl_file()
1117 filetype on 866 filetype on
1118 867
1119 call writefile([], 'Xfile.patch') 868 call writefile([' <!doctype dsssl-spec ['], 'dslfile.dsl')
1120 split Xfile.patch 869 split dslfile.dsl
1121 call assert_equal('diff', &filetype) 870 call assert_equal('dsl', &filetype)
1122 bwipe! 871 bwipe!
1123 872
1124 call writefile(['From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001'], 'Xfile.patch') 873 call writefile(['workspace {'], 'dslfile.dsl')
1125 split Xfile.patch 874 split dslfile.dsl
1126 call assert_equal('gitsendemail', &filetype) 875 call assert_equal('structurizr', &filetype)
1127 bwipe! 876 bwipe!
1128 877
1129 call writefile(['From 0000000000000000000000000000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001'], 'Xfile.patch') 878 call delete('dslfile.dsl')
1130 split Xfile.patch 879 filetype off
1131 call assert_equal('gitsendemail', &filetype) 880 endfunc
1132 bwipe! 881
1133 882 func Test_ex_file()
1134 call delete('Xfile.patch') 883 filetype on
1135 filetype off 884
1136 endfunc 885 call writefile(['arbitrary content'], 'Xfile.ex')
1137 886 split Xfile.ex
1138 func Test_git_file() 887 call assert_equal('elixir', &filetype)
1139 filetype on 888 bwipe!
1140 889 let g:filetype_euphoria = 'euphoria4'
1141 call assert_true(mkdir('Xrepo.git', 'p')) 890 split Xfile.ex
1142 891 call assert_equal('euphoria4', &filetype)
1143 call writefile([], 'Xrepo.git/HEAD') 892 bwipe!
1144 split Xrepo.git/HEAD 893 unlet g:filetype_euphoria
1145 call assert_equal('', &filetype) 894
1146 bwipe! 895 call writefile(['-- filetype euphoria comment'], 'Xfile.ex')
1147 896 split Xfile.ex
1148 call writefile(['0000000000000000000000000000000000000000'], 'Xrepo.git/HEAD') 897 call assert_equal('euphoria3', &filetype)
1149 split Xrepo.git/HEAD 898 bwipe!
1150 call assert_equal('git', &filetype) 899
1151 bwipe! 900 call writefile(['--filetype euphoria comment'], 'Xfile.ex')
1152 901 split Xfile.ex
1153 call writefile(['0000000000000000000000000000000000000000000000000000000000000000'], 'Xrepo.git/HEAD') 902 call assert_equal('euphoria3', &filetype)
1154 split Xrepo.git/HEAD 903 bwipe!
1155 call assert_equal('git', &filetype) 904
1156 bwipe! 905 call writefile(['ifdef '], 'Xfile.ex')
1157 906 split Xfile.ex
1158 call writefile(['ref: refs/heads/master'], 'Xrepo.git/HEAD') 907 call assert_equal('euphoria3', &filetype)
1159 split Xrepo.git/HEAD 908 bwipe!
1160 call assert_equal('git', &filetype) 909
1161 bwipe! 910 call writefile(['include '], 'Xfile.ex')
1162 911 split Xfile.ex
1163 call delete('Xrepo.git', 'rf') 912 call assert_equal('euphoria3', &filetype)
913 bwipe!
914
915 call delete('Xfile.ex')
1164 filetype off 916 filetype off
1165 endfunc 917 endfunc
1166 918
1167 func Test_foam_file() 919 func Test_foam_file()
1168 filetype on 920 filetype on
1216 call delete('XfileProperties') 968 call delete('XfileProperties')
1217 call delete('XfileProperties.something') 969 call delete('XfileProperties.something')
1218 filetype off 970 filetype off
1219 endfunc 971 endfunc
1220 972
1221 func Test_bas_file()
1222 filetype on
1223
1224 call writefile(['looks like BASIC'], 'Xfile.bas')
1225 split Xfile.bas
1226 call assert_equal('basic', &filetype)
1227 bwipe!
1228
1229 " Test dist#ft#FTbas()
1230
1231 let g:filetype_bas = 'freebasic'
1232 split Xfile.bas
1233 call assert_equal('freebasic', &filetype)
1234 bwipe!
1235 unlet g:filetype_bas
1236
1237 " FreeBASIC
1238
1239 call writefile(["/' FreeBASIC multiline comment '/"], 'Xfile.bas')
1240 split Xfile.bas
1241 call assert_equal('freebasic', &filetype)
1242 bwipe!
1243
1244 call writefile(['#define TESTING'], 'Xfile.bas')
1245 split Xfile.bas
1246 call assert_equal('freebasic', &filetype)
1247 bwipe!
1248
1249 call writefile(['option byval'], 'Xfile.bas')
1250 split Xfile.bas
1251 call assert_equal('freebasic', &filetype)
1252 bwipe!
1253
1254 call writefile(['extern "C"'], 'Xfile.bas')
1255 split Xfile.bas
1256 call assert_equal('freebasic', &filetype)
1257 bwipe!
1258
1259 " QB64
1260
1261 call writefile(['$LET TESTING = 1'], 'Xfile.bas')
1262 split Xfile.bas
1263 call assert_equal('qb64', &filetype)
1264 bwipe!
1265
1266 call writefile(['OPTION _EXPLICIT'], 'Xfile.bas')
1267 split Xfile.bas
1268 call assert_equal('qb64', &filetype)
1269 bwipe!
1270
1271 " Visual Basic
1272
1273 call writefile(['Attribute VB_NAME = "Testing"'], 'Xfile.bas')
1274 split Xfile.bas
1275 call assert_equal('vb', &filetype)
1276 bwipe!
1277
1278 call delete('Xfile.bas')
1279 filetype off
1280 endfunc
1281
1282 func Test_frm_file() 973 func Test_frm_file()
1283 filetype on 974 filetype on
1284 975
1285 call writefile(['looks like FORM'], 'Xfile.frm') 976 call writefile(['looks like FORM'], 'Xfile.frm')
1286 split Xfile.frm 977 split Xfile.frm
1301 split Xfile.frm 992 split Xfile.frm
1302 call assert_equal('vb', &filetype) 993 call assert_equal('vb', &filetype)
1303 bwipe! 994 bwipe!
1304 995
1305 call delete('Xfile.frm') 996 call delete('Xfile.frm')
997 filetype off
998 endfunc
999
1000 func Test_fs_file()
1001 filetype on
1002
1003 call writefile(['looks like F#'], 'Xfile.fs')
1004 split Xfile.fs
1005 call assert_equal('fsharp', &filetype)
1006 bwipe!
1007
1008 let g:filetype_fs = 'forth'
1009 split Xfile.fs
1010 call assert_equal('forth', &filetype)
1011 bwipe!
1012 unlet g:filetype_fs
1013
1014 " Test dist#ft#FTfs()
1015
1016 " Forth (Gforth)
1017
1018 call writefile(['( Forth inline comment )'], 'Xfile.fs')
1019 split Xfile.fs
1020 call assert_equal('forth', &filetype)
1021 bwipe!
1022
1023 call writefile(['.( Forth displayed inline comment )'], 'Xfile.fs')
1024 split Xfile.fs
1025 call assert_equal('forth', &filetype)
1026 bwipe!
1027
1028 call writefile(['\ Forth line comment'], 'Xfile.fs')
1029 split Xfile.fs
1030 call assert_equal('forth', &filetype)
1031 bwipe!
1032
1033 " empty line comment - no space required
1034 call writefile(['\'], 'Xfile.fs')
1035 split Xfile.fs
1036 call assert_equal('forth', &filetype)
1037 bwipe!
1038
1039 call writefile(['\G Forth documentation comment '], 'Xfile.fs')
1040 split Xfile.fs
1041 call assert_equal('forth', &filetype)
1042 bwipe!
1043
1044 call writefile([': squared ( n -- n^2 )', 'dup * ;'], 'Xfile.fs')
1045 split Xfile.fs
1046 call assert_equal('forth', &filetype)
1047 bwipe!
1048
1049 call delete('Xfile.fs')
1050 filetype off
1051 endfunc
1052
1053 func Test_git_file()
1054 filetype on
1055
1056 call assert_true(mkdir('Xrepo.git', 'p'))
1057
1058 call writefile([], 'Xrepo.git/HEAD')
1059 split Xrepo.git/HEAD
1060 call assert_equal('', &filetype)
1061 bwipe!
1062
1063 call writefile(['0000000000000000000000000000000000000000'], 'Xrepo.git/HEAD')
1064 split Xrepo.git/HEAD
1065 call assert_equal('git', &filetype)
1066 bwipe!
1067
1068 call writefile(['0000000000000000000000000000000000000000000000000000000000000000'], 'Xrepo.git/HEAD')
1069 split Xrepo.git/HEAD
1070 call assert_equal('git', &filetype)
1071 bwipe!
1072
1073 call writefile(['ref: refs/heads/master'], 'Xrepo.git/HEAD')
1074 split Xrepo.git/HEAD
1075 call assert_equal('git', &filetype)
1076 bwipe!
1077
1078 call delete('Xrepo.git', 'rf')
1079 filetype off
1080 endfunc
1081
1082 func Test_hook_file()
1083 filetype on
1084
1085 call writefile(['[Trigger]', 'this is pacman config'], 'Xfile.hook')
1086 split Xfile.hook
1087 call assert_equal('dosini', &filetype)
1088 bwipe!
1089
1090 call writefile(['not pacman'], 'Xfile.hook')
1091 split Xfile.hook
1092 call assert_notequal('dosini', &filetype)
1093 bwipe!
1094
1095 call delete('Xfile.hook')
1096 filetype off
1097 endfunc
1098
1099 func Test_m_file()
1100 filetype on
1101
1102 call writefile(['looks like Matlab'], 'Xfile.m')
1103 split Xfile.m
1104 call assert_equal('matlab', &filetype)
1105 bwipe!
1106
1107 let g:filetype_m = 'octave'
1108 split Xfile.m
1109 call assert_equal('octave', &filetype)
1110 bwipe!
1111 unlet g:filetype_m
1112
1113 " Test dist#ft#FTm()
1114
1115 " Objective-C
1116
1117 call writefile(['// Objective-C line comment'], 'Xfile.m')
1118 split Xfile.m
1119 call assert_equal('objc', &filetype)
1120 bwipe!
1121
1122 call writefile(['/* Objective-C block comment */'], 'Xfile.m')
1123 split Xfile.m
1124 call assert_equal('objc', &filetype)
1125 bwipe!
1126
1127 call writefile(['#import "test.m"'], 'Xfile.m')
1128 split Xfile.m
1129 call assert_equal('objc', &filetype)
1130 bwipe!
1131
1132 call writefile(['#include <header.h>'], 'Xfile.m')
1133 split Xfile.m
1134 call assert_equal('objc', &filetype)
1135 bwipe!
1136
1137 call writefile(['#define FORTY_TWO'], 'Xfile.m')
1138 split Xfile.m
1139 call assert_equal('objc', &filetype)
1140 bwipe!
1141
1142 " Octave
1143
1144 call writefile(['# Octave line comment'], 'Xfile.m')
1145 split Xfile.m
1146 call assert_equal('octave', &filetype)
1147 bwipe!
1148
1149 call writefile(['%!test "Octave test"'], 'Xfile.m')
1150 split Xfile.m
1151 call assert_equal('octave', &filetype)
1152 bwipe!
1153
1154 call writefile(['unwind_protect'], 'Xfile.m')
1155 split Xfile.m
1156 call assert_equal('octave', &filetype)
1157 bwipe!
1158
1159 call writefile(['try; 42; end_try_catch'], 'Xfile.m')
1160 split Xfile.m
1161 call assert_equal('octave', &filetype)
1162 bwipe!
1163
1164 " Mathematica
1165
1166 call writefile(['(* Mathematica comment'], 'Xfile.m')
1167 split Xfile.m
1168 call assert_equal('mma', &filetype)
1169 bwipe!
1170
1171 " MATLAB
1172
1173 call writefile(['% MATLAB line comment'], 'Xfile.m')
1174 split Xfile.m
1175 call assert_equal('matlab', &filetype)
1176 bwipe!
1177
1178 " Murphi
1179
1180 call writefile(['-- Murphi comment'], 'Xfile.m')
1181 split Xfile.m
1182 call assert_equal('murphi', &filetype)
1183 bwipe!
1184
1185 call writefile(['/* Murphi block comment */', 'Type'], 'Xfile.m')
1186 split Xfile.m
1187 call assert_equal('murphi', &filetype)
1188 bwipe!
1189
1190 call writefile(['Type'], 'Xfile.m')
1191 split Xfile.m
1192 call assert_equal('murphi', &filetype)
1193 bwipe!
1194
1195 call delete('Xfile.m')
1196 filetype off
1197 endfunc
1198
1199 func Test_patch_file()
1200 filetype on
1201
1202 call writefile([], 'Xfile.patch')
1203 split Xfile.patch
1204 call assert_equal('diff', &filetype)
1205 bwipe!
1206
1207 call writefile(['From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001'], 'Xfile.patch')
1208 split Xfile.patch
1209 call assert_equal('gitsendemail', &filetype)
1210 bwipe!
1211
1212 call writefile(['From 0000000000000000000000000000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001'], 'Xfile.patch')
1213 split Xfile.patch
1214 call assert_equal('gitsendemail', &filetype)
1215 bwipe!
1216
1217 call delete('Xfile.patch')
1218 filetype off
1219 endfunc
1220
1221 func Test_perl_file()
1222 filetype on
1223
1224 " only tests one case, should do more
1225 let lines =<< trim END
1226
1227 use a
1228 END
1229 call writefile(lines, "Xfile.t")
1230 split Xfile.t
1231 call assert_equal('perl', &filetype)
1232 bwipe
1233
1234 call delete('Xfile.t')
1235 filetype off
1236 endfunc
1237
1238 func Test_pp_file()
1239 filetype on
1240
1241 call writefile(['looks like puppet'], 'Xfile.pp')
1242 split Xfile.pp
1243 call assert_equal('puppet', &filetype)
1244 bwipe!
1245
1246 let g:filetype_pp = 'pascal'
1247 split Xfile.pp
1248 call assert_equal('pascal', &filetype)
1249 bwipe!
1250 unlet g:filetype_pp
1251
1252 " Test dist#ft#FTpp()
1253 call writefile(['{ pascal comment'], 'Xfile.pp')
1254 split Xfile.pp
1255 call assert_equal('pascal', &filetype)
1256 bwipe!
1257
1258 call writefile(['procedure pascal'], 'Xfile.pp')
1259 split Xfile.pp
1260 call assert_equal('pascal', &filetype)
1261 bwipe!
1262
1263 call delete('Xfile.pp')
1306 filetype off 1264 filetype off
1307 endfunc 1265 endfunc
1308 1266
1309 func Test_tex_file() 1267 func Test_tex_file()
1310 filetype on 1268 filetype on
1322 1280
1323 call delete('Xfile.tex') 1281 call delete('Xfile.tex')
1324 filetype off 1282 filetype off
1325 endfunc 1283 endfunc
1326 1284
1285 func Test_tf_file()
1286 filetype on
1287
1288 call writefile([';;; TF MUD client is super duper cool'], 'Xfile.tf')
1289 split Xfile.tf
1290 call assert_equal('tf', &filetype)
1291 bwipe!
1292
1293 call writefile(['provider "azurerm" {'], 'Xfile.tf')
1294 split Xfile.tf
1295 call assert_equal('terraform', &filetype)
1296 bwipe!
1297
1298 call delete('Xfile.tf')
1299 filetype off
1300 endfunc
1301
1302 func Test_ts_file()
1303 filetype on
1304
1305 call writefile(['<?xml version="1.0" encoding="utf-8"?>'], 'Xfile.ts')
1306 split Xfile.ts
1307 call assert_equal('xml', &filetype)
1308 bwipe!
1309
1310 call writefile(['// looks like Typescript'], 'Xfile.ts')
1311 split Xfile.ts
1312 call assert_equal('typescript', &filetype)
1313 bwipe!
1314
1315 call delete('Xfile.ts')
1316 filetype off
1317 endfunc
1318
1319 func Test_ttl_file()
1320 filetype on
1321
1322 call writefile(['@base <http://example.org/> .'], 'Xfile.ttl')
1323 split Xfile.ttl
1324 call assert_equal('turtle', &filetype)
1325 bwipe!
1326
1327 call writefile(['looks like Tera Term Language'], 'Xfile.ttl')
1328 split Xfile.ttl
1329 call assert_equal('teraterm', &filetype)
1330 bwipe!
1331
1332 call delete('Xfile.ttl')
1333 filetype off
1334 endfunc
1335
1336 func Test_xpm_file()
1337 filetype on
1338
1339 call writefile(['this is XPM2'], 'file.xpm')
1340 split file.xpm
1341 call assert_equal('xpm2', &filetype)
1342 bwipe!
1343
1344 call delete('file.xpm')
1345 filetype off
1346 endfunc
1347
1327 1348
1328 " vim: shiftwidth=2 sts=2 expandtab 1349 " vim: shiftwidth=2 sts=2 expandtab