-
Notifications
You must be signed in to change notification settings - Fork 160
Expand file tree
/
Copy pathtest_filetypes.lua
More file actions
169 lines (132 loc) · 4.89 KB
/
Copy pathtest_filetypes.lua
File metadata and controls
169 lines (132 loc) · 4.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
local ft = require("copilot.client.filetypes")
local eq = MiniTest.expect.equality
local T = MiniTest.new_set({
hooks = {
pre_once = function() end,
pre_case = function() end,
},
})
T["filetypes()"] = MiniTest.new_set()
-- language_for_file_type tests
T["filetypes()"]["normalizes bash to shellscript"] = function()
eq(ft.language_for_file_type("bash"), "shellscript")
end
T["filetypes()"]["normalizes cs to csharp"] = function()
eq(ft.language_for_file_type("cs"), "csharp")
end
T["filetypes()"]["normalizes sh to shellscript"] = function()
eq(ft.language_for_file_type("sh"), "shellscript")
end
T["filetypes()"]["normalizes text to plaintext"] = function()
eq(ft.language_for_file_type("text"), "plaintext")
end
T["filetypes()"]["normalizes cuda to cuda-cpp"] = function()
eq(ft.language_for_file_type("cuda"), "cuda-cpp")
end
T["filetypes()"]["normalizes dosbatch to bat"] = function()
eq(ft.language_for_file_type("dosbatch"), "bat")
end
T["filetypes()"]["normalizes dosini to ini"] = function()
eq(ft.language_for_file_type("dosini"), "ini")
end
T["filetypes()"]["normalizes make to makefile"] = function()
eq(ft.language_for_file_type("make"), "makefile")
end
T["filetypes()"]["normalizes objc to objective-c"] = function()
eq(ft.language_for_file_type("objc"), "objective-c")
end
T["filetypes()"]["normalizes objcpp to objective-cpp"] = function()
eq(ft.language_for_file_type("objcpp"), "objective-cpp")
end
T["filetypes()"]["normalizes ps1 to powershell"] = function()
eq(ft.language_for_file_type("ps1"), "powershell")
end
T["filetypes()"]["normalizes raku to perl6"] = function()
eq(ft.language_for_file_type("raku"), "perl6")
end
T["filetypes()"]["normalizes bst to bibtex"] = function()
eq(ft.language_for_file_type("bst"), "bibtex")
end
T["filetypes()"]["normalizes gitcommit to git-commit"] = function()
eq(ft.language_for_file_type("gitcommit"), "git-commit")
end
T["filetypes()"]["normalizes gitrebase to git-rebase"] = function()
eq(ft.language_for_file_type("gitrebase"), "git-rebase")
end
T["filetypes()"]["passes through unknown filetypes unchanged"] = function()
eq(ft.language_for_file_type("python"), "python")
eq(ft.language_for_file_type("lua"), "lua")
end
T["filetypes()"]["trims dot-separated filetypes"] = function()
eq(ft.language_for_file_type("yaml.gotexttmpl"), "yaml")
eq(ft.language_for_file_type("bash.zsh"), "shellscript")
end
T["filetypes()"]["empty filetype returns plaintext"] = function()
eq(ft.language_for_file_type(""), "plaintext")
end
-- is_ft_disabled tests
T["filetypes()"]["is_ft_disabled exact match enabled"] = function()
local disabled, _ = ft.is_ft_disabled("python", { python = true })
eq(disabled, false)
end
T["filetypes()"]["is_ft_disabled exact match disabled"] = function()
local disabled, _ = ft.is_ft_disabled("python", { python = false })
eq(disabled, true)
end
T["filetypes()"]["is_ft_disabled short filetype match"] = function()
local disabled, _ = ft.is_ft_disabled("yaml.gotexttmpl", { yaml = false })
eq(disabled, true)
end
T["filetypes()"]["is_ft_disabled wildcard enabled"] = function()
local disabled, _ = ft.is_ft_disabled("python", { ["*"] = true })
eq(disabled, false)
end
T["filetypes()"]["is_ft_disabled wildcard disabled"] = function()
local disabled, _ = ft.is_ft_disabled("python", { ["*"] = false })
eq(disabled, true)
end
T["filetypes()"]["is_ft_disabled falls through to internal_filetypes"] = function()
local disabled, reason = ft.is_ft_disabled("yaml", {})
eq(disabled, true)
eq(type(reason), "string")
end
T["filetypes()"]["is_ft_disabled internal filetypes help disabled"] = function()
local disabled, _ = ft.is_ft_disabled("help", {})
eq(disabled, true)
end
T["filetypes()"]["is_ft_disabled internal filetypes gitcommit disabled"] = function()
local disabled, _ = ft.is_ft_disabled("gitcommit", {})
eq(disabled, true)
end
T["filetypes()"]["is_ft_disabled internal filetypes overridden by user config"] = function()
local disabled, _ = ft.is_ft_disabled("markdown", { markdown = true })
eq(disabled, false)
end
T["filetypes()"]["is_ft_disabled unknown filetype not disabled"] = function()
local disabled, reason = ft.is_ft_disabled("python", {})
eq(disabled, false)
eq(reason, nil)
end
T["filetypes()"]["is_ft_disabled callable value"] = function()
local disabled, _ = ft.is_ft_disabled("python", {
python = function()
return true
end,
})
eq(disabled, false)
local disabled2, _ = ft.is_ft_disabled("python", {
python = function()
return false
end,
})
eq(disabled2, true)
end
T["filetypes()"]["is_ft_disabled exact match takes priority over wildcard"] = function()
local disabled, _ = ft.is_ft_disabled("python", { python = true, ["*"] = false })
eq(disabled, false)
end
T["filetypes()"]["is_ft_disabled internal filetype dot separator"] = function()
local disabled, _ = ft.is_ft_disabled("markdown.pandoc", {})
eq(disabled, true)
end
return T