aboutsummaryrefslogtreecommitdiff
path: root/test/functional/treesitter/parser_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/treesitter/parser_spec.lua')
-rw-r--r--test/functional/treesitter/parser_spec.lua34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/functional/treesitter/parser_spec.lua b/test/functional/treesitter/parser_spec.lua
index fdd6403859..67aad4d1b7 100644
--- a/test/functional/treesitter/parser_spec.lua
+++ b/test/functional/treesitter/parser_spec.lua
@@ -871,4 +871,38 @@ int x = INT_MAX;
end)
end)
end)
+
+ it("can fold via foldexpr", function()
+ insert(test_text)
+ exec_lua([[vim.treesitter.get_parser(0, "c")]])
+
+ local levels = exec_lua([[
+ local res = {}
+ for i = 1, vim.api.nvim_buf_line_count(0) do
+ res[i] = vim.treesitter.foldexpr(i)
+ end
+ return res
+ ]])
+
+ eq({
+ [1] = '>1',
+ [2] = '1',
+ [3] = '1',
+ [4] = '1',
+ [5] = '>2',
+ [6] = '2',
+ [7] = '2',
+ [8] = '1',
+ [9] = '1',
+ [10] = '>2',
+ [11] = '2',
+ [12] = '2',
+ [13] = '2',
+ [14] = '2',
+ [15] = '>3',
+ [16] = '3',
+ [17] = '3',
+ [18] = '2',
+ [19] = '1' }, levels)
+ end)
end)