aboutsummaryrefslogtreecommitdiff
path: root/test/unit/viml/expressions/parser_spec.lua
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2017-11-12 03:52:26 +0300
committerZyX <kp-pav@yandex.ru>2017-11-12 03:52:26 +0300
commit45445e2e03f1cbfa25dde76ccf3e24d0d297cabe (patch)
tree1646a752e35b6c077ec21c9bc0425ee5865116f8 /test/unit/viml/expressions/parser_spec.lua
parentc7495ebcc0918ffd682083408895451318e41d1f (diff)
downloadrneovim-45445e2e03f1cbfa25dde76ccf3e24d0d297cabe.tar.gz
rneovim-45445e2e03f1cbfa25dde76ccf3e24d0d297cabe.tar.bz2
rneovim-45445e2e03f1cbfa25dde76ccf3e24d0d297cabe.zip
unittests: Add some more edge test cases
Diffstat (limited to 'test/unit/viml/expressions/parser_spec.lua')
-rw-r--r--test/unit/viml/expressions/parser_spec.lua143
1 files changed, 143 insertions, 0 deletions
diff --git a/test/unit/viml/expressions/parser_spec.lua b/test/unit/viml/expressions/parser_spec.lua
index 810d7bfbc6..df45cae304 100644
--- a/test/unit/viml/expressions/parser_spec.lua
+++ b/test/unit/viml/expressions/parser_spec.lua
@@ -1233,6 +1233,132 @@ describe('Expressions parser', function()
hl('CallingParenthesis', ')'),
hl('CallingParenthesis', ')'),
})
+ check_parsing('()()', {
+ -- 0123
+ ast = {
+ {
+ 'Call:0:2:(',
+ children = {
+ {
+ 'Nested:0:0:(',
+ children = {
+ 'Missing:0:1:',
+ },
+ },
+ },
+ },
+ },
+ err = {
+ arg = ')()',
+ msg = 'E15: Expected value, got parenthesis: %.*s',
+ },
+ }, {
+ hl('NestingParenthesis', '('),
+ hl('InvalidNestingParenthesis', ')'),
+ hl('CallingParenthesis', '('),
+ hl('CallingParenthesis', ')'),
+ })
+ check_parsing('(@a)()', {
+ -- 012345
+ ast = {
+ {
+ 'Call:0:4:(',
+ children = {
+ {
+ 'Nested:0:0:(',
+ children = {
+ 'Register(name=a):0:1:@a',
+ },
+ },
+ },
+ },
+ },
+ }, {
+ hl('NestingParenthesis', '('),
+ hl('Register', '@a'),
+ hl('NestingParenthesis', ')'),
+ hl('CallingParenthesis', '('),
+ hl('CallingParenthesis', ')'),
+ })
+ check_parsing('(@a)(@b)', {
+ -- 01234567
+ ast = {
+ {
+ 'Call:0:4:(',
+ children = {
+ {
+ 'Nested:0:0:(',
+ children = {
+ 'Register(name=a):0:1:@a',
+ },
+ },
+ 'Register(name=b):0:5:@b',
+ },
+ },
+ },
+ }, {
+ hl('NestingParenthesis', '('),
+ hl('Register', '@a'),
+ hl('NestingParenthesis', ')'),
+ hl('CallingParenthesis', '('),
+ hl('Register', '@b'),
+ hl('CallingParenthesis', ')'),
+ })
+ check_parsing('(@a) (@b)', {
+ -- 012345678
+ ast = {
+ {
+ 'OpMissing:0:4:',
+ children = {
+ {
+ 'Nested:0:0:(',
+ children = {
+ 'Register(name=a):0:1:@a',
+ },
+ },
+ {
+ 'Nested:0:4: (',
+ children = {
+ 'Register(name=b):0:6:@b',
+ },
+ },
+ },
+ },
+ },
+ err = {
+ arg = '(@b)',
+ msg = 'E15: Missing operator: %.*s',
+ },
+ }, {
+ hl('NestingParenthesis', '('),
+ hl('Register', '@a'),
+ hl('NestingParenthesis', ')'),
+ hl('InvalidSpacing', ' '),
+ hl('NestingParenthesis', '('),
+ hl('Register', '@b'),
+ hl('NestingParenthesis', ')'),
+ }, {
+ [1] = {
+ ast = {
+ ast = {
+ {
+ 'Nested:0:0:(',
+ children = {
+ 'Register(name=a):0:1:@a',
+ REMOVE_THIS,
+ },
+ },
+ },
+ err = REMOVE_THIS,
+ },
+ hl_fs = {
+ [4] = REMOVE_THIS,
+ [5] = REMOVE_THIS,
+ [6] = REMOVE_THIS,
+ [7] = REMOVE_THIS,
+ },
+ },
+ })
end)
itp('works with variable names, including curly braces ones', function()
check_parsing('var', {
@@ -1543,6 +1669,21 @@ describe('Expressions parser', function()
hl('FigureBrace', '{'),
hl('Register', '@a'),
})
+ check_parsing('a ()', {
+ -- 0123
+ ast = {
+ {
+ 'Call:0:1: (',
+ children = {
+ 'PlainIdentifier(scope=0,ident=a):0:0:a',
+ },
+ },
+ },
+ }, {
+ hl('IdentifierName', 'a'),
+ hl('CallingParenthesis', '(', 1),
+ hl('CallingParenthesis', ')'),
+ })
end)
itp('works with lambdas and dictionaries', function()
check_parsing('{}', {
@@ -7346,4 +7487,6 @@ describe('Expressions parser', function()
end)
-- FIXME: Test assignments thoroughly
-- FIXME: Test that parsing assignments can be used for `:for` pre-`in` part.
+ -- FIXME: Somehow make functional tests use the same code. Or, at least,
+ -- create an automated script which will do the import.
end)