aboutsummaryrefslogtreecommitdiff
path: root/test/functional/treesitter/query_spec.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-11-25 19:15:05 +0000
committerJosh Rahm <joshuarahm@gmail.com>2024-11-25 19:27:38 +0000
commitc5d770d311841ea5230426cc4c868e8db27300a8 (patch)
treedd21f70127b4b8b5f109baefc8ecc5016f507c91 /test/functional/treesitter/query_spec.lua
parent9be89f131f87608f224f0ee06d199fcd09d32176 (diff)
parent081beb3659bd6d8efc3e977a160b1e72becbd8a2 (diff)
downloadrneovim-c5d770d311841ea5230426cc4c868e8db27300a8.tar.gz
rneovim-c5d770d311841ea5230426cc4c868e8db27300a8.tar.bz2
rneovim-c5d770d311841ea5230426cc4c868e8db27300a8.zip
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'test/functional/treesitter/query_spec.lua')
-rw-r--r--test/functional/treesitter/query_spec.lua34
1 files changed, 33 insertions, 1 deletions
diff --git a/test/functional/treesitter/query_spec.lua b/test/functional/treesitter/query_spec.lua
index c97619c913..634f8af83d 100644
--- a/test/functional/treesitter/query_spec.lua
+++ b/test/functional/treesitter/query_spec.lua
@@ -405,6 +405,20 @@ void ui_refresh(void)
{ 'literal', 'number_literal', { 0, 8, 0, 11 }, '123' },
{ 'literal', 'number_literal', { 2, 21, 2, 24 }, '125' },
}, result)
+
+ result = exec_lua(
+ get_query_result,
+ [[((number_literal) @literal (#has-ancestor? @literal "enumerator"))]]
+ )
+ eq({
+ { 'literal', 'number_literal', { 1, 13, 1, 16 }, '124' },
+ }, result)
+
+ result = exec_lua(
+ get_query_result,
+ [[((number_literal) @literal (#has-ancestor? @literal "number_literal"))]]
+ )
+ eq({}, result)
end)
it('allows loading query with escaped quotes and capture them `#{lua,vim}-match`?', function()
@@ -708,7 +722,25 @@ void ui_refresh(void)
eq(exp, pcall_err(exec_lua, "vim.treesitter.query.parse('c', ...)", cquery))
end
- -- Invalid node type
+ -- Invalid node types
+ test(
+ '.../query.lua:0: Query error at 1:2. Invalid node type ">\\">>":\n'
+ .. '">\\">>" @operator\n'
+ .. ' ^',
+ '">\\">>" @operator'
+ )
+ test(
+ '.../query.lua:0: Query error at 1:2. Invalid node type "\\\\":\n'
+ .. '"\\\\" @operator\n'
+ .. ' ^',
+ '"\\\\" @operator'
+ )
+ test(
+ '.../query.lua:0: Query error at 1:2. Invalid node type ">>>":\n'
+ .. '">>>" @operator\n'
+ .. ' ^',
+ '">>>" @operator'
+ )
test(
'.../query.lua:0: Query error at 1:2. Invalid node type "dentifier":\n'
.. '(dentifier) @variable\n'