summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-05-26 00:06:16 +0100
committerw0rp <devw0rp@gmail.com>2017-05-26 00:06:16 +0100
commitc89587785b6fc4cba844b7eda2dbd65d15185374 (patch)
tree649598602e229086e9eba8a37790216a115af393 /test
parentfb07971290783e1a71e8306e760e1fd645873277 (diff)
downloadale-c89587785b6fc4cba844b7eda2dbd65d15185374.zip
Fix #549 - escape strings more appropriately for use with cmd /c
Diffstat (limited to 'test')
-rw-r--r--test/test_windows_escaping.vader42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/test_windows_escaping.vader b/test/test_windows_escaping.vader
new file mode 100644
index 00000000..22cad888
--- /dev/null
+++ b/test/test_windows_escaping.vader
@@ -0,0 +1,42 @@
+Before:
+ Save &shell
+ let &shell = 'cmd.exe'
+
+After:
+ Restore
+
+Execute(ale#Escape for cmd.exe should allow not escape paths without special characters):
+ AssertEqual 'C:', ale#Escape('C:')
+ AssertEqual 'C:\', ale#Escape('C:\')
+ AssertEqual 'python', ale#Escape('python')
+ AssertEqual 'C:\foo\bar', ale#Escape('C:\foo\bar')
+ AssertEqual '/bar/baz', ale#Escape('/bar/baz')
+ AssertEqual 'nul', ale#Escape('nul')
+ AssertEqual '''foo''', ale#Escape('''foo''')
+
+Execute(ale#Escape for cmd.exe should escape Windows paths with spaces appropriately):
+ AssertEqual '"C:\foo bar\baz"', ale#Escape('C:\foo bar\baz')
+ AssertEqual '"^foo bar^"', ale#Escape('^foo bar^')
+ AssertEqual '"&foo bar&"', ale#Escape('&foo bar&')
+ AssertEqual '"|foo bar|"', ale#Escape('|foo bar|')
+ AssertEqual '"<foo bar<"', ale#Escape('<foo bar<')
+ AssertEqual '">foo bar>"', ale#Escape('>foo bar>')
+ AssertEqual '"^foo bar^"', ale#Escape('^foo bar^')
+ AssertEqual '"''foo'' ''bar''"', ale#Escape('''foo'' ''bar''')
+
+Execute(ale#Escape for cmd.exe should use caret escapes on special characters):
+ AssertEqual '^^foo^^', ale#Escape('^foo^')
+ AssertEqual '^&foo^&', ale#Escape('&foo&')
+ AssertEqual '^|foo^|', ale#Escape('|foo|')
+ AssertEqual '^<foo^<', ale#Escape('<foo<')
+ AssertEqual '^>foo^>', ale#Escape('>foo>')
+ AssertEqual '^^foo^^', ale#Escape('^foo^')
+ AssertEqual '''foo''^^''bar''', ale#Escape('''foo''^''bar''')
+
+Execute(ale#Escape for cmd.exe should escape percent characters):
+ AssertEqual '%%foo%%', ale#Escape('%foo%')
+ AssertEqual 'C:\foo%%\bar\baz%%', ale#Escape('C:\foo%\bar\baz%')
+ AssertEqual '"C:\foo bar%%\baz%%"', ale#Escape('C:\foo bar%\baz%')
+ AssertEqual '^^%%foo%%', ale#Escape('^%foo%')
+ AssertEqual '"^%%foo%% %%bar%%"', ale#Escape('^%foo% %bar%')
+ AssertEqual '"^%%foo%% %%bar%% """""', ale#Escape('^%foo% %bar% ""')