aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/vim_spec.lua
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2017-11-05 21:06:12 +0300
committerZyX <kp-pav@yandex.ru>2017-11-06 01:17:39 +0300
commit7849070f998902bb6aae5d6f9147d4daf5421b36 (patch)
tree60ce9e21300fa954b476347bb4f96b074a9095c8 /test/functional/api/vim_spec.lua
parent7bc6de75263f58c6c4f999bc86a6454ae9f28b80 (diff)
downloadrneovim-7849070f998902bb6aae5d6f9147d4daf5421b36.tar.gz
rneovim-7849070f998902bb6aae5d6f9147d4daf5421b36.tar.bz2
rneovim-7849070f998902bb6aae5d6f9147d4daf5421b36.zip
tests: Add missing test cases
Diffstat (limited to 'test/functional/api/vim_spec.lua')
-rw-r--r--test/functional/api/vim_spec.lua1197
1 files changed, 777 insertions, 420 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index bb7785657d..b904bd2a8f 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -12,8 +12,10 @@ local request = helpers.request
local meth_pcall = helpers.meth_pcall
local command = helpers.command
+local REMOVE_THIS = global_helpers.REMOVE_THIS
local intchar2lua = global_helpers.intchar2lua
local format_string = global_helpers.format_string
+local mergedicts_copy = global_helpers.mergedicts_copy
describe('api', function()
before_each(clear)
@@ -717,6 +719,9 @@ describe('api', function()
describe('nvim_parse_expression', function()
local function simplify_east_api_node(line, east_api_node)
+ if east_api_node == NIL then
+ return nil
+ end
if east_api_node.children then
for k, v in pairs(east_api_node.children) do
east_api_node.children[k] = simplify_east_api_node(line, v)
@@ -806,31 +811,53 @@ describe('api', function()
end
return east_hl
end
- local function check_parsing(str, flags, exp_ast, exp_highlighting_fs)
- if flags == 0 then
- flags = ""
- end
-
- local err, msg = pcall(function()
- local east_api = meths.parse_expression(str, flags, true)
- local east_hl = east_api.highlight
- east_api.highlight = nil
- local ast = simplify_east_api(str, east_api)
- local hls = simplify_east_hl(str, east_hl)
- eq(exp_ast, ast)
- if exp_highlighting_fs then
- local exp_highlighting = {}
- local next_col = 0
- for i, h in ipairs(exp_highlighting_fs) do
- exp_highlighting[i], next_col = h(next_col)
+ local FLAGS_TO_STR = {
+ [0] = "",
+ [1] = "m",
+ [2] = "E",
+ [3] = "mE",
+ }
+ local function check_parsing(str, exp_ast, exp_highlighting_fs,
+ nz_flags_exps)
+ nz_flags_exps = nz_flags_exps or {}
+ for _, flags in ipairs({0, 1, 2, 3}) do
+ local err, msg = pcall(function()
+ local east_api = meths.parse_expression(str, FLAGS_TO_STR[flags], true)
+ local east_hl = east_api.highlight
+ east_api.highlight = nil
+ local ast = simplify_east_api(str, east_api)
+ local hls = simplify_east_hl(str, east_hl)
+ local exps = {
+ ast = exp_ast,
+ 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]
end
- eq(exp_highlighting, hls)
+ if add_exps then
+ if add_exps.ast then
+ exps.ast = mergedicts_copy(exps.ast, add_exps.ast)
+ end
+ if add_exps.hl_fs then
+ exps.hl_fs = mergedicts_copy(exps.hl_fs, add_exps.hl_fs)
+ end
+ end
+ eq(exps.ast, ast)
+ if exp_highlighting_fs then
+ local exp_highlighting = {}
+ local next_col = 0
+ for i, h in ipairs(exps.hl_fs) do
+ exp_highlighting[i], next_col = h(next_col)
+ end
+ eq(exp_highlighting, hls)
+ end
+ end)
+ if not err then
+ msg = format_string('Error while processing test (%r, %s):\n%s',
+ str, FLAGS_TO_STR[flags], msg)
+ error(msg)
end
- end)
- if not err then
- msg = format_string('Error while processing test (%r, %s):\n%s',
- str, flags, msg)
- error(msg)
end
end
local function hl(group, str, shift)
@@ -844,14 +871,14 @@ describe('api', function()
end
end
it('works with + and @a', function()
- check_parsing('@a', 0, {
+ check_parsing('@a', {
ast = {
'Register(name=a):0:0:@a',
},
}, {
hl('Register', '@a'),
})
- check_parsing('+@a', 0, {
+ check_parsing('+@a', {
ast = {
{
'UnaryPlus:0:0:+',
@@ -864,7 +891,7 @@ describe('api', function()
hl('UnaryPlus', '+'),
hl('Register', '@a'),
})
- check_parsing('@a+@b', 0, {
+ check_parsing('@a+@b', {
ast = {
{
'BinaryPlus:0:2:+',
@@ -879,7 +906,7 @@ describe('api', function()
hl('BinaryPlus', '+'),
hl('Register', '@b'),
})
- check_parsing('@a+@b+@c', 0, {
+ check_parsing('@a+@b+@c', {
ast = {
{
'BinaryPlus:0:5:+',
@@ -902,7 +929,7 @@ describe('api', function()
hl('BinaryPlus', '+'),
hl('Register', '@c'),
})
- check_parsing('+@a+@b', 0, {
+ check_parsing('+@a+@b', {
ast = {
{
'BinaryPlus:0:3:+',
@@ -923,7 +950,7 @@ describe('api', function()
hl('BinaryPlus', '+'),
hl('Register', '@b'),
})
- check_parsing('+@a++@b', 0, {
+ check_parsing('+@a++@b', {
ast = {
{
'BinaryPlus:0:3:+',
@@ -950,7 +977,7 @@ describe('api', function()
hl('UnaryPlus', '+'),
hl('Register', '@b'),
})
- check_parsing('@a@b', 0, {
+ check_parsing('@a@b', {
ast = {
{
'OpMissing:0:2:',
@@ -967,8 +994,20 @@ describe('api', function()
}, {
hl('Register', '@a'),
hl('InvalidRegister', '@b'),
+ }, {
+ [1] = {
+ ast = {
+ err = REMOVE_THIS,
+ ast = {
+ 'Register(name=a):0:0:@a'
+ },
+ },
+ hl_fs = {
+ [2] = REMOVE_THIS,
+ },
+ },
})
- check_parsing(' @a \t @b', 0, {
+ check_parsing(' @a \t @b', {
ast = {
{
'OpMissing:0:3:',
@@ -986,8 +1025,21 @@ describe('api', function()
hl('Register', '@a', 1),
hl('InvalidSpacing', ' \t '),
hl('Register', '@b'),
+ }, {
+ [1] = {
+ ast = {
+ err = REMOVE_THIS,
+ ast = {
+ 'Register(name=a):0:0: @a'
+ },
+ },
+ hl_fs = {
+ [2] = REMOVE_THIS,
+ [3] = REMOVE_THIS,
+ },
+ },
})
- check_parsing('+', 0, {
+ check_parsing('+', {
ast = {
'UnaryPlus:0:0:+',
},
@@ -998,7 +1050,7 @@ describe('api', function()
}, {
hl('UnaryPlus', '+'),
})
- check_parsing(' +', 0, {
+ check_parsing(' +', {
ast = {
'UnaryPlus:0:0: +',
},
@@ -1009,7 +1061,7 @@ describe('api', function()
}, {
hl('UnaryPlus', '+', 1),
})
- check_parsing('@a+ ', 0, {
+ check_parsing('@a+ ', {
ast = {
{
'BinaryPlus:0:2:+',
@@ -1028,7 +1080,7 @@ describe('api', function()
})
end)
it('works with @a, + and parenthesis', function()
- check_parsing('(@a)', 0, {
+ check_parsing('(@a)', {
ast = {
{
'Nested:0:0:(',
@@ -1042,7 +1094,7 @@ describe('api', function()
hl('Register', '@a'),
hl('NestingParenthesis', ')'),
})
- check_parsing('()', 0, {
+ check_parsing('()', {
ast = {
{
'Nested:0:0:(',
@@ -1059,7 +1111,7 @@ describe('api', function()
hl('NestingParenthesis', '('),
hl('InvalidNestingParenthesis', ')'),
})
- check_parsing(')', 0, {
+ check_parsing(')', {
ast = {
{
'Nested:0:0:',
@@ -1075,7 +1127,7 @@ describe('api', function()
}, {
hl('InvalidNestingParenthesis', ')'),
})
- check_parsing('+)', 0, {
+ check_parsing('+)', {
ast = {
{
'Nested:0:1:',
@@ -1097,7 +1149,7 @@ describe('api', function()
hl('UnaryPlus', '+'),
hl('InvalidNestingParenthesis', ')'),
})
- check_parsing('+@a(@b)', 0, {
+ check_parsing('+@a(@b)', {
ast = {
{
'UnaryPlus:0:0:+',
@@ -1119,7 +1171,7 @@ describe('api', function()
hl('Register', '@b'),
hl('CallingParenthesis', ')'),
})
- check_parsing('@a+@b(@c)', 0, {
+ check_parsing('@a+@b(@c)', {
ast = {
{
'BinaryPlus:0:2:+',
@@ -1143,7 +1195,7 @@ describe('api', function()
hl('Register', '@c'),
hl('CallingParenthesis', ')'),
})
- check_parsing('@a()', 0, {
+ check_parsing('@a()', {
ast = {
{
'Call:0:2:(',
@@ -1157,7 +1209,7 @@ describe('api', function()
hl('CallingParenthesis', '('),
hl('CallingParenthesis', ')'),
})
- check_parsing('@a ()', 0, {
+ check_parsing('@a ()', {
ast = {
{
'OpMissing:0:2:',
@@ -1181,91 +1233,102 @@ describe('api', function()
hl('InvalidSpacing', ' '),
hl('NestingParenthesis', '('),
hl('InvalidNestingParenthesis', ')'),
- })
- check_parsing(
- '@a + (@b)', 0, {
+ }, {
+ [1] = {
ast = {
- {
- 'BinaryPlus:0:2: +',
- children = {
- 'Register(name=a):0:0:@a',
- {
- 'Nested:0:4: (',
- children = {
- 'Register(name=b):0:6:@b',
- },
+ 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)', 0, {
- 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('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)', 0, {
- 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('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', 0, {
+ },
+ }, {
+ 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:+',
@@ -1287,7 +1350,7 @@ describe('api', function()
hl('BinaryPlus', '+'),
hl('Register', '@b'),
})
- check_parsing('@a+(@b)(@c)', 0, {
+ check_parsing('@a+(@b)(@c)', {
-- 01234567890
ast = {
{
@@ -1317,7 +1380,7 @@ describe('api', function()
hl('Register', '@c'),
hl('CallingParenthesis', ')'),
})
- check_parsing('@a+((@b))(@c)', 0, {
+ check_parsing('@a+((@b))(@c)', {
-- 01234567890123456890123456789
-- 0 1 2
ast = {
@@ -1355,7 +1418,7 @@ describe('api', function()
hl('Register', '@c'),
hl('CallingParenthesis', ')'),
})
- check_parsing('@a+((@b))+@c', 0, {
+ check_parsing('@a+((@b))+@c', {
-- 01234567890123456890123456789
-- 0 1 2
ast = {
@@ -1393,7 +1456,7 @@ describe('api', function()
hl('Register', '@c'),
})
check_parsing(
- '@a + (@b + @c) + @d(@e) + (+@f) + ((+@g(@h))(@j)(@k))(@l)', 0, {--[[
+ '@a + (@b + @c) + @d(@e) + (+@f) + ((+@g(@h))(@j)(@k))(@l)', {--[[
| | | | | | | | || | | || | | ||| || || || ||
000000000011111111112222222222333333333344444444445555555
012345678901234567890123456789012345678901234567890123456
@@ -1527,7 +1590,7 @@ describe('api', function()
hl('Register', '@l'),
hl('CallingParenthesis', ')'),
})
- check_parsing('@a)', 0, {
+ check_parsing('@a)', {
-- 012
ast = {
{
@@ -1545,7 +1608,7 @@ describe('api', function()
hl('Register', '@a'),
hl('InvalidNestingParenthesis', ')'),
})
- check_parsing('(@a', 0, {
+ check_parsing('(@a', {
-- 012
ast = {
{
@@ -1563,7 +1626,7 @@ describe('api', function()
hl('NestingParenthesis', '('),
hl('Register', '@a'),
})
- check_parsing('@a(@b', 0, {
+ check_parsing('@a(@b', {
-- 01234
ast = {
{
@@ -1583,7 +1646,7 @@ describe('api', function()
hl('CallingParenthesis', '('),
hl('Register', '@b'),
})
- check_parsing('@a(@b, @c, @d, @e)', 0, {
+ check_parsing('@a(@b, @c, @d, @e)', {
-- 012345678901234567
-- 0 1
ast = {
@@ -1625,7 +1688,7 @@ describe('api', function()
hl('Register', '@e', 1),
hl('CallingParenthesis', ')'),
})
- check_parsing('@a(@b(@c))', 0, {
+ check_parsing('@a(@b(@c))', {
-- 01234567890123456789012345678901234567
-- 0 1 2 3
ast = {
@@ -1652,7 +1715,7 @@ describe('api', function()
hl('CallingParenthesis', ')'),
hl('CallingParenthesis', ')'),
})
- check_parsing('@a(@b(@c(@d(@e), @f(@g(@h), @i(@j)))))', 0, {
+ check_parsing('@a(@b(@c(@d(@e), @f(@g(@h), @i(@j)))))', {
-- 01234567890123456789012345678901234567
-- 0 1 2 3
ast = {
@@ -1742,14 +1805,14 @@ describe('api', function()
})
end)
it('works with variable names, including curly braces ones', function()
- check_parsing('var', 0, {
+ check_parsing('var', {
ast = {
'PlainIdentifier(scope=0,ident=var):0:0:var',
},
}, {
hl('IdentifierName', 'var'),
})
- check_parsing('g:var', 0, {
+ check_parsing('g:var', {
ast = {
'PlainIdentifier(scope=g,ident=var):0:0:g:var',
},
@@ -1758,7 +1821,7 @@ describe('api', function()
hl('IdentifierScopeDelimiter', ':'),
hl('IdentifierName', 'var'),
})
- check_parsing('g:', 0, {
+ check_parsing('g:', {
ast = {
'PlainIdentifier(scope=g,ident=):0:0:g:',
},
@@ -1766,7 +1829,7 @@ describe('api', function()
hl('IdentifierScope', 'g'),
hl('IdentifierScopeDelimiter', ':'),
})
- check_parsing('{a}', 0, {
+ check_parsing('{a}', {
-- 012
ast = {
{
@@ -1781,7 +1844,7 @@ describe('api', function()
hl('IdentifierName', 'a'),
hl('Curly', '}'),
})
- check_parsing('{a:b}', 0, {
+ check_parsing('{a:b}', {
-- 012
ast = {
{
@@ -1798,7 +1861,7 @@ describe('api', function()
hl('IdentifierName', 'b'),
hl('Curly', '}'),
})
- check_parsing('{a:@b}', 0, {
+ check_parsing('{a:@b}', {
-- 012345
ast = {
{
@@ -1825,7 +1888,7 @@ describe('api', function()
hl('InvalidRegister', '@b'),
hl('Curly', '}'),
})
- check_parsing('{@a}', 0, {
+ check_parsing('{@a}', {
ast = {
{
'CurlyBracesIdentifier:0:0:{',
@@ -1839,7 +1902,7 @@ describe('api', function()
hl('Register', '@a'),
hl('Curly', '}'),
})
- check_parsing('{@a}{@b}', 0, {
+ check_parsing('{@a}{@b}', {
-- 01234567
ast = {
{
@@ -1868,7 +1931,7 @@ describe('api', function()
hl('Register', '@b'),
hl('Curly', '}'),
})
- check_parsing('g:{@a}', 0, {
+ check_parsing('g:{@a}', {
-- 01234567
ast = {
{
@@ -1891,7 +1954,7 @@ describe('api', function()
hl('Register', '@a'),
hl('Curly', '}'),
})
- check_parsing('{@a}_test', 0, {
+ check_parsing('{@a}_test', {
-- 012345678
ast = {
{
@@ -1913,7 +1976,7 @@ describe('api', function()
hl('Curly', '}'),
hl('IdentifierName', '_test'),
})
- check_parsing('g:{@a}_test', 0, {
+ check_parsing('g:{@a}_test', {
-- 01234567890
ast = {
{
@@ -1943,7 +2006,7 @@ describe('api', function()
hl('Curly', '}'),
hl('IdentifierName', '_test'),
})
- check_parsing('g:{@a}_test()', 0, {
+ check_parsing('g:{@a}_test()', {
-- 0123456789012
ast = {
{
@@ -1980,7 +2043,7 @@ describe('api', function()
hl('CallingParenthesis', '('),
hl('CallingParenthesis', ')'),
})
- check_parsing('{@a} ()', 0, {
+ check_parsing('{@a} ()', {
-- 0123456789012
ast = {
{
@@ -2002,7 +2065,7 @@ describe('api', function()
hl('CallingParenthesis', '(', 1),
hl('CallingParenthesis', ')'),
})
- check_parsing('g:{@a} ()', 0, {
+ check_parsing('g:{@a} ()', {
-- 0123456789012
ast = {
{
@@ -2032,7 +2095,7 @@ describe('api', function()
hl('CallingParenthesis', '(', 1),
hl('CallingParenthesis', ')'),
})
- check_parsing('{@a', 0, {
+ check_parsing('{@a', {
-- 012
ast = {
{
@@ -2052,7 +2115,7 @@ describe('api', function()
})
end)
it('works with lambdas and dictionaries', function()
- check_parsing('{}', 0, {
+ check_parsing('{}', {
ast = {
'DictLiteral:0:0:{',
},
@@ -2060,7 +2123,7 @@ describe('api', function()
hl('Dict', '{'),
hl('Dict', '}'),
})
- check_parsing('{->@a}', 0, {
+ check_parsing('{->@a}', {
ast = {
{
'Lambda:0:0:{',
@@ -2080,7 +2143,7 @@ describe('api', function()
hl('Register', '@a'),
hl('Lambda', '}'),
})
- check_parsing('{->@a+@b}', 0, {
+ check_parsing('{->@a+@b}', {
-- 012345678
ast = {
{
@@ -2109,7 +2172,7 @@ describe('api', function()
hl('Register', '@b'),
hl('Lambda', '}'),
})
- check_parsing('{a->@a}', 0, {
+ check_parsing('{a->@a}', {
-- 012345678
ast = {
{
@@ -2132,7 +2195,7 @@ describe('api', function()
hl('Register', '@a'),
hl('Lambda', '}'),
})
- check_parsing('{a,b->@a}', 0, {
+ check_parsing('{a,b->@a}', {
-- 012345678
ast = {
{
@@ -2163,7 +2226,7 @@ describe('api', function()
hl('Register', '@a'),
hl('Lambda', '}'),
})
- check_parsing('{a,b,c->@a}', 0, {
+ check_parsing('{a,b,c->@a}', {
-- 01234567890
ast = {
{
@@ -2202,7 +2265,7 @@ describe('api', function()
hl('Register', '@a'),
hl('Lambda', '}'),
})
- check_parsing('{a,b,c,d->@a}', 0, {
+ check_parsing('{a,b,c,d->@a}', {
-- 0123456789012
ast = {
{
@@ -2249,7 +2312,7 @@ describe('api', function()
hl('Register', '@a'),
hl('Lambda', '}'),
})
- check_parsing('{a,b,c,d,->@a}', 0, {
+ check_parsing('{a,b,c,d,->@a}', {
-- 01234567890123
ast = {
{
@@ -2302,7 +2365,7 @@ describe('api', function()
hl('Register', '@a'),
hl('Lambda', '}'),
})
- check_parsing('{a,b->{c,d->{e,f->@a}}}', 0, {
+ check_parsing('{a,b->{c,d->{e,f->@a}}}', {
-- 01234567890123456789012
-- 0 1 2
ast = {
@@ -2380,7 +2443,7 @@ describe('api', function()
hl('Lambda', '}'),
hl('Lambda', '}'),
})
- check_parsing('{a,b->c,d}', 0, {
+ check_parsing('{a,b->c,d}', {
-- 0123456789
ast = {
{
@@ -2423,7 +2486,7 @@ describe('api', function()
hl('IdentifierName', 'd'),
hl('Lambda', '}'),
})
- check_parsing('a,b,c,d', 0, {
+ check_parsing('a,b,c,d', {
-- 0123456789
ast = {
{
@@ -2459,7 +2522,7 @@ describe('api', function()
hl('InvalidComma', ','),
hl('IdentifierName', 'd'),
})
- check_parsing('a,b,c,d,', 0, {
+ check_parsing('a,b,c,d,', {
-- 0123456789
ast = {
{
@@ -2501,7 +2564,7 @@ describe('api', function()
hl('IdentifierName', 'd'),
hl('InvalidComma', ','),
})
- check_parsing(',', 0, {
+ check_parsing(',', {
-- 0123456789
ast = {
{
@@ -2518,7 +2581,7 @@ describe('api', function()
}, {
hl('InvalidComma', ','),
})
- check_parsing('{,a->@a}', 0, {
+ check_parsing('{,a->@a}', {
-- 0123456789
ast = {
{
@@ -2552,7 +2615,7 @@ describe('api', function()
hl('Register', '@a'),
hl('Curly', '}'),
})
- check_parsing('}', 0, {
+ check_parsing('}', {
-- 0123456789
ast = {
'UnknownFigure:0:0:',
@@ -2564,7 +2627,7 @@ describe('api', function()
}, {
hl('InvalidFigureBrace', '}'),
})
- check_parsing('{->}', 0, {
+ check_parsing('{->}', {
-- 0123456789
ast = {
{
@@ -2583,7 +2646,7 @@ describe('api', function()
hl('Arrow', '->'),
hl('InvalidLambda', '}'),
})
- check_parsing('{a,b}', 0, {
+ check_parsing('{a,b}', {
-- 0123456789
ast = {
{
@@ -2610,7 +2673,7 @@ describe('api', function()
hl('IdentifierName', 'b'),
hl('InvalidLambda', '}'),
})
- check_parsing('{a,}', 0, {
+ check_parsing('{a,}', {
-- 0123456789
ast = {
{
@@ -2635,7 +2698,7 @@ describe('api', function()
hl('Comma', ','),
hl('InvalidLambda', '}'),
})
- check_parsing('{@a:@b}', 0, {
+ check_parsing('{@a:@b}', {
-- 0123456789
ast = {
{
@@ -2658,7 +2721,7 @@ describe('api', function()
hl('Register', '@b'),
hl('Dict', '}'),
})
- check_parsing('{@a:@b,@c:@d}', 0, {
+ check_parsing('{@a:@b,@c:@d}', {
-- 0123456789012
-- 0 1
ast = {
@@ -2698,7 +2761,7 @@ describe('api', function()
hl('Register', '@d'),
hl('Dict', '}'),
})
- check_parsing('{@a:@b,@c:@d,@e:@f,}', 0, {
+ check_parsing('{@a:@b,@c:@d,@e:@f,}', {
-- 01234567890123456789
-- 0 1
ast = {
@@ -2760,7 +2823,7 @@ describe('api', function()
hl('Comma', ','),
hl('Dict', '}'),
})
- check_parsing('{@a:@b,@c:@d,@e:@f,@g:}', 0, {
+ check_parsing('{@a:@b,@c:@d,@e:@f,@g:}', {
-- 01234567890123456789012
-- 0 1 2
ast = {
@@ -2834,7 +2897,7 @@ describe('api', function()
hl('Colon', ':'),
hl('InvalidDict', '}'),
})
- check_parsing('{@a:@b,}', 0, {
+ check_parsing('{@a:@b,}', {
-- 01234567890123
-- 0 1
ast = {
@@ -2864,7 +2927,7 @@ describe('api', function()
hl('Comma', ','),
hl('Dict', '}'),
})
- check_parsing('{({f -> g})(@h)(@i)}', 0, {
+ check_parsing('{({f -> g})(@h)(@i)}', {
-- 01234567890123456789
-- 0 1
ast = {
@@ -2920,7 +2983,7 @@ describe('api', function()
hl('CallingParenthesis', ')'),
hl('Curly', '}'),
})
- check_parsing('a:{b()}c', 0, {
+ check_parsing('a:{b()}c', {
-- 01234567
ast = {
{
@@ -2957,7 +3020,7 @@ describe('api', function()
hl('Curly', '}'),
hl('IdentifierName', 'c'),
})
- check_parsing('a:{{b, c -> @d + @e + ({f -> g})(@h)}(@i)}j', 0, {
+ check_parsing('a:{{b, c -> @d + @e + ({f -> g})(@h)}(@i)}j', {
-- 01234567890123456789012345678901234567890123456
-- 0 1 2 3 4
ast = {
@@ -3067,7 +3130,7 @@ describe('api', function()
hl('Curly', '}'),
hl('IdentifierName', 'j'),
})
- check_parsing('{@a + @b : @c + @d, @e + @f : @g + @i}', 0, {
+ check_parsing('{@a + @b : @c + @d, @e + @f : @g + @i}', {
-- 01234567890123456789012345678901234567
-- 0 1 2 3
ast = {
@@ -3139,7 +3202,7 @@ describe('api', function()
hl('Register', '@i', 1),
hl('Dict', '}'),
})
- check_parsing('-> -> ->', 0, {
+ check_parsing('-> -> ->', {
-- 01234567
ast = {
{
@@ -3170,7 +3233,7 @@ describe('api', function()
hl('InvalidArrow', '->', 1),
hl('InvalidArrow', '->', 1),
})
- check_parsing('a -> b -> c -> d', 0, {
+ check_parsing('a -> b -> c -> d', {
-- 0123456789012345
-- 0 1
ast = {
@@ -3207,7 +3270,7 @@ describe('api', function()
hl('InvalidArrow', '->', 1),
hl('IdentifierName', 'd', 1),
})
- check_parsing('{a -> b -> c}', 0, {
+ check_parsing('{a -> b -> c}', {
-- 0123456789012
-- 0 1
ast = {
@@ -3243,7 +3306,7 @@ describe('api', function()
hl('IdentifierName', 'c', 1),
hl('Lambda', '}'),
})
- check_parsing('{a: -> b}', 0, {
+ check_parsing('{a: -> b}', {
-- 012345678
ast = {
{
@@ -3272,7 +3335,7 @@ describe('api', function()
hl('Curly', '}'),
})
- check_parsing('{a:b -> b}', 0, {
+ check_parsing('{a:b -> b}', {
-- 0123456789
ast = {
{
@@ -3302,7 +3365,7 @@ describe('api', function()
hl('Curly', '}'),
})
- check_parsing('{a#b -> b}', 0, {
+ check_parsing('{a#b -> b}', {
-- 0123456789
ast = {
{
@@ -3329,7 +3392,7 @@ describe('api', function()
hl('IdentifierName', 'b', 1),
hl('Curly', '}'),
})
- check_parsing('{a : b : c}', 0, {
+ check_parsing('{a : b : c}', {
-- 01234567890
-- 0 1
ast = {
@@ -3365,7 +3428,7 @@ describe('api', function()
hl('IdentifierName', 'c', 1),
hl('Dict', '}'),
})
- check_parsing('{', 0, {
+ check_parsing('{', {
-- 0
ast = {
'UnknownFigure:0:0:{',
@@ -3377,7 +3440,7 @@ describe('api', function()
}, {
hl('FigureBrace', '{'),
})
- check_parsing('{a', 0, {
+ check_parsing('{a', {
-- 01
ast = {
{
@@ -3395,7 +3458,7 @@ describe('api', function()
hl('FigureBrace', '{'),
hl('IdentifierName', 'a'),
})
- check_parsing('{a,b', 0, {
+ check_parsing('{a,b', {
-- 0123
ast = {
{
@@ -3421,7 +3484,7 @@ describe('api', function()
hl('Comma', ','),
hl('IdentifierName', 'b'),
})
- check_parsing('{a,b->', 0, {
+ check_parsing('{a,b->', {
-- 012345
ast = {
{
@@ -3449,7 +3512,7 @@ describe('api', function()
hl('IdentifierName', 'b'),
hl('Arrow', '->'),
})
- check_parsing('{a,b->c', 0, {
+ check_parsing('{a,b->c', {
-- 0123456
ast = {
{
@@ -3483,7 +3546,7 @@ describe('api', function()
hl('Arrow', '->'),
hl('IdentifierName', 'c'),
})
- check_parsing('{a : b', 0, {
+ check_parsing('{a : b', {
-- 012345
ast = {
{
@@ -3509,7 +3572,7 @@ describe('api', function()
hl('Colon', ':', 1),
hl('IdentifierName', 'b', 1),
})
- check_parsing('{a : b,', 0, {
+ check_parsing('{a : b,', {
-- 0123456
ast = {
{
@@ -3543,7 +3606,7 @@ describe('api', function()
})
end)
it('works with ternary operator', function()
- check_parsing('a ? b : c', 0, {
+ check_parsing('a ? b : c', {
-- 012345678
ast = {
{
@@ -3567,7 +3630,7 @@ describe('api', function()
hl('TernaryColon', ':', 1),
hl('IdentifierName', 'c', 1),
})
- check_parsing('@a?@b?@c:@d:@e', 0, {
+ check_parsing('@a?@b?@c:@d:@e', {
-- 01234567890123
-- 0 1
ast = {
@@ -3608,7 +3671,7 @@ describe('api', function()
hl('TernaryColon', ':'),
hl('Register', '@e'),
})
- check_parsing('@a?@b:@c?@d:@e', 0, {
+ check_parsing('@a?@b:@c?@d:@e', {
-- 01234567890123
-- 0 1
ast = {
@@ -3649,7 +3712,7 @@ describe('api', function()
hl('TernaryColon', ':'),
hl('Register', '@e'),
})
- check_parsing('@a?@b?@c?@d:@e?@f:@g:@h?@i:@j:@k', 0, {
+ check_parsing('@a?@b?@c?@d:@e?@f:@g:@h?@i:@j:@k', {
-- 01234567890123456789012345678901
-- 0 1 2 3
ast = {
@@ -3738,7 +3801,7 @@ describe('api', function()
hl('TernaryColon', ':'),
hl('Register', '@k'),
})
- check_parsing('?', 0, {
+ check_parsing('?', {
-- 0
ast = {
{
@@ -3757,7 +3820,7 @@ describe('api', function()
hl('InvalidTernary', '?'),
})
- check_parsing('?:', 0, {
+ check_parsing('?:', {
-- 01
ast = {
{
@@ -3782,7 +3845,7 @@ describe('api', function()
hl('InvalidTernaryColon', ':'),
})
- check_parsing('?::', 0, {
+ check_parsing('?::', {
-- 012
ast = {
{
@@ -3814,7 +3877,7 @@ describe('api', function()
hl('InvalidColon', ':'),
})
- check_parsing('a?b', 0, {
+ check_parsing('a?b', {
-- 012
ast = {
{
@@ -3839,7 +3902,7 @@ describe('api', function()
hl('Ternary', '?'),
hl('IdentifierName', 'b'),
})
- check_parsing('a?b:', 0, {
+ check_parsing('a?b:', {
-- 0123
ast = {
{
@@ -3866,7 +3929,7 @@ describe('api', function()
hl('IdentifierScopeDelimiter', ':'),
})
- check_parsing('a?b::c', 0, {
+ check_parsing('a?b::c', {
-- 012345
ast = {
{
@@ -3892,7 +3955,7 @@ describe('api', function()
hl('IdentifierName', 'c'),
})
- check_parsing('a?b :', 0, {
+ check_parsing('a?b :', {
-- 01234
ast = {
{
@@ -3919,7 +3982,7 @@ describe('api', function()
hl('TernaryColon', ':', 1),
})
- check_parsing('(@a?@b:@c)?@d:@e', 0, {
+ check_parsing('(@a?@b:@c)?@d:@e', {
-- 0123456789012345
-- 0 1
ast = {
@@ -3968,7 +4031,7 @@ describe('api', function()
hl('Register', '@e'),
})
- check_parsing('(@a?@b:@c)?(@d?@e:@f):(@g?@h:@i)', 0, {
+ check_parsing('(@a?@b:@c)?(@d?@e:@f):(@g?@h:@i)', {
-- 01234567890123456789012345678901
-- 0 1 2 3
ast = {
@@ -4063,7 +4126,7 @@ describe('api', function()
hl('NestingParenthesis', ')'),
})
- check_parsing('(@a?@b:@c)?@d?@e:@f:@g?@h:@i', 0, {
+ check_parsing('(@a?@b:@c)?@d?@e:@f:@g?@h:@i', {
-- 0123456789012345678901234567
-- 0 1 2
ast = {
@@ -4143,7 +4206,7 @@ describe('api', function()
hl('TernaryColon', ':'),
hl('Register', '@i'),
})
- check_parsing('a?b{cdef}g:h', 0, {
+ check_parsing('a?b{cdef}g:h', {
-- 012345678901
-- 0 1
ast = {
@@ -4189,7 +4252,7 @@ describe('api', function()
hl('TernaryColon', ':'),
hl('IdentifierName', 'h'),
})
- check_parsing('a ? b : c : d', 0, {
+ check_parsing('a ? b : c : d', {
-- 0123456789012
-- 0 1
ast = {
@@ -4228,7 +4291,7 @@ describe('api', function()
})
end)
it('works with comparison operators', function()
- check_parsing('a == b', 0, {
+ check_parsing('a == b', {
-- 012345
ast = {
{
@@ -4245,7 +4308,7 @@ describe('api', function()
hl('IdentifierName', 'b', 1),
})
- check_parsing('a ==? b', 0, {
+ check_parsing('a ==? b', {
-- 0123456
ast = {
{
@@ -4263,7 +4326,7 @@ describe('api', function()
hl('IdentifierName', 'b', 1),
})
- check_parsing('a ==# b', 0, {
+ check_parsing('a ==# b', {
-- 0123456
ast = {
{
@@ -4281,7 +4344,7 @@ describe('api', function()
hl('IdentifierName', 'b', 1),
})
- check_parsing('a !=# b', 0, {
+ check_parsing('a !=# b', {
-- 0123456
ast = {
{
@@ -4299,7 +4362,7 @@ describe('api', function()
hl('IdentifierName', 'b', 1),
})
- check_parsing('a <=# b', 0, {
+ check_parsing('a <=# b', {
-- 0123456
ast = {
{
@@ -4317,7 +4380,7 @@ describe('api', function()
hl('IdentifierName', 'b', 1),
})
- check_parsing('a >=# b', 0, {
+ check_parsing('a >=# b', {
-- 0123456
ast = {
{
@@ -4335,7 +4398,7 @@ describe('api', function()
hl('IdentifierName', 'b', 1),
})
- check_parsing('a ># b', 0, {
+ check_parsing('a ># b', {
-- 012345
ast = {
{
@@ -4353,7 +4416,7 @@ describe('api', function()
hl('IdentifierName', 'b', 1),
})
- check_parsing('a <# b', 0, {
+ check_parsing('a <# b', {
-- 012345
ast = {
{
@@ -4371,7 +4434,7 @@ describe('api', function()
hl('IdentifierName', 'b', 1),
})
- check_parsing('a is#b', 0, {
+ check_parsing('a is#b', {
-- 012345
ast = {
{
@@ -4389,7 +4452,7 @@ describe('api', function()
hl('IdentifierName', 'b'),
})
- check_parsing('a is?b', 0, {
+ check_parsing('a is?b', {
-- 012345
ast = {
{
@@ -4407,7 +4470,7 @@ describe('api', function()
hl('IdentifierName', 'b'),
})
- check_parsing('a isnot b', 0, {
+ check_parsing('a isnot b', {
-- 012345678
ast = {
{
@@ -4424,7 +4487,7 @@ describe('api', function()
hl('IdentifierName', 'b', 1),
})
- check_parsing('a < b < c', 0, {
+ check_parsing('a < b < c', {
-- 012345678
ast = {
{
@@ -4453,7 +4516,7 @@ describe('api', function()
hl('IdentifierName', 'c', 1),
})
- check_parsing('a < b <# c', 0, {
+ check_parsing('a < b <# c', {
-- 012345678
ast = {
{
@@ -4483,7 +4546,7 @@ describe('api', function()
hl('IdentifierName', 'c', 1),
})
- check_parsing('a += b', 0, {
+ check_parsing('a += b', {
-- 012345
ast = {
{
@@ -4510,7 +4573,7 @@ describe('api', function()
hl('InvalidComparison', '='),
hl('IdentifierName', 'b', 1),
})
- check_parsing('a + b == c + d', 0, {
+ check_parsing('a + b == c + d', {
-- 01234567890123
-- 0 1
ast = {
@@ -4543,7 +4606,7 @@ describe('api', function()
hl('BinaryPlus', '+', 1),
hl('IdentifierName', 'd', 1),
})
- check_parsing('+ a == + b', 0, {
+ check_parsing('+ a == + b', {
-- 0123456789
ast = {
{
@@ -4573,7 +4636,7 @@ describe('api', function()
})
end)
it('works with concat/subscript', function()
- check_parsing('.', 0, {
+ check_parsing('.', {
-- 0
ast = {
{
@@ -4591,7 +4654,7 @@ describe('api', function()
hl('InvalidConcatOrSubscript', '.'),
})
- check_parsing('a.', 0, {
+ check_parsing('a.', {
-- 01
ast = {
{
@@ -4610,7 +4673,7 @@ describe('api', function()
hl('ConcatOrSubscript', '.'),
})
- check_parsing('a.b', 0, {
+ check_parsing('a.b', {
-- 012
ast = {
{
@@ -4627,7 +4690,7 @@ describe('api', function()
hl('IdentifierKey', 'b'),
})
- check_parsing('1.2', 0, {
+ check_parsing('1.2', {
-- 012
ast = {
'Float(val=1.200000e+00):0:0:1.2',
@@ -4636,7 +4699,7 @@ describe('api', function()
hl('Float', '1.2'),
})
- check_parsing('1.2 + 1.3e-5', 0, {
+ check_parsing('1.2 + 1.3e-5', {
-- 012345678901
-- 0 1
ast = {
@@ -4654,7 +4717,7 @@ describe('api', function()
hl('Float', '1.3e-5', 1),
})
- check_parsing('a . 1.2 + 1.3e-5', 0, {
+ check_parsing('a . 1.2 + 1.3e-5', {
-- 0123456789012345
-- 0 1
ast = {
@@ -4688,7 +4751,7 @@ describe('api', function()
hl('Float', '1.3e-5', 1),
})
- check_parsing('1.3e-5 + 1.2 . a', 0, {
+ check_parsing('1.3e-5 + 1.2 . a', {
-- 0123456789012345
-- 0 1
ast = {
@@ -4714,7 +4777,7 @@ describe('api', function()
hl('IdentifierName', 'a', 1),
})
- check_parsing('1.3e-5 + a . 1.2', 0, {
+ check_parsing('1.3e-5 + a . 1.2', {
-- 0123456789012345
-- 0 1
ast = {
@@ -4748,7 +4811,7 @@ describe('api', function()
hl('IdentifierKey', '2'),
})
- check_parsing('1.2.3', 0, {
+ check_parsing('1.2.3', {
-- 01234
ast = {
{
@@ -4773,7 +4836,7 @@ describe('api', function()
hl('IdentifierKey', '3'),
})
- check_parsing('a.1.2', 0, {
+ check_parsing('a.1.2', {
-- 01234
ast = {
{
@@ -4798,7 +4861,7 @@ describe('api', function()
hl('IdentifierKey', '2'),
})
- check_parsing('a . 1.2', 0, {
+ check_parsing('a . 1.2', {
-- 0123456
ast = {
{
@@ -4823,7 +4886,7 @@ describe('api', function()
hl('IdentifierKey', '2'),
})
- check_parsing('+a . +b', 0, {
+ check_parsing('+a . +b', {
-- 0123456
ast = {
{
@@ -4852,7 +4915,7 @@ describe('api', function()
hl('IdentifierName', 'b'),
})
- check_parsing('a. b', 0, {
+ check_parsing('a. b', {
-- 0123
ast = {
{
@@ -4869,7 +4932,7 @@ describe('api', function()
hl('IdentifierName', 'b', 1),
})
- check_parsing('a. 1', 0, {
+ check_parsing('a. 1', {
-- 0123
ast = {
{
@@ -4887,7 +4950,7 @@ describe('api', function()
})
end)
it('works with bracket subscripts', function()
- check_parsing(':', 0, {
+ check_parsing(':', {
-- 0
ast = {
{
@@ -4904,7 +4967,7 @@ describe('api', function()
}, {
hl('InvalidColon', ':'),
})
- check_parsing('a[]', 0, {
+ check_parsing('a[]', {
-- 012
ast = {
{
@@ -4923,7 +4986,7 @@ describe('api', function()
hl('SubscriptBracket', '['),
hl('InvalidSubscriptBracket', ']'),
})
- check_parsing('a[b:]', 0, {
+ check_parsing('a[b:]', {
-- 01234
ast = {
{
@@ -4942,7 +5005,7 @@ describe('api', function()
hl('SubscriptBracket', ']'),
})
- check_parsing('a[b:c]', 0, {
+ check_parsing('a[b:c]', {
-- 012345
ast = {
{
@@ -4961,7 +5024,7 @@ describe('api', function()
hl('IdentifierName', 'c'),
hl('SubscriptBracket', ']'),
})
- check_parsing('a[b : c]', 0, {
+ check_parsing('a[b : c]', {
-- 01234567
ast = {
{
@@ -4987,7 +5050,7 @@ describe('api', function()
hl('SubscriptBracket', ']'),
})
- check_parsing('a[: b]', 0, {
+ check_parsing('a[: b]', {
-- 012345
ast = {
{
@@ -5012,7 +5075,7 @@ describe('api', function()
hl('SubscriptBracket', ']'),
})
- check_parsing('a[b :]', 0, {
+ check_parsing('a[b :]', {
-- 012345
ast = {
{
@@ -5035,7 +5098,7 @@ describe('api', function()
hl('SubscriptColon', ':', 1),
hl('SubscriptBracket', ']'),
})
- check_parsing('a[b][c][d](e)(f)(g)', 0, {
+ check_parsing('a[b][c][d](e)(f)(g)', {
-- 0123456789012345678
-- 0 1
ast = {
@@ -5098,7 +5161,7 @@ describe('api', function()
hl('IdentifierName', 'g'),
hl('CallingParenthesis', ')'),
})
- check_parsing('{a}{b}{c}[d][e][f]', 0, {
+ check_parsing('{a}{b}{c}[d][e][f]', {
-- 012345678901234567
-- 0 1
ast = {
@@ -5171,7 +5234,7 @@ describe('api', function()
})
end)
it('supports list literals', function()
- check_parsing('[]', 0, {
+ check_parsing('[]', {
-- 01
ast = {
'ListLiteral:0:0:[',
@@ -5181,7 +5244,7 @@ describe('api', function()
hl('List', ']'),
})
- check_parsing('[a]', 0, {
+ check_parsing('[a]', {
-- 012
ast = {
{
@@ -5197,7 +5260,7 @@ describe('api', function()
hl('List', ']'),
})
- check_parsing('[a, b]', 0, {
+ check_parsing('[a, b]', {
-- 012345
ast = {
{
@@ -5221,7 +5284,7 @@ describe('api', function()
hl('List', ']'),
})
- check_parsing('[a, b, c]', 0, {
+ check_parsing('[a, b, c]', {
-- 012345678
ast = {
{
@@ -5253,7 +5316,7 @@ describe('api', function()
hl('List', ']'),
})
- check_parsing('[a, b, c, ]', 0, {
+ check_parsing('[a, b, c, ]', {
-- 01234567890
-- 0 1
ast = {
@@ -5292,7 +5355,7 @@ describe('api', function()
hl('List', ']', 1),
})
- check_parsing('[a : b, c : d]', 0, {
+ check_parsing('[a : b, c : d]', {
-- 01234567890123
-- 0 1
ast = {
@@ -5337,7 +5400,7 @@ describe('api', function()
hl('List', ']'),
})
- check_parsing(']', 0, {
+ check_parsing(']', {
-- 0
ast = {
'ListLiteral:0:0:',
@@ -5350,7 +5413,7 @@ describe('api', function()
hl('InvalidList', ']'),
})
- check_parsing('a]', 0, {
+ check_parsing('a]', {
-- 01
ast = {
{
@@ -5369,7 +5432,7 @@ describe('api', function()
hl('InvalidList', ']'),
})
- check_parsing('[] []', 0, {
+ check_parsing('[] []', {
-- 01234
ast = {
{
@@ -5390,9 +5453,23 @@ describe('api', function()
hl('InvalidSpacing', ' '),
hl('List', '['),
hl('List', ']'),
+ }, {
+ [1] = {
+ ast = {
+ err = REMOVE_THIS,
+ ast = {
+ 'ListLiteral:0:0:[',
+ },
+ },
+ hl_fs = {
+ [3] = REMOVE_THIS,
+ [4] = REMOVE_THIS,
+ [5] = REMOVE_THIS,
+ },
+ },
})
- check_parsing('[][]', 0, {
+ check_parsing('[][]', {
-- 0123
ast = {
{
@@ -5413,7 +5490,7 @@ describe('api', function()
hl('InvalidSubscriptBracket', ']'),
})
- check_parsing('[', 0, {
+ check_parsing('[', {
-- 0
ast = {
'ListLiteral:0:0:[',
@@ -5426,7 +5503,7 @@ describe('api', function()
hl('List', '['),
})
- check_parsing('[1', 0, {
+ check_parsing('[1', {
-- 01
ast = {
{
@@ -5446,7 +5523,7 @@ describe('api', function()
})
end)
it('works with strings', function()
- check_parsing('\'abc\'', 0, {
+ check_parsing('\'abc\'', {
-- 01234
ast = {
'SingleQuotedString(val="abc"):0:0:\'abc\'',
@@ -5456,7 +5533,7 @@ describe('api', function()
hl('SingleQuotedBody', 'abc'),
hl('SingleQuote', '\''),
})
- check_parsing('"abc"', 0, {
+ check_parsing('"abc"', {
-- 01234
ast = {
'DoubleQuotedString(val="abc"):0:0:"abc"',
@@ -5466,7 +5543,7 @@ describe('api', function()
hl('DoubleQuotedBody', 'abc'),
hl('DoubleQuote', '"'),
})
- check_parsing('\'\'', 0, {
+ check_parsing('\'\'', {
-- 01
ast = {
'SingleQuotedString(val=""):0:0:\'\'',
@@ -5475,7 +5552,7 @@ describe('api', function()
hl('SingleQuote', '\''),
hl('SingleQuote', '\''),
})
- check_parsing('""', 0, {
+ check_parsing('""', {
-- 01
ast = {
'DoubleQuotedString(val=""):0:0:""',
@@ -5484,7 +5561,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
hl('DoubleQuote', '"'),
})
- check_parsing('"', 0, {
+ check_parsing('"', {
-- 0
ast = {
'DoubleQuotedString(val=""):0:0:"',
@@ -5496,7 +5573,7 @@ describe('api', function()
}, {
hl('InvalidDoubleQuote', '"'),
})
- check_parsing('\'', 0, {
+ check_parsing('\'', {
-- 0
ast = {
'SingleQuotedString(val=""):0:0:\'',
@@ -5508,7 +5585,7 @@ describe('api', function()
}, {
hl('InvalidSingleQuote', '\''),
})
- check_parsing('"a', 0, {
+ check_parsing('"a', {
-- 01
ast = {
'DoubleQuotedString(val="a"):0:0:"a',
@@ -5521,7 +5598,7 @@ describe('api', function()
hl('InvalidDoubleQuote', '"'),
hl('InvalidDoubleQuotedBody', 'a'),
})
- check_parsing('\'a', 0, {
+ check_parsing('\'a', {
-- 01
ast = {
'SingleQuotedString(val="a"):0:0:\'a',
@@ -5534,7 +5611,7 @@ describe('api', function()
hl('InvalidSingleQuote', '\''),
hl('InvalidSingleQuotedBody', 'a'),
})
- check_parsing('\'abc\'\'def\'', 0, {
+ check_parsing('\'abc\'\'def\'', {
-- 0123456789
ast = {
'SingleQuotedString(val="abc\'def"):0:0:\'abc\'\'def\'',
@@ -5546,7 +5623,7 @@ describe('api', function()
hl('SingleQuotedBody', 'def'),
hl('SingleQuote', '\''),
})
- check_parsing('\'abc\'\'', 0, {
+ check_parsing('\'abc\'\'', {
-- 012345
ast = {
'SingleQuotedString(val="abc\'"):0:0:\'abc\'\'',
@@ -5560,7 +5637,7 @@ describe('api', function()
hl('InvalidSingleQuotedBody', 'abc'),
hl('InvalidSingleQuotedQuote', '\'\''),
})
- check_parsing('\'\'\'\'\'\'\'\'', 0, {
+ check_parsing('\'\'\'\'\'\'\'\'', {
-- 01234567
ast = {
'SingleQuotedString(val="\'\'\'"):0:0:\'\'\'\'\'\'\'\'',
@@ -5572,7 +5649,7 @@ describe('api', function()
hl('SingleQuotedQuote', '\'\''),
hl('SingleQuote', '\''),
})
- check_parsing('\'\'\'a\'\'\'\'bc\'', 0, {
+ check_parsing('\'\'\'a\'\'\'\'bc\'', {
-- 01234567890
-- 0 1
ast = {
@@ -5587,7 +5664,7 @@ describe('api', function()
hl('SingleQuotedBody', 'bc'),
hl('SingleQuote', '\''),
})
- check_parsing('"\\"\\"\\"\\""', 0, {
+ check_parsing('"\\"\\"\\"\\""', {
-- 0123456789
ast = {
'DoubleQuotedString(val="\\"\\"\\"\\""):0:0:"\\"\\"\\"\\""',
@@ -5600,7 +5677,7 @@ describe('api', function()
hl('DoubleQuotedEscape', '\\"'),
hl('DoubleQuote', '"'),
})
- check_parsing('"abc\\"def\\"ghi\\"jkl\\"mno"', 0, {
+ check_parsing('"abc\\"def\\"ghi\\"jkl\\"mno"', {
-- 0123456789012345678901234
-- 0 1 2
ast = {
@@ -5619,7 +5696,7 @@ describe('api', function()
hl('DoubleQuotedBody', 'mno'),
hl('DoubleQuote', '"'),
})
- check_parsing('"\\b\\e\\f\\r\\t\\\\"', 0, {
+ check_parsing('"\\b\\e\\f\\r\\t\\\\"', {
-- 0123456789012345
-- 0 1
ast = {
@@ -5635,7 +5712,7 @@ describe('api', function()
hl('DoubleQuotedEscape', '\\\\'),
hl('DoubleQuote', '"'),
})
- check_parsing('"\\n\n"', 0, {
+ check_parsing('"\\n\n"', {
-- 01234
ast = {
'DoubleQuotedString(val="\\\n\\\n"):0:0:"\\n\n"',
@@ -5646,7 +5723,7 @@ describe('api', function()
hl('DoubleQuotedBody', '\n'),
hl('DoubleQuote', '"'),
})
- check_parsing('"\\x00"', 0, {
+ check_parsing('"\\x00"', {
-- 012345
ast = {
'DoubleQuotedString(val="\\0"):0:0:"\\x00"',
@@ -5656,7 +5733,7 @@ describe('api', function()
hl('DoubleQuotedEscape', '\\x00'),
hl('DoubleQuote', '"'),
})
- check_parsing('"\\xFF"', 0, {
+ check_parsing('"\\xFF"', {
-- 012345
ast = {
'DoubleQuotedString(val="\255"):0:0:"\\xFF"',
@@ -5666,7 +5743,7 @@ describe('api', function()
hl('DoubleQuotedEscape', '\\xFF'),
hl('DoubleQuote', '"'),
})
- check_parsing('"\\xF"', 0, {
+ check_parsing('"\\xF"', {
-- 012345
ast = {
'DoubleQuotedString(val="\\15"):0:0:"\\xF"',
@@ -5676,7 +5753,7 @@ describe('api', function()
hl('DoubleQuotedEscape', '\\xF'),
hl('DoubleQuote', '"'),
})
- check_parsing('"\\u00AB"', 0, {
+ check_parsing('"\\u00AB"', {
-- 01234567
ast = {
'DoubleQuotedString(val="«"):0:0:"\\u00AB"',
@@ -5686,7 +5763,7 @@ describe('api', function()
hl('DoubleQuotedEscape', '\\u00AB'),
hl('DoubleQuote', '"'),
})
- check_parsing('"\\U000000AB"', 0, {
+ check_parsing('"\\U000000AB"', {
-- 01234567
ast = {
'DoubleQuotedString(val="«"):0:0:"\\U000000AB"',
@@ -5696,7 +5773,7 @@ describe('api', function()
hl('DoubleQuotedEscape', '\\U000000AB'),
hl('DoubleQuote', '"'),
})
- check_parsing('"\\x"', 0, {
+ check_parsing('"\\x"', {
-- 0123
ast = {
'DoubleQuotedString(val="x"):0:0:"\\x"',
@@ -5707,7 +5784,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\x', 0, {
+ check_parsing('"\\x', {
-- 012
ast = {
'DoubleQuotedString(val="x"):0:0:"\\x',
@@ -5721,7 +5798,7 @@ describe('api', function()
hl('InvalidDoubleQuotedUnknownEscape', '\\x'),
})
- check_parsing('"\\xF', 0, {
+ check_parsing('"\\xF', {
-- 0123
ast = {
'DoubleQuotedString(val="\\15"):0:0:"\\xF',
@@ -5735,7 +5812,7 @@ describe('api', function()
hl('InvalidDoubleQuotedEscape', '\\xF'),
})
- check_parsing('"\\u"', 0, {
+ check_parsing('"\\u"', {
-- 0123
ast = {
'DoubleQuotedString(val="u"):0:0:"\\u"',
@@ -5746,7 +5823,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\u', 0, {
+ check_parsing('"\\u', {
-- 012
ast = {
'DoubleQuotedString(val="u"):0:0:"\\u',
@@ -5760,7 +5837,7 @@ describe('api', function()
hl('InvalidDoubleQuotedUnknownEscape', '\\u'),
})
- check_parsing('"\\U', 0, {
+ check_parsing('"\\U', {
-- 012
ast = {
'DoubleQuotedString(val="U"):0:0:"\\U',
@@ -5774,7 +5851,7 @@ describe('api', function()
hl('InvalidDoubleQuotedUnknownEscape', '\\U'),
})
- check_parsing('"\\U"', 0, {
+ check_parsing('"\\U"', {
-- 0123
ast = {
'DoubleQuotedString(val="U"):0:0:"\\U"',
@@ -5785,7 +5862,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\xFX"', 0, {
+ check_parsing('"\\xFX"', {
-- 012345
ast = {
'DoubleQuotedString(val="\\15X"):0:0:"\\xFX"',
@@ -5797,7 +5874,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\XFX"', 0, {
+ check_parsing('"\\XFX"', {
-- 012345
ast = {
'DoubleQuotedString(val="\\15X"):0:0:"\\XFX"',
@@ -5809,7 +5886,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\xX"', 0, {
+ check_parsing('"\\xX"', {
-- 01234
ast = {
'DoubleQuotedString(val="xX"):0:0:"\\xX"',
@@ -5821,7 +5898,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\XX"', 0, {
+ check_parsing('"\\XX"', {
-- 01234
ast = {
'DoubleQuotedString(val="XX"):0:0:"\\XX"',
@@ -5833,7 +5910,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\uX"', 0, {
+ check_parsing('"\\uX"', {
-- 01234
ast = {
'DoubleQuotedString(val="uX"):0:0:"\\uX"',
@@ -5845,7 +5922,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\UX"', 0, {
+ check_parsing('"\\UX"', {
-- 01234
ast = {
'DoubleQuotedString(val="UX"):0:0:"\\UX"',
@@ -5857,7 +5934,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\x0X"', 0, {
+ check_parsing('"\\x0X"', {
-- 012345
ast = {
'DoubleQuotedString(val="\\0X"):0:0:"\\x0X"',
@@ -5869,7 +5946,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\X0X"', 0, {
+ check_parsing('"\\X0X"', {
-- 012345
ast = {
'DoubleQuotedString(val="\\0X"):0:0:"\\X0X"',
@@ -5881,7 +5958,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\u0X"', 0, {
+ check_parsing('"\\u0X"', {
-- 012345
ast = {
'DoubleQuotedString(val="\\0X"):0:0:"\\u0X"',
@@ -5893,7 +5970,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\U0X"', 0, {
+ check_parsing('"\\U0X"', {
-- 012345
ast = {
'DoubleQuotedString(val="\\0X"):0:0:"\\U0X"',
@@ -5905,7 +5982,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\x00X"', 0, {
+ check_parsing('"\\x00X"', {
-- 0123456
ast = {
'DoubleQuotedString(val="\\0X"):0:0:"\\x00X"',
@@ -5917,7 +5994,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\X00X"', 0, {
+ check_parsing('"\\X00X"', {
-- 0123456
ast = {
'DoubleQuotedString(val="\\0X"):0:0:"\\X00X"',
@@ -5929,7 +6006,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\u00X"', 0, {
+ check_parsing('"\\u00X"', {
-- 0123456
ast = {
'DoubleQuotedString(val="\\0X"):0:0:"\\u00X"',
@@ -5941,7 +6018,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\U00X"', 0, {
+ check_parsing('"\\U00X"', {
-- 0123456
ast = {
'DoubleQuotedString(val="\\0X"):0:0:"\\U00X"',
@@ -5953,7 +6030,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\u000X"', 0, {
+ check_parsing('"\\u000X"', {
-- 01234567
ast = {
'DoubleQuotedString(val="\\0X"):0:0:"\\u000X"',
@@ -5965,7 +6042,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\U000X"', 0, {
+ check_parsing('"\\U000X"', {
-- 01234567
ast = {
'DoubleQuotedString(val="\\0X"):0:0:"\\U000X"',
@@ -5977,7 +6054,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\u0000X"', 0, {
+ check_parsing('"\\u0000X"', {
-- 012345678
ast = {
'DoubleQuotedString(val="\\0X"):0:0:"\\u0000X"',
@@ -5989,7 +6066,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\U0000X"', 0, {
+ check_parsing('"\\U0000X"', {
-- 012345678
ast = {
'DoubleQuotedString(val="\\0X"):0:0:"\\U0000X"',
@@ -6001,7 +6078,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\U00000X"', 0, {
+ check_parsing('"\\U00000X"', {
-- 0123456789
ast = {
'DoubleQuotedString(val="\\0X"):0:0:"\\U00000X"',
@@ -6013,7 +6090,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\U000000X"', 0, {
+ check_parsing('"\\U000000X"', {
-- 01234567890
-- 0 1
ast = {
@@ -6026,7 +6103,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\U0000000X"', 0, {
+ check_parsing('"\\U0000000X"', {
-- 012345678901
-- 0 1
ast = {
@@ -6039,7 +6116,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\U00000000X"', 0, {
+ check_parsing('"\\U00000000X"', {
-- 0123456789012
-- 0 1
ast = {
@@ -6052,7 +6129,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\x000X"', 0, {
+ check_parsing('"\\x000X"', {
-- 01234567
ast = {
'DoubleQuotedString(val="\\0000X"):0:0:"\\x000X"',
@@ -6064,7 +6141,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\X000X"', 0, {
+ check_parsing('"\\X000X"', {
-- 01234567
ast = {
'DoubleQuotedString(val="\\0000X"):0:0:"\\X000X"',
@@ -6076,7 +6153,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\u00000X"', 0, {
+ check_parsing('"\\u00000X"', {
-- 0123456789
ast = {
'DoubleQuotedString(val="\\0000X"):0:0:"\\u00000X"',
@@ -6088,7 +6165,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\U000000000X"', 0, {
+ check_parsing('"\\U000000000X"', {
-- 01234567890123
-- 0 1
ast = {
@@ -6101,7 +6178,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\0"', 0, {
+ check_parsing('"\\0"', {
-- 0123
ast = {
'DoubleQuotedString(val="\\0"):0:0:"\\0"',
@@ -6112,7 +6189,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\00"', 0, {
+ check_parsing('"\\00"', {
-- 01234
ast = {
'DoubleQuotedString(val="\\0"):0:0:"\\00"',
@@ -6123,7 +6200,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\000"', 0, {
+ check_parsing('"\\000"', {
-- 012345
ast = {
'DoubleQuotedString(val="\\0"):0:0:"\\000"',
@@ -6134,7 +6211,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\0000"', 0, {
+ check_parsing('"\\0000"', {
-- 0123456
ast = {
'DoubleQuotedString(val="\\0000"):0:0:"\\0000"',
@@ -6146,7 +6223,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\8"', 0, {
+ check_parsing('"\\8"', {
-- 0123
ast = {
'DoubleQuotedString(val="8"):0:0:"\\8"',
@@ -6157,7 +6234,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\08"', 0, {
+ check_parsing('"\\08"', {
-- 01234
ast = {
'DoubleQuotedString(val="\\0008"):0:0:"\\08"',
@@ -6169,7 +6246,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\008"', 0, {
+ check_parsing('"\\008"', {
-- 012345
ast = {
'DoubleQuotedString(val="\\0008"):0:0:"\\008"',
@@ -6181,7 +6258,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\0008"', 0, {
+ check_parsing('"\\0008"', {
-- 0123456
ast = {
'DoubleQuotedString(val="\\0008"):0:0:"\\0008"',
@@ -6193,7 +6270,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\777"', 0, {
+ check_parsing('"\\777"', {
-- 012345
ast = {
'DoubleQuotedString(val="\255"):0:0:"\\777"',
@@ -6204,7 +6281,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\050"', 0, {
+ check_parsing('"\\050"', {
-- 012345
ast = {
'DoubleQuotedString(val="\40"):0:0:"\\050"',
@@ -6215,7 +6292,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\<C-u>"', 0, {
+ check_parsing('"\\<C-u>"', {
-- 012345
ast = {
'DoubleQuotedString(val="\\21"):0:0:"\\<C-u>"',
@@ -6226,7 +6303,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\<', 0, {
+ check_parsing('"\\<', {
-- 012
ast = {
'DoubleQuotedString(val="<"):0:0:"\\<',
@@ -6240,7 +6317,7 @@ describe('api', function()
hl('InvalidDoubleQuotedUnknownEscape', '\\<'),
})
- check_parsing('"\\<"', 0, {
+ check_parsing('"\\<"', {
-- 0123
ast = {
'DoubleQuotedString(val="<"):0:0:"\\<"',
@@ -6251,7 +6328,7 @@ describe('api', function()
hl('DoubleQuote', '"'),
})
- check_parsing('"\\<C-u"', 0, {
+ check_parsing('"\\<C-u"', {
-- 0123456
ast = {
'DoubleQuotedString(val="<C-u"):0:0:"\\<C-u"',
@@ -6264,7 +6341,7 @@ describe('api', function()
})
end)
it('works with multiplication-like operators', function()
- check_parsing('2+2*2', 0, {
+ check_parsing('2+2*2', {
-- 01234
ast = {
{
@@ -6289,7 +6366,7 @@ describe('api', function()
hl('Number', '2'),
})
- check_parsing('2+2*', 0, {
+ check_parsing('2+2*', {
-- 0123
ast = {
{
@@ -6316,7 +6393,7 @@ describe('api', function()
hl('Multiplication', '*'),
})
- check_parsing('2+*2', 0, {
+ check_parsing('2+*2', {
-- 0123
ast = {
{
@@ -6344,7 +6421,7 @@ describe('api', function()
hl('Number', '2'),
})
- check_parsing('2+2/2', 0, {
+ check_parsing('2+2/2', {
-- 01234
ast = {
{
@@ -6369,7 +6446,7 @@ describe('api', function()
hl('Number', '2'),
})
- check_parsing('2+2/', 0, {
+ check_parsing('2+2/', {
-- 0123
ast = {
{
@@ -6396,7 +6473,7 @@ describe('api', function()
hl('Division', '/'),
})
- check_parsing('2+/2', 0, {
+ check_parsing('2+/2', {
-- 0123
ast = {
{
@@ -6424,7 +6501,7 @@ describe('api', function()
hl('Number', '2'),
})
- check_parsing('2+2%2', 0, {
+ check_parsing('2+2%2', {
-- 01234
ast = {
{
@@ -6449,7 +6526,7 @@ describe('api', function()
hl('Number', '2'),
})
- check_parsing('2+2%', 0, {
+ check_parsing('2+2%', {
-- 0123
ast = {
{
@@ -6476,7 +6553,7 @@ describe('api', function()
hl('Mod', '%'),
})
- check_parsing('2+%2', 0, {
+ check_parsing('2+%2', {
-- 0123
ast = {
{
@@ -6505,14 +6582,14 @@ describe('api', function()
})
end)
it('works with -', function()
- check_parsing('@a', 0, {
+ check_parsing('@a', {
ast = {
'Register(name=a):0:0:@a',
},
}, {
hl('Register', '@a'),
})
- check_parsing('-@a', 0, {
+ check_parsing('-@a', {
ast = {
{
'UnaryMinus:0:0:-',
@@ -6525,7 +6602,7 @@ describe('api', function()
hl('UnaryMinus', '-'),
hl('Register', '@a'),
})
- check_parsing('@a-@b', 0, {
+ check_parsing('@a-@b', {
ast = {
{
'BinaryMinus:0:2:-',
@@ -6540,7 +6617,7 @@ describe('api', function()
hl('BinaryMinus', '-'),
hl('Register', '@b'),
})
- check_parsing('@a-@b-@c', 0, {
+ check_parsing('@a-@b-@c', {
ast = {
{
'BinaryMinus:0:5:-',
@@ -6563,7 +6640,7 @@ describe('api', function()
hl('BinaryMinus', '-'),
hl('Register', '@c'),
})
- check_parsing('-@a-@b', 0, {
+ check_parsing('-@a-@b', {
ast = {
{
'BinaryMinus:0:3:-',
@@ -6584,7 +6661,7 @@ describe('api', function()
hl('BinaryMinus', '-'),
hl('Register', '@b'),
})
- check_parsing('-@a--@b', 0, {
+ check_parsing('-@a--@b', {
ast = {
{
'BinaryMinus:0:3:-',
@@ -6611,44 +6688,7 @@ describe('api', function()
hl('UnaryMinus', '-'),
hl('Register', '@b'),
})
- check_parsing('@a@b', 0, {
- 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'),
- })
- check_parsing(' @a \t @b', 0, {
- 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'),
- })
- check_parsing('-', 0, {
+ check_parsing('-', {
ast = {
'UnaryMinus:0:0:-',
},
@@ -6659,7 +6699,7 @@ describe('api', function()
}, {
hl('UnaryMinus', '-'),
})
- check_parsing(' -', 0, {
+ check_parsing(' -', {
ast = {
'UnaryMinus:0:0: -',
},
@@ -6670,7 +6710,7 @@ describe('api', function()
}, {
hl('UnaryMinus', '-', 1),
})
- check_parsing('@a- ', 0, {
+ check_parsing('@a- ', {
ast = {
{
'BinaryMinus:0:2:-',
@@ -6689,7 +6729,7 @@ describe('api', function()
})
end)
it('works with logical operators', function()
- check_parsing('a && b || c && d', 0, {
+ check_parsing('a && b || c && d', {
-- 0123456789012345
-- 0 1
ast = {
@@ -6723,7 +6763,7 @@ describe('api', function()
hl('IdentifierName', 'd', 1),
})
- check_parsing('&& a', 0, {
+ check_parsing('&& a', {
-- 0123
ast = {
{
@@ -6743,7 +6783,7 @@ describe('api', function()
hl('IdentifierName', 'a', 1),
})
- check_parsing('|| a', 0, {
+ check_parsing('|| a', {
-- 0123
ast = {
{
@@ -6763,7 +6803,7 @@ describe('api', function()
hl('IdentifierName', 'a', 1),
})
- check_parsing('a||', 0, {
+ check_parsing('a||', {
-- 012
ast = {
{
@@ -6782,7 +6822,7 @@ describe('api', function()
hl('Or', '||'),
})
- check_parsing('a&&', 0, {
+ check_parsing('a&&', {
-- 012
ast = {
{
@@ -6801,7 +6841,7 @@ describe('api', function()
hl('And', '&&'),
})
- check_parsing('(&&)', 0, {
+ check_parsing('(&&)', {
-- 0123
ast = {
{
@@ -6827,7 +6867,7 @@ describe('api', function()
hl('InvalidNestingParenthesis', ')'),
})
- check_parsing('(||)', 0, {
+ check_parsing('(||)', {
-- 0123
ast = {
{
@@ -6853,7 +6893,7 @@ describe('api', function()
hl('InvalidNestingParenthesis', ')'),
})
- check_parsing('(a||)', 0, {
+ check_parsing('(a||)', {
-- 01234
ast = {
{
@@ -6880,7 +6920,7 @@ describe('api', function()
hl('InvalidNestingParenthesis', ')'),
})
- check_parsing('(a&&)', 0, {
+ check_parsing('(a&&)', {
-- 01234
ast = {
{
@@ -6907,7 +6947,7 @@ describe('api', function()
hl('InvalidNestingParenthesis', ')'),
})
- check_parsing('(&&a)', 0, {
+ check_parsing('(&&a)', {
-- 01234
ast = {
{
@@ -6934,7 +6974,7 @@ describe('api', function()
hl('NestingParenthesis', ')'),
})
- check_parsing('(||a)', 0, {
+ check_parsing('(||a)', {
-- 01234
ast = {
{
@@ -6962,7 +7002,7 @@ describe('api', function()
})
end)
it('works with &opt', function()
- check_parsing('&', 0, {
+ check_parsing('&', {
-- 0
ast = {
'Option(scope=0,ident=):0:0:&',
@@ -6975,7 +7015,7 @@ describe('api', function()
hl('InvalidOptionSigil', '&'),
})
- check_parsing('&opt', 0, {
+ check_parsing('&opt', {
-- 0123
ast = {
'Option(scope=0,ident=opt):0:0:&opt',
@@ -6985,7 +7025,7 @@ describe('api', function()
hl('OptionName', 'opt'),
})
- check_parsing('&l:opt', 0, {
+ check_parsing('&l:opt', {
-- 012345
ast = {
'Option(scope=l,ident=opt):0:0:&l:opt',
@@ -6997,7 +7037,7 @@ describe('api', function()
hl('OptionName', 'opt'),
})
- check_parsing('&g:opt', 0, {
+ check_parsing('&g:opt', {
-- 012345
ast = {
'Option(scope=g,ident=opt):0:0:&g:opt',
@@ -7009,7 +7049,7 @@ describe('api', function()
hl('OptionName', 'opt'),
})
- check_parsing('&s:opt', 0, {
+ check_parsing('&s:opt', {
-- 012345
ast = {
{
@@ -7031,7 +7071,7 @@ describe('api', function()
hl('IdentifierName', 'opt'),
})
- check_parsing('& ', 0, {
+ check_parsing('& ', {
-- 01
ast = {
'Option(scope=0,ident=):0:0:&',
@@ -7044,7 +7084,7 @@ describe('api', function()
hl('InvalidOptionSigil', '&'),
})
- check_parsing('&-', 0, {
+ check_parsing('&-', {
-- 01
ast = {
{
@@ -7063,7 +7103,7 @@ describe('api', function()
hl('BinaryMinus', '-'),
})
- check_parsing('&A', 0, {
+ check_parsing('&A', {
-- 01
ast = {
'Option(scope=0,ident=A):0:0:&A',
@@ -7073,7 +7113,7 @@ describe('api', function()
hl('OptionName', 'A'),
})
- check_parsing('&xxx_yyy', 0, {
+ check_parsing('&xxx_yyy', {
-- 01234567
ast = {
{
@@ -7092,9 +7132,21 @@ describe('api', function()
hl('OptionSigil', '&'),
hl('OptionName', 'xxx'),
hl('InvalidIdentifierName', '_yyy'),
+ }, {
+ [1] = {
+ ast = {
+ err = REMOVE_THIS,
+ ast = {
+ 'Option(scope=0,ident=xxx):0:0:&xxx',
+ },
+ },
+ hl_fs = {
+ [3] = REMOVE_THIS,
+ },
+ },
})
- check_parsing('(1+&)', 0, {
+ check_parsing('(1+&)', {
-- 01234
ast = {
{
@@ -7122,7 +7174,7 @@ describe('api', function()
hl('NestingParenthesis', ')'),
})
- check_parsing('(&+1)', 0, {
+ check_parsing('(&+1)', {
-- 01234
ast = {
{
@@ -7151,7 +7203,7 @@ describe('api', function()
})
end)
it('works with $ENV', function()
- check_parsing('$', 0, {
+ check_parsing('$', {
-- 0
ast = {
'Environment(ident=):0:0:$',
@@ -7164,7 +7216,7 @@ describe('api', function()
hl('InvalidEnvironmentSigil', '$'),
})
- check_parsing('$g:A', 0, {
+ check_parsing('$g:A', {
-- 0123
ast = {
{
@@ -7186,7 +7238,7 @@ describe('api', function()
hl('IdentifierName', 'A'),
})
- check_parsing('$A', 0, {
+ check_parsing('$A', {
-- 01
ast = {
'Environment(ident=A):0:0:$A',
@@ -7196,7 +7248,7 @@ describe('api', function()
hl('EnvironmentName', 'A'),
})
- check_parsing('$ABC', 0, {
+ check_parsing('$ABC', {
-- 0123
ast = {
'Environment(ident=ABC):0:0:$ABC',
@@ -7206,7 +7258,7 @@ describe('api', function()
hl('EnvironmentName', 'ABC'),
})
- check_parsing('(1+$)', 0, {
+ check_parsing('(1+$)', {
-- 01234
ast = {
{
@@ -7234,7 +7286,7 @@ describe('api', function()
hl('NestingParenthesis', ')'),
})
- check_parsing('($+1)', 0, {
+ check_parsing('($+1)', {
-- 01234
ast = {
{
@@ -7262,7 +7314,7 @@ describe('api', function()
hl('NestingParenthesis', ')'),
})
- check_parsing('$_ABC', 0, {
+ check_parsing('$_ABC', {
-- 01234
ast = {
'Environment(ident=_ABC):0:0:$_ABC',
@@ -7272,7 +7324,7 @@ describe('api', function()
hl('EnvironmentName', '_ABC'),
})
- check_parsing('$_', 0, {
+ check_parsing('$_', {
-- 01
ast = {
'Environment(ident=_):0:0:$_',
@@ -7282,7 +7334,7 @@ describe('api', function()
hl('EnvironmentName', '_'),
})
- check_parsing('$ABC_DEF', 0, {
+ check_parsing('$ABC_DEF', {
-- 01234567
ast = {
'Environment(ident=ABC_DEF):0:0:$ABC_DEF',
@@ -7293,7 +7345,7 @@ describe('api', function()
})
end)
it('works with unary !', function()
- check_parsing('!', 0, {
+ check_parsing('!', {
-- 0
ast = {
'Not:0:0:!',
@@ -7306,7 +7358,7 @@ describe('api', function()
hl('Not', '!'),
})
- check_parsing('!!', 0, {
+ check_parsing('!!', {
-- 01
ast = {
{
@@ -7325,7 +7377,7 @@ describe('api', function()
hl('Not', '!'),
})
- check_parsing('!!1', 0, {
+ check_parsing('!!1', {
-- 012
ast = {
{
@@ -7346,7 +7398,7 @@ describe('api', function()
hl('Number', '1'),
})
- check_parsing('!1', 0, {
+ check_parsing('!1', {
-- 01
ast = {
{
@@ -7361,7 +7413,7 @@ describe('api', function()
hl('Number', '1'),
})
- check_parsing('(!1)', 0, {
+ check_parsing('(!1)', {
-- 0123
ast = {
{
@@ -7383,7 +7435,7 @@ describe('api', function()
hl('NestingParenthesis', ')'),
})
- check_parsing('(!)', 0, {
+ check_parsing('(!)', {
-- 012
ast = {
{
@@ -7408,7 +7460,7 @@ describe('api', function()
hl('InvalidNestingParenthesis', ')'),
})
- check_parsing('(1!2)', 0, {
+ check_parsing('(1!2)', {
-- 01234
ast = {
{
@@ -7441,7 +7493,7 @@ describe('api', function()
hl('NestingParenthesis', ')'),
})
- check_parsing('1!2', 0, {
+ check_parsing('1!2', {
-- 012
ast = {
{
@@ -7465,10 +7517,23 @@ describe('api', function()
hl('Number', '1'),
hl('InvalidNot', '!'),
hl('Number', '2'),
+ }, {
+ [1] = {
+ ast = {
+ err = REMOVE_THIS,
+ ast = {
+ 'Integer(val=1):0:0:1',
+ },
+ },
+ hl_fs = {
+ [2] = REMOVE_THIS,
+ [3] = REMOVE_THIS,
+ },
+ },
})
end)
it('highlights numbers with prefix', function()
- check_parsing('0xABCDEF', 0, {
+ check_parsing('0xABCDEF', {
-- 01234567
ast = {
'Integer(val=11259375):0:0:0xABCDEF',
@@ -7478,7 +7543,7 @@ describe('api', function()
hl('Number', 'ABCDEF'),
})
- check_parsing('0Xabcdef', 0, {
+ check_parsing('0Xabcdef', {
-- 01234567
ast = {
'Integer(val=11259375):0:0:0Xabcdef',
@@ -7488,7 +7553,7 @@ describe('api', function()
hl('Number', 'abcdef'),
})
- check_parsing('0XABCDEF', 0, {
+ check_parsing('0XABCDEF', {
-- 01234567
ast = {
'Integer(val=11259375):0:0:0XABCDEF',
@@ -7498,7 +7563,7 @@ describe('api', function()
hl('Number', 'ABCDEF'),
})
- check_parsing('0xabcdef', 0, {
+ check_parsing('0xabcdef', {
-- 01234567
ast = {
'Integer(val=11259375):0:0:0xabcdef',
@@ -7508,7 +7573,7 @@ describe('api', function()
hl('Number', 'abcdef'),
})
- check_parsing('0b001', 0, {
+ check_parsing('0b001', {
-- 01234
ast = {
'Integer(val=1):0:0:0b001',
@@ -7518,7 +7583,7 @@ describe('api', function()
hl('Number', '001'),
})
- check_parsing('0B001', 0, {
+ check_parsing('0B001', {
-- 01234
ast = {
'Integer(val=1):0:0:0B001',
@@ -7528,7 +7593,7 @@ describe('api', function()
hl('Number', '001'),
})
- check_parsing('0B00', 0, {
+ check_parsing('0B00', {
-- 0123
ast = {
'Integer(val=0):0:0:0B00',
@@ -7538,7 +7603,7 @@ describe('api', function()
hl('Number', '00'),
})
- check_parsing('00', 0, {
+ check_parsing('00', {
-- 01
ast = {
'Integer(val=0):0:0:00',
@@ -7548,7 +7613,7 @@ describe('api', function()
hl('Number', '0'),
})
- check_parsing('001', 0, {
+ check_parsing('001', {
-- 012
ast = {
'Integer(val=1):0:0:001',
@@ -7558,7 +7623,7 @@ describe('api', function()
hl('Number', '01'),
})
- check_parsing('01', 0, {
+ check_parsing('01', {
-- 01
ast = {
'Integer(val=1):0:0:01',
@@ -7568,7 +7633,7 @@ describe('api', function()
hl('Number', '1'),
})
- check_parsing('1', 0, {
+ check_parsing('1', {
-- 0
ast = {
'Integer(val=1):0:0:1',
@@ -7577,10 +7642,302 @@ describe('api', function()
hl('Number', '1'),
})
end)
- -- FIXME
- -- FIXME Test error
- -- FIXME Test with highlight = false
- -- FIXME Check flag effects
+ it('errors out on unknown flags', function()
+ eq({false, 'Invalid flag: \'F\' (70)'},
+ meth_pcall(meths.parse_expression, '', 'F', true))
+ eq({false, 'Invalid flag: \'\\0\' (0)'},
+ meth_pcall(meths.parse_expression, '', '\0', true))
+ eq({false, 'Invalid flag: \'\1\' (1)'},
+ meth_pcall(meths.parse_expression, '', 'm\1E', true))
+ end)
+ it('respects highlight argument', function()
+ eq({
+ ast = {
+ ivalue = 1,
+ len = 1,
+ start = {0, 0},
+ type = 'Integer'
+ },
+ }, meths.parse_expression('1', '', false))
+ eq({
+ ast = {
+ ivalue = 1,
+ len = 1,
+ start = {0, 0},
+ type = 'Integer'
+ },
+ highlight = {
+ {0, 0, 1, 'NVimNumber'}
+ },
+ }, meths.parse_expression('1', '', true))
+ end)
+ it('works (KLEE tests)', function()
+ check_parsing('\0002&A:\000', {
+ ast = {},
+ err = {
+ arg = '\0002&A:\0',
+ msg = 'E15: Expected value, got EOC: %.*s',
+ },
+ }, {
+ }, {
+ [2] = {
+ ast = {
+ ast = {
+ {
+ 'Colon:0:4::',
+ children = {
+ {
+ 'OpMissing:0:2:',
+ children = {
+ 'Integer(val=2):0:1:2',
+ 'Option(scope=0,ident=A):0:2:&A',
+ },
+ },
+ },
+ },
+ },
+ err = {
+ msg = 'E15: Unexpected EOC character: %.*s',
+ },
+ },
+ hl_fs = {
+ hl('InvalidSpacing', '\0'),
+ hl('Number', '2'),
+ hl('InvalidOptionSigil', '&'),
+ hl('InvalidOptionName', 'A'),
+ hl('InvalidColon', ':'),
+ hl('InvalidSpacing', '\0'),
+ },
+ },
+ [3] = {
+ ast = {
+ ast = {
+ 'Integer(val=2):0:1:2',
+ },
+ err = {
+ msg = 'E15: Unexpected EOC character: %.*s',
+ },
+ },
+ hl_fs = {
+ hl('InvalidSpacing', '\0'),
+ hl('Number', '2'),
+ },
+ },
+ })
+ check_parsing('"\\U\\', {
+ -- 0123
+ ast = {
+ [[DoubleQuotedString(val="U\\"):0:0:"\U\]],
+ },
+ err = {
+ arg = '"\\U\\',
+ msg = 'E114: Missing double quote: %.*s',
+ },
+ }, {
+ hl('InvalidDoubleQuote', '"'),
+ hl('InvalidDoubleQuotedUnknownEscape', '\\U'),
+ hl('InvalidDoubleQuotedBody', '\\'),
+ })
+ check_parsing('"\\U', {
+ -- 012
+ ast = {
+ 'DoubleQuotedString(val="U"):0:0:"\\U',
+ },
+ err = {
+ arg = '"\\U',
+ msg = 'E114: Missing double quote: %.*s',
+ },
+ }, {
+ hl('InvalidDoubleQuote', '"'),
+ hl('InvalidDoubleQuotedUnknownEscape', '\\U'),
+ })
+ check_parsing('|"\\U\\', {
+ -- 01234
+ ast = {},
+ err = {
+ arg = '|"\\U\\',
+ msg = 'E15: Expected value, got EOC: %.*s',
+ },
+ }, {
+ }, {
+ [2] = {
+ ast = {
+ ast = {
+ {
+ 'Or:0:0:|',
+ children = {
+ 'Missing:0:0:',
+ 'DoubleQuotedString(val="U\\\\"):0:1:"\\U\\',
+ },
+ },
+ },
+ err = {
+ msg = 'E15: Unexpected EOC character: %.*s',
+ },
+ },
+ hl_fs = {
+ hl('InvalidOr', '|'),
+ hl('InvalidDoubleQuote', '"'),
+ hl('InvalidDoubleQuotedUnknownEscape', '\\U'),
+ hl('InvalidDoubleQuotedBody', '\\'),
+ },
+ },
+ })
+ check_parsing('|"\\e"', {
+ -- 01234
+ ast = {},
+ err = {
+ arg = '|"\\e"',
+ msg = 'E15: Expected value, got EOC: %.*s',
+ },
+ }, {
+ }, {
+ [2] = {
+ ast = {
+ ast = {
+ {
+ 'Or:0:0:|',
+ children = {
+ 'Missing:0:0:',
+ 'DoubleQuotedString(val="\\27"):0:1:"\\e"',
+ },
+ },
+ },
+ err = {
+ msg = 'E15: Unexpected EOC character: %.*s',
+ },
+ },
+ hl_fs = {
+ hl('InvalidOr', '|'),
+ hl('DoubleQuote', '"'),
+ hl('DoubleQuotedEscape', '\\e'),
+ hl('DoubleQuote', '"'),
+ },
+ },
+ })
+ check_parsing('|\029', {
+ -- 01
+ ast = {},
+ err = {
+ arg = '|\029',
+ msg = 'E15: Expected value, got EOC: %.*s',
+ },
+ }, {
+ }, {
+ [2] = {
+ ast = {
+ ast = {
+ {
+ 'Or:0:0:|',
+ children = {
+ 'Missing:0:0:',
+ 'PlainIdentifier(scope=0,ident=\029):0:1:\029',
+ },
+ },
+ },
+ err = {
+ msg = 'E15: Unexpected EOC character: %.*s',
+ },
+ },
+ hl_fs = {
+ hl('InvalidOr', '|'),
+ hl('InvalidIdentifierName', '\029'),
+ },
+ },
+ })
+ check_parsing('"\\<', {
+ -- 012
+ ast = {
+ 'DoubleQuotedString(val="<"):0:0:"\\<',
+ },
+ err = {
+ arg = '"\\<',
+ msg = 'E114: Missing double quote: %.*s',
+ },
+ }, {
+ hl('InvalidDoubleQuote', '"'),
+ hl('InvalidDoubleQuotedUnknownEscape', '\\<'),
+ })
+ check_parsing('"\\1', {
+ -- 012
+ ast = {
+ 'DoubleQuotedString(val="\\1"):0:0:"\\1',
+ },
+ err = {
+ arg = '"\\1',
+ msg = 'E114: Missing double quote: %.*s',
+ },
+ }, {
+ hl('InvalidDoubleQuote', '"'),
+ hl('InvalidDoubleQuotedEscape', '\\1'),
+ })
+ check_parsing('}l', {
+ -- 01
+ ast = {
+ {
+ 'OpMissing:0:1:',
+ children = {
+ 'UnknownFigure:0:0:',
+ 'PlainIdentifier(scope=0,ident=l):0:1:l',
+ },
+ },
+ },
+ err = {
+ arg = '}l',
+ msg = 'E15: Unexpected closing figure brace: %.*s',
+ },
+ }, {
+ hl('InvalidFigureBrace', '}'),
+ hl('InvalidIdentifierName', 'l'),
+ }, {
+ [1] = {
+ ast = {
+ ast = {
+ 'UnknownFigure:0:0:',
+ },
+ },
+ hl_fs = {
+ [2] = REMOVE_THIS,
+ },
+ },
+ })
+ check_parsing(':?\000\000\000\000\000\000\000', {
+ ast = {
+ {
+ 'Colon:0:0::',
+ children = {
+ 'Missing:0:0:',
+ {
+ 'Ternary:0:1:?',
+ children = {
+ 'Missing:0:1:',
+ 'TernaryValue:0:1:?',
+ },
+ },
+ },
+ },
+ },
+ err = {
+ arg = ':?\000\000\000\000\000\000\000',
+ msg = 'E15: Colon outside of dictionary or ternary operator: %.*s',
+ },
+ }, {
+ hl('InvalidColon', ':'),
+ hl('InvalidTernary', '?'),
+ }, {
+ [2] = {
+ hl_fs = {
+ [3] = hl('InvalidSpacing', '\0'),
+ [4] = hl('InvalidSpacing', '\0'),
+ [5] = hl('InvalidSpacing', '\0'),
+ [6] = hl('InvalidSpacing', '\0'),
+ [7] = hl('InvalidSpacing', '\0'),
+ [8] = hl('InvalidSpacing', '\0'),
+ [9] = hl('InvalidSpacing', '\0'),
+ },
+ },
+ })
+ end)
end)
end)