aboutsummaryrefslogtreecommitdiff
path: root/test/functional/helpers.lua
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2014-10-01 09:31:57 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2014-10-01 09:31:57 -0300
commitf6a008a1824938038bb0801881302ea5b42e1087 (patch)
tree5619f7303937f4d8f859b01d39946066b156140e /test/functional/helpers.lua
parent549fc9548deaa737ff101806b60cedd7d4970c28 (diff)
downloadrneovim-f6a008a1824938038bb0801881302ea5b42e1087.tar.gz
rneovim-f6a008a1824938038bb0801881302ea5b42e1087.tar.bz2
rneovim-f6a008a1824938038bb0801881302ea5b42e1087.zip
test: Add 'eval' functional helper
The eval helper transforms vimL expressions into lua tables, it's useful for verifying function output.
Diffstat (limited to 'test/functional/helpers.lua')
-rw-r--r--test/functional/helpers.lua22
1 files changed, 20 insertions, 2 deletions
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index 2b9ddfbe3c..671e34e592 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -31,9 +31,24 @@ local function execute(...)
end
end
+local function eval(expr)
+ local status, result = pcall(function() return nvim_eval(expr) end)
+ if not status then
+ error('Failed to evaluate expression "' .. expr .. '"')
+ end
+ return result
+end
+
+local function eq(expected, actual)
+ return assert.are.same(expected, actual)
+end
+
+local function neq(expected, actual)
+ return assert.are_not.same(expected, actual)
+end
+
local function expect(contents, first, last, buffer_index)
- return assert.are.same(dedent(contents),
- buffer_slice(first, last, buffer_idx))
+ return eq(dedent(contents), buffer_slice(first, last, buffer_idx))
end
rawfeed([[:function BeforeEachTest()
@@ -80,5 +95,8 @@ return {
insert = insert,
feed = feed,
execute = execute,
+ eval = eval,
+ eq = eq,
+ neq = neq,
expect = expect
}