diff options
author | ZyX <kp-pav@yandex.ru> | 2017-06-20 18:17:19 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-06-21 10:58:47 +0300 |
commit | 607dc3e0f9119fa4939d9cfa8ee1f7f764c6e530 (patch) | |
tree | 4f867539149bd316e90dae921a7c55d56d9c74c9 /test/helpers.lua | |
parent | 60c025267265ba4bfc2abd34ea02b13bd5c0e63f (diff) | |
download | rneovim-607dc3e0f9119fa4939d9cfa8ee1f7f764c6e530.tar.gz rneovim-607dc3e0f9119fa4939d9cfa8ee1f7f764c6e530.tar.bz2 rneovim-607dc3e0f9119fa4939d9cfa8ee1f7f764c6e530.zip |
functests: Add tests
Diffstat (limited to 'test/helpers.lua')
-rw-r--r-- | test/helpers.lua | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/test/helpers.lua b/test/helpers.lua index 7a0e4b8c3c..260f10002e 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -284,7 +284,7 @@ local function concat_tables(...) return ret end -local function dedent(str) +local function dedent(str, leave_indent) -- find minimum common indent across lines local indent = nil for line in str:gmatch('[^\n]+') do @@ -297,12 +297,13 @@ local function dedent(str) -- no minimum common indent return str end + local left_indent = (' '):rep(leave_indent or 0) -- create a pattern for the indent indent = indent:gsub('%s', '[ \t]') -- strip it from the first line - str = str:gsub('^'..indent, '') + str = str:gsub('^'..indent, left_indent) -- strip it from the remaining lines - str = str:gsub('[\n]'..indent, '\n') + str = str:gsub('[\n]'..indent, '\n' .. left_indent) return str end |