aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2017-11-19 20:20:06 +0300
committerZyX <kp-pav@yandex.ru>2017-11-19 20:20:06 +0300
commita94255a7ac22649311f858e39b217543d0d7e5e8 (patch)
treeb9046e4aa38a8afc00a338161ecef0ccec9238da /test/functional/api
parent53fa435a1f081e1d7e1890e3ecd978b85c39e0eb (diff)
downloadrneovim-a94255a7ac22649311f858e39b217543d0d7e5e8.tar.gz
rneovim-a94255a7ac22649311f858e39b217543d0d7e5e8.tar.bz2
rneovim-a94255a7ac22649311f858e39b217543d0d7e5e8.zip
tests: Use single test file for unit and functional parser tests
Diffstat (limited to 'test/functional/api')
-rw-r--r--test/functional/api/vim_spec.lua7132
1 files changed, 37 insertions, 7095 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 714b1988fb..3939bc9b52 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -766,6 +766,11 @@ describe('api', function()
elseif typ == 'Environment' then
typ = ('%s(ident=%s)'):format(typ, east_api_node.ident)
east_api_node.ident = nil
+ elseif typ == 'Assignment' then
+ local aug = east_api_node.augmentation
+ if aug == '' then aug = 'Plain' end
+ typ = ('%s(%s)'):format(typ, aug)
+ east_api_node.augmentation = nil
end
typ = ('%s:%u:%u:%s'):format(
typ, east_api_node.start[1], east_api_node.start[2],
@@ -798,6 +803,9 @@ describe('api', function()
end
if east_api.ast then
east_api.ast = {simplify_east_api_node(line, east_api.ast)}
+ if #east_api.ast == 0 then
+ east_api.ast = nil
+ end
end
if east_api.len == #line then
east_api.len = nil
@@ -819,11 +827,19 @@ describe('api', function()
[1] = "m",
[2] = "E",
[3] = "mE",
+ [4] = "l",
+ [5] = "lm",
+ [6] = "lE",
+ [7] = "lmE",
}
- local function check_parsing(str, exp_ast, exp_highlighting_fs,
- nz_flags_exps)
+ local function _check_parsing(opts, str, exp_ast, exp_highlighting_fs,
+ nz_flags_exps)
+ if type(str) ~= 'string' then
+ return
+ end
+ local zflags = opts.flags[1]
nz_flags_exps = nz_flags_exps or {}
- for _, flags in ipairs({0, 1, 2, 3}) do
+ for _, flags in ipairs(opts.flags) do
local err, msg = pcall(function()
local east_api = meths.parse_expression(str, FLAGS_TO_STR[flags], true)
local east_hl = east_api.highlight
@@ -835,8 +851,8 @@ describe('api', function()
hl_fs = exp_highlighting_fs,
}
local add_exps = nz_flags_exps[flags]
- if not add_exps and flags == 3 then
- add_exps = nz_flags_exps[1] or nz_flags_exps[2]
+ if not add_exps and flags == 3 + zflags then
+ add_exps = nz_flags_exps[1 + zflags] or nz_flags_exps[2 + zflags]
end
if add_exps then
if add_exps.ast then
@@ -873,7096 +889,22 @@ describe('api', function()
str)), (col + #str)
end
end
- it('works with + and @a', function()
- check_parsing('@a', {
- ast = {
- 'Register(name=a):0:0:@a',
- },
- }, {
- hl('Register', '@a'),
- })
- check_parsing('+@a', {
- ast = {
- {
- 'UnaryPlus:0:0:+',
- children = {
- 'Register(name=a):0:1:@a',
- },
- },
- },
- }, {
- hl('UnaryPlus', '+'),
- hl('Register', '@a'),
- })
- check_parsing('@a+@b', {
- ast = {
- {
- 'BinaryPlus:0:2:+',
- children = {
- 'Register(name=a):0:0:@a',
- 'Register(name=b):0:3:@b',
- },
- },
- },
- }, {
- hl('Register', '@a'),
- hl('BinaryPlus', '+'),
- hl('Register', '@b'),
- })
- check_parsing('@a+@b+@c', {
- ast = {
- {
- 'BinaryPlus:0:5:+',
- children = {
- {
- 'BinaryPlus:0:2:+',
- children = {
- 'Register(name=a):0:0:@a',
- 'Register(name=b):0:3:@b',
- },
- },
- 'Register(name=c):0:6:@c',
- },
- },
- },
- }, {
- hl('Register', '@a'),
- hl('BinaryPlus', '+'),
- hl('Register', '@b'),
- hl('BinaryPlus', '+'),
- hl('Register', '@c'),
- })
- check_parsing('+@a+@b', {
- ast = {
- {
- 'BinaryPlus:0:3:+',
- children = {
- {
- 'UnaryPlus:0:0:+',
- children = {
- 'Register(name=a):0:1:@a',
- },
- },
- 'Register(name=b):0:4:@b',
- },
- },
- },
- }, {
- hl('UnaryPlus', '+'),
- hl('Register', '@a'),
- hl('BinaryPlus', '+'),
- hl('Register', '@b'),
- })
- check_parsing('+@a++@b', {
- ast = {
- {
- 'BinaryPlus:0:3:+',
- children = {
- {
- 'UnaryPlus:0:0:+',
- children = {
- 'Register(name=a):0:1:@a',
- },
- },
- {
- 'UnaryPlus:0:4:+',
- children = {
- 'Register(name=b):0:5:@b',
- },
- },
- },
- },
- },
- }, {
- hl('UnaryPlus', '+'),
- hl('Register', '@a'),
- hl('BinaryPlus', '+'),
- hl('UnaryPlus', '+'),
- hl('Register', '@b'),
- })
- check_parsing('@a@b', {
- ast = {
- {
- 'OpMissing:0:2:',
- children = {
- 'Register(name=a):0:0:@a',
- 'Register(name=b):0:2:@b',
- },
- },
- },
- err = {
- arg = '@b',
- msg = 'E15: Missing operator: %.*s',
- },
- }, {
- hl('Register', '@a'),
- hl('InvalidRegister', '@b'),
- }, {
- [1] = {
- ast = {
- len = 2,
- err = REMOVE_THIS,
- ast = {
- 'Register(name=a):0:0:@a'
- },
- },
- hl_fs = {
- [2] = REMOVE_THIS,
- },
- },
- })
- check_parsing(' @a \t @b', {
- ast = {
- {
- 'OpMissing:0:3:',
- children = {
- 'Register(name=a):0:0: @a',
- 'Register(name=b):0:3: \t @b',
- },
- },
- },
- err = {
- arg = '@b',
- msg = 'E15: Missing operator: %.*s',
- },
- }, {
- hl('Register', '@a', 1),
- hl('InvalidSpacing', ' \t '),
- hl('Register', '@b'),
- }, {
- [1] = {
- ast = {
- len = 6,
- err = REMOVE_THIS,
- ast = {
- 'Register(name=a):0:0: @a'
- },
- },
- hl_fs = {
- [2] = REMOVE_THIS,
- [3] = REMOVE_THIS,
- },
- },
- })
- check_parsing('+', {
- ast = {
- 'UnaryPlus:0:0:+',
- },
- err = {
- arg = '',
- msg = 'E15: Expected value, got EOC: %.*s',
- },
- }, {
- hl('UnaryPlus', '+'),
- })
- check_parsing(' +', {
- ast = {
- 'UnaryPlus:0:0: +',
- },
- err = {
- arg = '',
- msg = 'E15: Expected value, got EOC: %.*s',
- },
- }, {
- hl('UnaryPlus', '+', 1),
- })
- check_parsing('@a+ ', {
- ast = {
- {
- 'BinaryPlus:0:2:+',
- children = {
- 'Register(name=a):0:0:@a',
- },
- },
- },
- err = {
- arg = '',
- msg = 'E15: Expected value, got EOC: %.*s',
- },
- }, {
- hl('Register', '@a'),
- hl('BinaryPlus', '+'),
- })
- end)
- it('works with @a, + and parenthesis', function()
- check_parsing('(@a)', {
- ast = {
- {
- 'Nested:0:0:(',
- children = {
- 'Register(name=a):0:1:@a',
- },
- },
- },
- }, {
- hl('NestingParenthesis', '('),
- hl('Register', '@a'),
- hl('NestingParenthesis', ')'),
- })
- check_parsing('()', {
- ast = {
- {
- 'Nested:0:0:(',
- children = {
- 'Missing:0:1:',
- },
- },
- },
- err = {
- arg = ')',
- msg = 'E15: Expected value, got parenthesis: %.*s',
- },
- }, {
- hl('NestingParenthesis', '('),
- hl('InvalidNestingParenthesis', ')'),
- })
- check_parsing(')', {
- ast = {
- {
- 'Nested:0:0:',
- children = {
- 'Missing:0:0:',
- },
- },
- },
- err = {
- arg = ')',
- msg = 'E15: Expected value, got parenthesis: %.*s',
- },
- }, {
- hl('InvalidNestingParenthesis', ')'),
- })
- check_parsing('+)', {
- ast = {
- {
- 'Nested:0:1:',
- children = {
- {
- 'UnaryPlus:0:0:+',
- children = {
- 'Missing:0:1:',
- },
- },
- },
- },
- },
- err = {
- arg = ')',
- msg = 'E15: Expected value, got parenthesis: %.*s',
- },
- }, {
- hl('UnaryPlus', '+'),
- hl('InvalidNestingParenthesis', ')'),
- })
- check_parsing('+@a(@b)', {
- ast = {
- {
- 'UnaryPlus:0:0:+',
- children = {
- {
- 'Call:0:3:(',
- children = {
- 'Register(name=a):0:1:@a',
- 'Register(name=b):0:4:@b',
- },
- },
- },
- },
- },
- }, {
- hl('UnaryPlus', '+'),
- hl('Register', '@a'),
- hl('CallingParenthesis', '('),
- hl('Register', '@b'),
- hl('CallingParenthesis', ')'),
- })
- check_parsing('@a+@b(@c)', {
- ast = {
- {
- 'BinaryPlus:0:2:+',
- children = {
- 'Register(name=a):0:0:@a',
- {
- 'Call:0:5:(',
- children = {
- 'Register(name=b):0:3:@b',
- 'Register(name=c):0:6:@c',
- },
- },
- },
- },
- },
- }, {
- hl('Register', '@a'),
- hl('BinaryPlus', '+'),
- hl('Register', '@b'),
- hl('CallingParenthesis', '('),
- hl('Register', '@c'),
- hl('CallingParenthesis', ')'),
- })
- check_parsing('@a()', {
- ast = {
- {
- 'Call:0:2:(',
- children = {
- 'Register(name=a):0:0:@a',
- },
- },
- },
- }, {
- hl('Register', '@a'),
- hl('CallingParenthesis', '('),
- hl('CallingParenthesis', ')'),
- })
- check_parsing('@a ()', {
- ast = {
- {
- 'OpMissing:0:2:',
- children = {
- 'Register(name=a):0:0:@a',
- {
- 'Nested:0:2: (',
- children = {
- 'Missing:0:4:',
- },
- },
- },
- },
- },
- err = {
- arg = '()',
- msg = 'E15: Missing operator: %.*s',
- },
- }, {
- hl('Register', '@a'),
- hl('InvalidSpacing', ' '),
- hl('NestingParenthesis', '('),
- hl('InvalidNestingParenthesis', ')'),
- }, {
- [1] = {
- ast = {
- len = 3,
- err = REMOVE_THIS,
- ast = {
- 'Register(name=a):0:0:@a',
- },
- },
- hl_fs = {
- [2] = REMOVE_THIS,
- [3] = REMOVE_THIS,
- [4] = REMOVE_THIS,
- },
- },
- })
- check_parsing('@a + (@b)', {
- ast = {
- {
- 'BinaryPlus:0:2: +',
- children = {
- 'Register(name=a):0:0:@a',
- {
- 'Nested:0:4: (',
- children = {
- 'Register(name=b):0:6:@b',
- },
- },
- },
- },
- },
- }, {
- hl('Register', '@a'),
- hl('BinaryPlus', '+', 1),
- hl('NestingParenthesis', '(', 1),
- hl('Register', '@b'),
- hl('NestingParenthesis', ')'),
- })
- check_parsing('@a + (+@b)', {
- ast = {
- {
- 'BinaryPlus:0:2: +',
- children = {
- 'Register(name=a):0:0:@a',
- {
- 'Nested:0:4: (',
- children = {
- {
- 'UnaryPlus:0:6:+',
- children = {
- 'Register(name=b):0:7:@b',
- },
- },
- },
- },
- },
- },
- },
- }, {
- hl('Register', '@a'),
- hl('BinaryPlus', '+', 1),
- hl('NestingParenthesis', '(', 1),
- hl('UnaryPlus', '+'),
- hl('Register', '@b'),
- hl('NestingParenthesis', ')'),
- })
- check_parsing('@a + (@b + @c)', {
- ast = {
- {
- 'BinaryPlus:0:2: +',
- children = {
- 'Register(name=a):0:0:@a',
- {
- 'Nested:0:4: (',
- children = {
- {
- 'BinaryPlus:0:8: +',
- children = {
- 'Register(name=b):0:6:@b',
- 'Register(name=c):0:10: @c',
- },
- },
- },
- },
- },
- },
- },
- }, {
- hl('Register', '@a'),
- hl('BinaryPlus', '+', 1),
- hl('NestingParenthesis', '(', 1),
- hl('Register', '@b'),
- hl('BinaryPlus', '+', 1),
- hl('Register', '@c', 1),
- hl('NestingParenthesis', ')'),
- })
- check_parsing('(@a)+@b', {
- ast = {
- {
- 'BinaryPlus: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('BinaryPlus', '+'),
- hl('Register', '@b'),
- })
- check_parsing('@a+(@b)(@c)', {
- -- 01234567890
- ast = {
- {
- 'BinaryPlus:0:2:+',
- children = {
- 'Register(name=a):0:0:@a',
- {
- 'Call:0:7:(',
- children = {
- {
- 'Nested:0:3:(',
- children = { 'Register(name=b):0:4:@b' },
- },
- 'Register(name=c):0:8:@c',
- },
- },
- },
- },
- },
- }, {
- hl('Register', '@a'),
- hl('BinaryPlus', '+'),
- hl('NestingParenthesis', '('),
- hl('Register', '@b'),
- hl('NestingParenthesis', ')'),
- hl('CallingParenthesis', '('),
- hl('Register', '@c'),
- hl('CallingParenthesis', ')'),
- })
- check_parsing('@a+((@b))(@c)', {
- -- 01234567890123456890123456789
- -- 0 1 2
- ast = {
- {
- 'BinaryPlus:0:2:+',
- children = {
- 'Register(name=a):0:0:@a',
- {
- 'Call:0:9:(',
- children = {
- {
- 'Nested:0:3:(',
- children = {
- {
- 'Nested:0:4:(',
- children = { 'Register(name=b):0:5:@b' }
- },
- },
- },
- 'Register(name=c):0:10:@c',
- },
- },
- },
- },
- },
- }, {
- hl('Register', '@a'),
- hl('BinaryPlus', '+'),
- hl('NestingParenthesis', '('),
- hl('NestingParenthesis', '('),
- hl('Register', '@b'),
- hl('NestingParenthesis', ')'),
- hl('NestingParenthesis', ')'),
- hl('CallingParenthesis', '('),
- hl('Register', '@c'),
- hl('CallingParenthesis', ')'),
- })
- check_parsing('@a+((@b))+@c', {
- -- 01234567890123456890123456789
- -- 0 1 2
- ast = {
- {
- 'BinaryPlus:0:9:+',
- children = {
- {
- 'BinaryPlus:0:2:+',
- children = {
- 'Register(name=a):0:0:@a',
- {
- 'Nested:0:3:(',
- children = {
- {
- 'Nested:0:4:(',
- children = { 'Register(name=b):0:5:@b' }
- },
- },
- },
- },
- },
- 'Register(name=c):0:10:@c',
- },
- },
- },
- }, {
- hl('Register', '@a'),
- hl('BinaryPlus', '+'),
- hl('NestingParenthesis', '('),
- hl('NestingParenthesis', '('),
- hl('Register', '@b'),
- hl('NestingParenthesis', ')'),
- hl('NestingParenthesis', ')'),
- hl('BinaryPlus', '+'),
- hl('Register', '@c'),
- })
- check_parsing(
- '@a + (@b + @c) + @d(@e) + (+@f) + ((+@g(@h))(@j)(@k))(@l)', {--[[
- | | | | | | | | || | | || | | ||| || || || ||
- 000000000011111111112222222222333333333344444444445555555
- 012345678901234567890123456789012345678901234567890123456
- ]]
- ast = {{
- 'BinaryPlus:0:31: +',
- children = {
- {
- 'BinaryPlus:0:23: +',
- children = {
- {
- 'BinaryPlus:0:14: +',
- children = {
- {
- 'BinaryPlus:0:2: +',
- children = {
- 'Register(name=a):0:0:@a',
- {
- 'Nested:0:4: (',
- children = {
- {
- 'BinaryPlus:0:8: +',
- children = {
- 'Register(name=b):0:6:@b',
- 'Register(name=c):0:10: @c',
- },
- },
- },
- },
- },
- },
- {
- 'Call:0:19:(',
- children = {
- 'Register(name=d):0:16: @d',
- 'Register(name=e):0:20:@e',
- },
- },
- },
- },
- {
- 'Nested:0:25: (',
- children = {
- {
- 'UnaryPlus:0:27:+',
- children = {
- 'Register(name=f):0:28:@f',
- },
- },
- },
- },
- },
- },
- {
- 'Call:0:53:(',
- children = {
- {
- 'Nested:0:33: (',
- children = {
- {
- 'Call:0:48:(',
- children = {
- {
- 'Call:0:44:(',
- children = {
- {
- 'Nested:0:35:(',
- children = {
- {
- 'UnaryPlus:0:36:+',
- children = {
- {
- 'Call:0:39:(',
- children = {
- 'Register(name=g):0:37:@g',
- 'Register(name=h):0:40:@h',
- },
- },
- },
- },
- },
- },
- 'Register(name=j):0:45:@j',
- },
- },
- 'Register(name=k):0:49:@k',
- },
- },
- },
- },
- 'Register(name=l):0:54:@l',
- },
- },
- },
- }},
- }, {
- hl('Register', '@a'),
- hl('BinaryPlus', '+', 1),
- hl('NestingParenthesis', '(', 1),
- hl('Register', '@b'),
- hl('BinaryPlus', '+', 1),
- hl('Register', '@c', 1),
- hl('NestingParenthesis', ')'),
- hl('BinaryPlus', '+', 1),
- hl('Register', '@d', 1),
- hl('CallingParenthesis', '('),
- hl('Register', '@e'),
- hl('CallingParenthesis', ')'),
- hl('BinaryPlus', '+', 1),
- hl('NestingParenthesis', '(', 1),
- hl('UnaryPlus', '+'),
- hl('Register', '@f'),
- hl('NestingParenthesis', ')'),
- hl('BinaryPlus', '+', 1),
- hl('NestingParenthesis', '(', 1),
- hl('NestingParenthesis', '('),
- hl('UnaryPlus', '+'),
- hl('Register', '@g'),
- hl('CallingParenthesis', '('),
- hl('Register', '@h'),
- hl('CallingParenthesis', ')'),
- hl('NestingParenthesis', ')'),
- hl('CallingParenthesis', '('),
- hl('Register', '@j'),
- hl('CallingParenthesis', ')'),
- hl('CallingParenthesis', '('),
- hl('Register', '@k'),
- hl('CallingParenthesis', ')'),
- hl('NestingParenthesis', ')'),
- hl('CallingParenthesis', '('),
- hl('Register', '@l'),
- hl('CallingParenthesis', ')'),
- })
- check_parsing('@a)', {
- -- 012
- ast = {
- {
- 'Nested:0:2:',
- children = {
- 'Register(name=a):0:0:@a',
- },
- },
- },
- err = {
- arg = ')',
- msg = 'E15: Unexpected closing parenthesis: %.*s',
- },
- }, {
- hl('Register', '@a'),
- hl('InvalidNestingParenthesis', ')'),
- })
- check_parsing('(@a', {
- -- 012
- ast = {
- {
- 'Nested:0:0:(',
- children = {
- 'Register(name=a):0:1:@a',
- },
- },
- },
- err = {
- arg = '(@a',
- msg = 'E110: Missing closing parenthesis for nested expression: %.*s',
- },
- }, {
- hl('NestingParenthesis', '('),
- hl('Register', '@a'),
- })
- check_parsing('@a(@b', {
- -- 01234
- ast = {
- {
- 'Call:0:2:(',
- children = {
- 'Register(name=a):0:0:@a',
- 'Register(name=b):0:3:@b',
- },
- },
- },
- err = {
- arg = '(@b',
- msg = 'E116: Missing closing parenthesis for function call: %.*s',
- },
- }, {
- hl('Register', '@a'),
- hl('CallingParenthesis', '('),
- hl('Register', '@b'),
- })
- check_parsing('@a(@b, @c, @d, @e)', {
- -- 012345678901234567
- -- 0 1
- ast = {
- {
- 'Call:0:2:(',
- children = {
- 'Register(name=a):0:0:@a',
- {
- 'Comma:0:5:,',
- children = {
- 'Register(name=b):0:3:@b',
- {
- 'Comma:0:9:,',
- children = {
- 'Register(name=c):0:6: @c',
- {
- 'Comma:0:13:,',
- children = {
- 'Register(name=d):0:10: @d',
- 'Register(name=e):0:14: @e',
- },
- },
- },
- },
- },
- },
- },
- },
- },
- }, {
- hl('Register', '@a'),
- hl('CallingParenthesis', '('),
- hl('Register', '@b'),
- hl('Comma', ','),
- hl('Register', '@c', 1),
- hl('Comma', ','),
- hl('Register', '@d', 1),
- hl('Comma', ','),
- hl('Register', '@e', 1),
- hl('CallingParenthesis', ')'),
- })
- check_parsing('@a(@b(@c))', {
- -- 01234567890123456789012345678901234567
- -- 0 1 2 3
- ast = {
- {
- 'Call:0:2:(',
- children = {
- 'Register(name=a):0:0:@a',
- {
- 'Call:0:5:(',
- children = {
- 'Register(name=b):0:3:@b',
- 'Register(name=c):0:6:@c',
- },
- },
- },
- },
- },
- }, {
- hl('Register', '@a'),
- hl('CallingParenthesis', '('),
- hl('Register', '@b'),
- hl('CallingParenthesis', '('),
- hl('Register', '@c'),
- hl('CallingParenthesis', ')'),
- hl('CallingParenthesis', ')'),
- })
- check_parsing('@a(@b(@c(@d(@e), @f(@g(@h), @i(@j)))))', {
- -- 01234567890123456789012345678901234567
- -- 0 1 2 3
- ast = {
- {
- 'Call:0:2:(',
- children = {
- 'Register(name=a):0:0:@a',
- {
- 'Call:0:5:(',
- children = {
- 'Register(name=b):0:3:@b',
- {
- 'Call:0:8:(',
- children = {
- 'Register(name=c):0:6:@c',
- {
- 'Comma:0:15:,',
- children = {
- {
- 'Call:0:11:(',
- children = {
- 'Register(name=d):0:9:@d',
- 'Register(name=e):0:12:@e',
- },
- },
- {
- 'Call:0:19:(',
- children = {
- 'Register(name=f):0:16: @f',
- {
- 'Comma:0:26:,',
- children = {
- {
- 'Call:0:22:(',
- children = {
- 'Register(name=g):0:20:@g',
- 'Register(name=h):0:23:@h',
- },
- },
- {
- 'Call:0:30:(',
- children = {
- 'Register(name=i):0:27: @i',
- 'Register(name=j):0:31:@j',
- },
- },
- },
- },
- },
- },
- },
- },
- },
- },
- },
- },
- },
- },
- },
- }, {
- hl('Register', '@a'),
- hl('CallingParenthesis', '('),
- hl('Register', '@b'),
- hl('CallingParenthesis', '('),
- hl('Register', '@c'),
- hl('CallingParenthesis', '('),
- hl('Register', '@d'),
- hl('CallingParenthesis', '('),
- hl('Register', '@e'),
- hl('CallingParenthesis', ')'),
- hl('Comma', ','),
- hl('Register', '@f', 1),
- hl('CallingParenthesis', '('),
- hl('Register', '@g'),
- hl('CallingParenthesis', '('),
- hl('Register', '@h'),
- hl('CallingParenthesis', ')'),
- hl('Comma', ','),
- hl('Register', '@i', 1),
- hl('CallingParenthesis', '('),
- hl('Register', '@j'),
- hl('CallingParenthesis', ')'),
- hl('CallingParenthesis', ')'),
- hl('CallingParenthesis', ')'),
- hl('CallingParenthesis', ')'),
- hl('CallingParenthesis', ')'),
- })
- end)
- it('works with variable names, including curly braces ones', function()
- check_parsing('var', {
- ast = {
- 'PlainIdentifier(scope=0,ident=var):0:0:var',
- },
- }, {
- hl('IdentifierName', 'var'),
- })
- check_parsing('g:var', {
- ast = {
- 'PlainIdentifier(scope=g,ident=var):0:0:g:var',
- },
- }, {
- hl('IdentifierScope', 'g'),
- hl('IdentifierScopeDelimiter', ':'),
- hl('IdentifierName', 'var'),
- })
- check_parsing('g:', {
- ast = {
- 'PlainIdentifier(scope=g,ident=):0:0:g:',
- },
- }, {
- hl('IdentifierScope', 'g'),
- hl('IdentifierScopeDelimiter', ':'),
- })
- check_parsing('{a}', {
- -- 012
- ast = {
- {
- 'CurlyBracesIdentifier:0:0:{',
- children = {
- 'PlainIdentifier(scope=0,ident=a):0:1:a',
- },
- },
- },
- }, {
- hl('Curly', '{'),
- hl('IdentifierName', 'a'),
- hl('Curly', '}'),
- })
- check_parsing('{a:b}', {
- -- 012
- ast = {
- {
- 'CurlyBracesIdentifier:0:0:{',
- children = {
- 'PlainIdentifier(scope=a,ident=b):0:1:a:b',
- },
- },
- },
- }, {
- hl('Curly', '{'),
- hl('IdentifierScope', 'a'),
- hl('IdentifierScopeDelimiter', ':'),
- hl('IdentifierName', 'b'),
- hl('Curly', '}'),
- })
- check_parsing('{a:@b}', {
- -- 012345
- ast = {
- {
- 'CurlyBracesIdentifier:0:0:{',
- children = {
- {
- 'OpMissing:0:3:',
- children={
- 'PlainIdentifier(scope=a,ident=):0:1:a:',
- 'Register(name=b):0:3:@b',
- },
- },
- },
- },
- },
- err = {
- arg = '@b}',
- msg = 'E15: Missing operator: %.*s',
- },
- }, {
- hl('Curly', '{'),
- hl('IdentifierScope', 'a'),
- hl('IdentifierScopeDelimiter', ':'),
- hl('InvalidRegister', '@b'),
- hl('Curly', '}'),
- })
- check_parsing('{@a}', {
- ast = {
- {
- 'CurlyBracesIdentifier:0:0:{',
- children = {
- 'Register(name=a):0:1:@a',
- },
- },
- },
- }, {
- hl('Curly', '{'),
- hl('Register', '@a'),
- hl('Curly', '}'),
- })
- check_parsing('{@a}{@b}', {
- -- 01234567
- ast = {
- {
- 'ComplexIdentifier:0:4:',
- children = {
- {
- 'CurlyBracesIdentifier:0:0:{',
- children = {
- 'Register(name=a):0:1:@a',
- },
- },
- {
- 'CurlyBracesIdentifier:0:4:{',
- children = {
- 'Register(name=b):0:5:@b',
- },
- },
- },
- },
- },
- }, {
- hl('Curly', '{'),
- hl('Register', '@a'),
- hl('Curly', '}'),
- hl('Curly', '{'),
- hl('Register', '@b'),
- hl('Curly', '}'),
- })