aboutsummaryrefslogtreecommitdiffstats
path: root/tests/indent
diff options
context:
space:
mode:
Diffstat (limited to 'tests/indent')
-rw-r--r--tests/indent/c_spec.lua14
-rw-r--r--tests/indent/cpp_spec.lua19
-rw-r--r--tests/indent/lua_spec.lua14
-rw-r--r--tests/indent/python_spec.lua14
-rw-r--r--tests/indent/rust_spec.lua14
5 files changed, 38 insertions, 37 deletions
diff --git a/tests/indent/c_spec.lua b/tests/indent/c_spec.lua
index 98311c772..1089ee4eb 100644
--- a/tests/indent/c_spec.lua
+++ b/tests/indent/c_spec.lua
@@ -9,6 +9,13 @@ local opts = {
expandtab = true,
}
+local run = function(file, spec, title)
+ title = title and title or tostring(spec.on_line)
+ it(string.format('%s[%s]', file, title), function()
+ new_line('tests/indent/c/' .. file, spec, opts)
+ end)
+end
+
describe('indent C:', function()
describe('whole file:', function()
local files = scan_dir('tests/indent/c');
@@ -20,13 +27,6 @@ describe('indent C:', function()
end)
describe('new line:', function()
- local run = function(file, spec, title)
- title = title and title or tostring(spec.on_line)
- it(string.format('%s[%s]', file, title), function()
- new_line('tests/indent/c/' .. file, spec, opts)
- end)
- end
-
run('array.c', { on_line = 2, text = '0,', indent = 4 })
run('cond.c', { on_line = 3, text = 'x++;', indent = 8 })
run('cond.c', { on_line = 8, text = 'x++;', indent = 8 })
diff --git a/tests/indent/cpp_spec.lua b/tests/indent/cpp_spec.lua
index d3c98401c..261c00499 100644
--- a/tests/indent/cpp_spec.lua
+++ b/tests/indent/cpp_spec.lua
@@ -15,10 +15,18 @@ local get_name = function(file)
return Path:new(file):make_relative('tests/indent')
end
+local run = function(file, spec, title)
+ title = title and title or tostring(spec.on_line)
+ it(string.format('%s[%s]', get_name(file), title), function()
+ new_line(file, spec, opts)
+ end)
+end
+
describe('indent C++:', function()
describe('whole file:', function()
- local files = scan_dir('tests/indent/c');
- vim.list_extend(files, scan_dir('tests/indent/cpp'))
+ local files = vim.tbl_flatten(vim.tbl_map(scan_dir, {
+ 'tests/indent/c', 'tests/indent/cpp',
+ }))
for _, file in ipairs(files) do
it(get_name(file), function()
@@ -28,13 +36,6 @@ describe('indent C++:', function()
end)
describe('new line:', function()
- local run = function(file, spec, title)
- title = title and title or tostring(spec.on_line)
- it(string.format('%s[%s]', get_name(file), title), function()
- new_line(file, spec, opts)
- end)
- end
-
run('tests/indent/cpp/access.cpp', { on_line = 3, text = 'protected:', indent = 0 })
run('tests/indent/cpp/class.cpp', { on_line = 2, text = 'using T = int;', indent = 4 })
run('tests/indent/cpp/stream.cpp', { on_line = 5, text = '<< x + 3', indent = 8 })
diff --git a/tests/indent/lua_spec.lua b/tests/indent/lua_spec.lua
index 473f584c4..0a6a3b29a 100644
--- a/tests/indent/lua_spec.lua
+++ b/tests/indent/lua_spec.lua
@@ -9,6 +9,13 @@ local opts = {
expandtab = true,
}
+local run = function(file, spec, title)
+ title = title and title or tostring(spec.on_line)
+ it(string.format('%s[%s]', file, title), function()
+ new_line('tests/indent/lua/' .. file, spec, opts)
+ end)
+end
+
describe('indent Lua:', function()
describe('whole file:', function()
local files = scan_dir('tests/indent/lua');
@@ -20,13 +27,6 @@ describe('indent Lua:', function()
end)
describe('new line:', function()
- local run = function(file, spec, title)
- title = title and title or tostring(spec.on_line)
- it(string.format('%s[%s]', file, title), function()
- new_line('tests/indent/lua/' .. file, spec, opts)
- end)
- end
-
run('comment.lua', { on_line = 1, text = 'line', indent = '-- ' })
run('comment.lua', { on_line = 5, text = 'multiline', indent = ' ' })
run('func.lua', { on_line = 1, text = 'x = x + 1', indent = 2 })
diff --git a/tests/indent/python_spec.lua b/tests/indent/python_spec.lua
index 7a058af55..85c3bc3bf 100644
--- a/tests/indent/python_spec.lua
+++ b/tests/indent/python_spec.lua
@@ -9,6 +9,13 @@ local opts = {
expandtab = true,
}
+local run = function(file, spec, title)
+ title = title and title or tostring(spec.on_line)
+ it(string.format('%s[%s]', file, title), function()
+ new_line('tests/indent/python/' .. file, spec, opts)
+ end)
+end
+
describe('indent Python:', function()
describe('whole file:', function()
local files = scan_dir('tests/indent/python');
@@ -20,13 +27,6 @@ describe('indent Python:', function()
end)
describe('new line:', function()
- local run = function(file, spec, title)
- title = title and title or tostring(spec.on_line)
- it(string.format('%s[%s]', file, title), function()
- new_line('tests/indent/python/' .. file, spec, opts)
- end)
- end
-
run('aligned_indent.py', { on_line = 1, text = 'arg3,', indent = 19 })
run('basic_blocks.py', { on_line = 1, text = 'wait,', indent = 4 })
run('basic_blocks.py', { on_line = 6, text = 'x += 1', indent = 4 })
diff --git a/tests/indent/rust_spec.lua b/tests/indent/rust_spec.lua
index c3ffe3fdf..6009c7fb8 100644
--- a/tests/indent/rust_spec.lua
+++ b/tests/indent/rust_spec.lua
@@ -9,6 +9,13 @@ local opts = {
expandtab = true,
}
+local run = function(file, spec, title)
+ title = title and title or tostring(spec.on_line)
+ it(string.format('%s[%s]', file, title), function()
+ new_line('tests/indent/rust/' .. file, spec, opts)
+ end)
+end
+
describe('indent Rust:', function()
describe('whole file:', function()
local files = scan_dir('tests/indent/rust');
@@ -20,13 +27,6 @@ describe('indent Rust:', function()
end)
describe('new line:', function()
- local run = function(file, spec, title)
- title = title and title or tostring(spec.on_line)
- it(string.format('%s[%s]', file, title), function()
- new_line('tests/indent/rust/' .. file, spec, opts)
- end)
- end
-
run('array.rs', { on_line = 2, text = '0,', indent = 4 })
run('array.rs', { on_line = 8, text = '0,', indent = 8 })
run('comment.rs', { on_line = 3, text = 'a', indent = '/// ' })