]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/lua/windows_escaping_spec.lua

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit 'd49e95aa7ba744f0a7f544aca43afdb6aab41f24' as '.vim/bundle/asyncomplete...
[etc/vim.git] / .vim / bundle / ale / test / lua / windows_escaping_spec.lua
1 local eq = assert.are.same
2 local ale = require("ale")
3
4 describe("ale.escape for cmd.exe", function()
5     setup(function()
6         _G.vim = {
7             o = {
8                 shell = "cmd.exe"
9             },
10             fn = {
11                 fnamemodify = function(shell, _)
12                     return shell
13                 end
14             }
15         }
16     end)
17
18     teardown(function()
19         _G.vim = nil
20     end)
21
22     it("should allow not escape paths without special characters", function()
23         eq("C:", ale.escape("C:"))
24         eq("C:\\", ale.escape("C:\\"))
25         eq("python", ale.escape("python"))
26         eq("C:\\foo\\bar", ale.escape("C:\\foo\\bar"))
27         eq("/bar/baz", ale.escape("/bar/baz"))
28         eq("nul", ale.escape("nul"))
29         eq("'foo'", ale.escape("'foo'"))
30     end)
31
32     it("should escape Windows paths with spaces appropriately", function()
33         eq('"C:\\foo bar\\baz"', ale.escape('C:\\foo bar\\baz'))
34         eq('"^foo bar^"', ale.escape('^foo bar^'))
35         eq('"&foo bar&"', ale.escape('&foo bar&'))
36         eq('"|foo bar|"', ale.escape('|foo bar|'))
37         eq('"<foo bar<"', ale.escape('<foo bar<'))
38         eq('">foo bar>"', ale.escape('>foo bar>'))
39         eq('"^foo bar^"', ale.escape('^foo bar^'))
40         eq('"\'foo\' \'bar\'"', ale.escape('\'foo\' \'bar\''))
41     end)
42
43     it("should use caret escapes on special characters", function()
44         eq('^^foo^^', ale.escape('^foo^'))
45         eq('^&foo^&', ale.escape('&foo&'))
46         eq('^|foo^|', ale.escape('|foo|'))
47         eq('^<foo^<', ale.escape('<foo<'))
48         eq('^>foo^>', ale.escape('>foo>'))
49         eq('^^foo^^', ale.escape('^foo^'))
50         eq('\'foo\'^^\'bar\'', ale.escape('\'foo\'^\'bar\''))
51     end)
52
53     it("should escape percent characters", function()
54         eq('%%foo%%', ale.escape('%foo%'))
55         eq('C:\foo%%\bar\baz%%', ale.escape('C:\foo%\bar\baz%'))
56         eq('"C:\foo bar%%\baz%%"', ale.escape('C:\foo bar%\baz%'))
57         eq('^^%%foo%%', ale.escape('^%foo%'))
58         eq('"^%%foo%% %%bar%%"', ale.escape('^%foo% %bar%'))
59         eq('"^%%foo%% %%bar%% """""', ale.escape('^%foo% %bar% ""'))
60     end)
61 end)