Use stylua for autoformat code (#1480)

This commit is contained in:
Santos Gallegos 2021-07-04 16:12:17 -05:00 committed by GitHub
parent 90f15d9bf7
commit be8f656087
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 1181 additions and 979 deletions

View file

@ -1,35 +1,35 @@
local Runner = require('tests.indent.common').Runner
local Runner = require("tests.indent.common").Runner
local runner = Runner:new(it, 'tests/indent/c', {
local runner = Runner:new(it, "tests/indent/c", {
tabstop = 4,
shiftwidth = 4,
softtabstop = 0,
expandtab = true,
})
describe('indent C:', function()
describe('whole file:', function()
runner:whole_file('.')
describe("indent C:", function()
describe("whole file:", function()
runner:whole_file "."
end)
describe('new line:', function()
runner:new_line('array.c', { on_line = 2, text = '0,', indent = 4 })
runner:new_line('cond.c', { on_line = 3, text = 'x++;', indent = 8 })
runner:new_line('cond.c', { on_line = 8, text = 'x++;', indent = 8 })
runner:new_line('expr.c', { on_line = 10, text = '2 *', indent = 8 })
runner:new_line('func.c', { on_line = 17, text = 'int z,', indent = 4 })
runner:new_line('label.c', { on_line = 3, text = 'normal:', indent = 0 })
runner:new_line('loop.c', { on_line = 3, text = 'x++;', indent = 8 })
runner:new_line('preproc_cond.c', { on_line = 5, text = 'x++;', indent = 4 })
runner:new_line('preproc_func.c', { on_line = 3, text = 'x++; \\', indent = 8 })
runner:new_line('string.c', { on_line = 1, text = 'brave new \\', indent = 0 })
runner:new_line('string.c', { on_line = 4, text = '"brave new "', indent = 4 })
runner:new_line('struct.c', { on_line = 4, text = 'int y;', indent = 8 })
runner:new_line('switch.c', { on_line = 3, text = 'x++;', indent = 12 })
runner:new_line('ternary.c', { on_line = 4, text = ': (x == 0) : 0', indent = 8 })
describe("new line:", function()
runner:new_line("array.c", { on_line = 2, text = "0,", indent = 4 })
runner:new_line("cond.c", { on_line = 3, text = "x++;", indent = 8 })
runner:new_line("cond.c", { on_line = 8, text = "x++;", indent = 8 })
runner:new_line("expr.c", { on_line = 10, text = "2 *", indent = 8 })
runner:new_line("func.c", { on_line = 17, text = "int z,", indent = 4 })
runner:new_line("label.c", { on_line = 3, text = "normal:", indent = 0 })
runner:new_line("loop.c", { on_line = 3, text = "x++;", indent = 8 })
runner:new_line("preproc_cond.c", { on_line = 5, text = "x++;", indent = 4 })
runner:new_line("preproc_func.c", { on_line = 3, text = "x++; \\", indent = 8 })
runner:new_line("string.c", { on_line = 1, text = "brave new \\", indent = 0 })
runner:new_line("string.c", { on_line = 4, text = '"brave new "', indent = 4 })
runner:new_line("struct.c", { on_line = 4, text = "int y;", indent = 8 })
runner:new_line("switch.c", { on_line = 3, text = "x++;", indent = 12 })
runner:new_line("ternary.c", { on_line = 4, text = ": (x == 0) : 0", indent = 8 })
-- the line after inserted one will be left with wrong indent but we only care about the inserted one
runner:new_line('no_braces.c', { on_line = 4, text = 'x++;', indent = 8 })
runner:new_line('no_braces.c', { on_line = 7, text = 'x++;', indent = 8 })
runner:new_line('no_braces.c', { on_line = 10, text = 'x++;', indent = 8 })
runner:new_line("no_braces.c", { on_line = 4, text = "x++;", indent = 8 })
runner:new_line("no_braces.c", { on_line = 7, text = "x++;", indent = 8 })
runner:new_line("no_braces.c", { on_line = 10, text = "x++;", indent = 8 })
end)
end)

View file

@ -1,9 +1,9 @@
local M = {}
local assert = require('luassert')
local say = require('say')
local scan_dir = require('plenary.scandir').scan_dir
local Path = require('plenary.path')
local assert = require "luassert"
local say = require "say"
local scan_dir = require("plenary.scandir").scan_dir
local Path = require "plenary.path"
local function same_indent(state, arguments)
local before = arguments[1]
@ -11,11 +11,11 @@ local function same_indent(state, arguments)
local ok = true
local errors = { before = {}, after = {} }
for line = 1,#before do
for line = 1, #before do
if before[line] ~= after[line] then
-- store the actual indentation length for each line
errors.before[line] = #string.match(before[line], '^%s*')
errors.after[line] = #string.match(after[line], '^%s*')
errors.before[line] = #string.match(before[line], "^%s*")
errors.after[line] = #string.match(after[line], "^%s*")
ok = false
end
end
@ -35,28 +35,33 @@ local function format_indent(arg, fmtargs)
end
width = width + 3
local header_fmt = '%8s %2s%-' .. tostring(width + 1) .. 's %s'
local fmt = '%8s %2s |%-' .. tostring(width) .. 's |%s'
local header_fmt = "%8s %2s%-" .. tostring(width + 1) .. "s %s"
local fmt = "%8s %2s |%-" .. tostring(width) .. "s |%s"
local output = {header_fmt:format('', '', 'Found:', 'Expected:')}
local output = { header_fmt:format("", "", "Found:", "Expected:") }
for i, line in ipairs(arg) do
if fmtargs.errors.before[i] then
local indents = string.format('%d vs %d', fmtargs.errors.after[i], fmtargs.errors.before[i])
table.insert(output, fmt:format(indents, '=>', fmtargs.other[i], line))
local indents = string.format("%d vs %d", fmtargs.errors.after[i], fmtargs.errors.before[i])
table.insert(output, fmt:format(indents, "=>", fmtargs.other[i], line))
else
table.insert(output, fmt:format('', '', fmtargs.other[i], line))
table.insert(output, fmt:format("", "", fmtargs.other[i], line))
end
end
return table.concat(output, '\n')
return table.concat(output, "\n")
end
say:set_namespace('en')
say:set('assertion.same_indent.positive', 'Incorrect indentation\n%s')
say:set('assertion.same_indent.negative', 'Incorrect indentation\n%s')
assert:register('assertion', 'same_indent', same_indent,
'assertion.same_indent.positive', 'assert.same_indent.negative')
say:set_namespace "en"
say:set("assertion.same_indent.positive", "Incorrect indentation\n%s")
say:set("assertion.same_indent.negative", "Incorrect indentation\n%s")
assert:register(
"assertion",
"same_indent",
same_indent,
"assertion.same_indent.positive",
"assert.same_indent.negative"
)
-- Custom assertion better suited for indentation diffs
local function compare_indent(before, after)
@ -66,7 +71,7 @@ local function compare_indent(before, after)
end
local function set_buf_indent_opts(opts)
local optnames = {'tabstop', 'shiftwidth', 'softtabstop', 'expandtab', 'filetype'}
local optnames = { "tabstop", "shiftwidth", "softtabstop", "expandtab", "filetype" }
for _, opt in ipairs(optnames) do
if opts[opt] ~= nil then
vim.bo[opt] = opts[opt]
@ -78,10 +83,10 @@ function M.run_indent_test(file, runner, opts)
assert.are.same(1, vim.fn.filereadable(file), string.format('File "%s" not readable', file))
-- load reference file
vim.cmd(string.format('edit %s', file))
vim.cmd(string.format("edit %s", file))
local before = vim.api.nvim_buf_get_lines(0, 0, -1, true)
assert.are.same('nvim_treesitter#indent()', vim.bo.indentexpr)
assert.are.same("nvim_treesitter#indent()", vim.bo.indentexpr)
set_buf_indent_opts(opts)
-- perform the test
@ -91,14 +96,14 @@ function M.run_indent_test(file, runner, opts)
local after = vim.api.nvim_buf_get_lines(0, 0, -1, true)
-- clear any changes to avoid 'No write since last change (add ! to override)'
vim.cmd 'edit!'
vim.cmd "edit!"
return before, after
end
function M.indent_whole_file(file, opts)
local before, after = M.run_indent_test(file, function()
vim.cmd 'silent normal gg=G'
vim.cmd "silent normal gg=G"
end, opts)
compare_indent(before, after)
@ -114,11 +119,11 @@ end
function M.indent_new_line(file, spec, opts)
local before, after = M.run_indent_test(file, function()
-- move to the line and input the new one
vim.cmd(string.format('normal! %dG', spec.on_line))
vim.cmd(string.format('normal! o%s', spec.text))
vim.cmd(string.format("normal! %dG", spec.on_line))
vim.cmd(string.format("normal! o%s", spec.text))
end, opts)
local indent = type(spec.indent) == 'string' and spec.indent or string.rep(' ', spec.indent)
local indent = type(spec.indent) == "string" and spec.indent or string.rep(" ", spec.indent)
table.insert(before, spec.on_line + 1, indent .. spec.text)
compare_indent(before, after)
@ -140,7 +145,7 @@ function Runner:new(it, base_dir, buf_opts)
end
function Runner:whole_file(dirs)
dirs = type(dirs) == "table" and dirs or {dirs}
dirs = type(dirs) == "table" and dirs or { dirs }
dirs = vim.tbl_map(function(dir)
dir = self.base_dir / Path:new(dir)
assert.is.same(1, vim.fn.isdirectory(dir.filename))
@ -157,7 +162,7 @@ end
function Runner:new_line(file, spec, title)
title = title and title or tostring(spec.on_line)
self.it(string.format('%s[%s]', file, title), function()
self.it(string.format("%s[%s]", file, title), function()
local path = self.base_dir / file
M.indent_new_line(path.filename, spec, self.buf_opts)
end)

View file

@ -1,42 +1,42 @@
local Runner = require('tests.indent.common').Runner
local Runner = require("tests.indent.common").Runner
-- will use both c/ and cpp/
local run = Runner:new(it, 'tests/indent', {
local run = Runner:new(it, "tests/indent", {
tabstop = 4,
shiftwidth = 4,
softtabstop = 0,
expandtab = true,
filetype = 'cpp',
filetype = "cpp",
})
describe('indent C++:', function()
describe('whole file:', function()
run:whole_file({'c/', 'cpp/'})
describe("indent C++:", function()
describe("whole file:", function()
run:whole_file { "c/", "cpp/" }
end)
describe('new line:', function()
run:new_line('cpp/access.cpp', { on_line = 3, text = 'protected:', indent = 0 })
run:new_line('cpp/class.cpp', { on_line = 2, text = 'using T = int;', indent = 4 })
run:new_line('cpp/stream.cpp', { on_line = 5, text = '<< x + 3', indent = 8 })
describe("new line:", function()
run:new_line("cpp/access.cpp", { on_line = 3, text = "protected:", indent = 0 })
run:new_line("cpp/class.cpp", { on_line = 2, text = "using T = int;", indent = 4 })
run:new_line("cpp/stream.cpp", { on_line = 5, text = "<< x + 3", indent = 8 })
-- TODO: find a clean way to import these from c_spec.lua
run:new_line('c/array.c', { on_line = 2, text = '0,', indent = 4 })
run:new_line('c/cond.c', { on_line = 3, text = 'x++;', indent = 8 })
run:new_line('c/cond.c', { on_line = 8, text = 'x++;', indent = 8 })
run:new_line('c/expr.c', { on_line = 10, text = '2 *', indent = 8 })
run:new_line('c/func.c', { on_line = 17, text = 'int z,', indent = 4 })
run:new_line('c/label.c', { on_line = 3, text = 'normal:', indent = 0 })
run:new_line('c/loop.c', { on_line = 3, text = 'x++;', indent = 8 })
run:new_line('c/preproc_cond.c', { on_line = 5, text = 'x++;', indent = 4 })
run:new_line('c/preproc_func.c', { on_line = 3, text = 'x++; \\', indent = 8 })
run:new_line('c/string.c', { on_line = 1, text = 'brave new \\', indent = 0 })
run:new_line('c/string.c', { on_line = 4, text = '"brave new "', indent = 4 })
run:new_line('c/struct.c', { on_line = 4, text = 'int y;', indent = 8 })
run:new_line('c/switch.c', { on_line = 3, text = 'x++;', indent = 12 })
run:new_line('c/ternary.c', { on_line = 4, text = ': (x == 0) : 0', indent = 8 })
run:new_line("c/array.c", { on_line = 2, text = "0,", indent = 4 })
run:new_line("c/cond.c", { on_line = 3, text = "x++;", indent = 8 })
run:new_line("c/cond.c", { on_line = 8, text = "x++;", indent = 8 })
run:new_line("c/expr.c", { on_line = 10, text = "2 *", indent = 8 })
run:new_line("c/func.c", { on_line = 17, text = "int z,", indent = 4 })
run:new_line("c/label.c", { on_line = 3, text = "normal:", indent = 0 })
run:new_line("c/loop.c", { on_line = 3, text = "x++;", indent = 8 })
run:new_line("c/preproc_cond.c", { on_line = 5, text = "x++;", indent = 4 })
run:new_line("c/preproc_func.c", { on_line = 3, text = "x++; \\", indent = 8 })
run:new_line("c/string.c", { on_line = 1, text = "brave new \\", indent = 0 })
run:new_line("c/string.c", { on_line = 4, text = '"brave new "', indent = 4 })
run:new_line("c/struct.c", { on_line = 4, text = "int y;", indent = 8 })
run:new_line("c/switch.c", { on_line = 3, text = "x++;", indent = 12 })
run:new_line("c/ternary.c", { on_line = 4, text = ": (x == 0) : 0", indent = 8 })
-- the line after inserted one will be left with wrong indent but we only care about the inserted one
run:new_line('c/no_braces.c', { on_line = 4, text = 'x++;', indent = 8 })
run:new_line('c/no_braces.c', { on_line = 7, text = 'x++;', indent = 8 })
run:new_line('c/no_braces.c', { on_line = 10, text = 'x++;', indent = 8 })
run:new_line("c/no_braces.c", { on_line = 4, text = "x++;", indent = 8 })
run:new_line("c/no_braces.c", { on_line = 7, text = "x++;", indent = 8 })
run:new_line("c/no_braces.c", { on_line = 10, text = "x++;", indent = 8 })
end)
end)

View file

@ -1,35 +1,33 @@
local Runner = require('tests.indent.common').Runner
local Runner = require("tests.indent.common").Runner
local run = Runner:new(it, 'tests/indent/lua', {
local run = Runner:new(it, "tests/indent/lua", {
tabstop = 2,
shiftwidth = 2,
softtabstop = 0,
expandtab = true,
})
describe('indent Lua:', function()
describe('whole file:', function()
run:whole_file('.')
describe("indent Lua:", function()
describe("whole file:", function()
run:whole_file "."
end)
describe('new line:', function()
run:new_line('comment.lua', { on_line = 1, text = 'line', indent = '-- ' })
run:new_line('comment.lua', { on_line = 5, text = 'multiline', indent = ' ' })
run:new_line('func.lua', { on_line = 1, text = 'x = x + 1', indent = 2 })
run:new_line('func.lua', { on_line = 2, text = 'y = y + 1', indent = 4 })
run:new_line('func.lua', { on_line = 5, text = '3,', indent = 4 })
run:new_line('string.lua', { on_line = 1, text = 'x', indent = 0 })
run:new_line('string.lua', { on_line = 2, text = 'x', indent = 0 })
run:new_line('string.lua', { on_line = 3, text = 'x', indent = 2 })
run:new_line('string.lua', { on_line = 4, text = 'x', indent = 4 })
run:new_line('table.lua', { on_line = 1, text = 'b = 0,', indent = 2 })
run:new_line('table.lua', { on_line = 5, text = '4,', indent = 4 })
run:new_line('table.lua', { on_line = 7, text = '4,', indent = 4 })
run:new_line('loop.lua', { on_line = 4, text = 'x = x + 1', indent = 2 })
run:new_line('cond.lua', { on_line = 5, text = 'x = x + 1', indent = 2 })
run:new_line('cond.lua', { on_line = 7, text = 'x = x + 1', indent = 2 })
run:new_line('cond.lua', { on_line = 8, text = 'x = x + 1', indent = 4 })
describe("new line:", function()
run:new_line("comment.lua", { on_line = 1, text = "line", indent = "-- " })
run:new_line("comment.lua", { on_line = 5, text = "multiline", indent = " " })
run:new_line("func.lua", { on_line = 1, text = "x = x + 1", indent = 2 })
run:new_line("func.lua", { on_line = 2, text = "y = y + 1", indent = 4 })
run:new_line("func.lua", { on_line = 5, text = "3,", indent = 4 })
run:new_line("string.lua", { on_line = 1, text = "x", indent = 0 })
run:new_line("string.lua", { on_line = 2, text = "x", indent = 0 })
run:new_line("string.lua", { on_line = 3, text = "x", indent = 2 })
run:new_line("string.lua", { on_line = 4, text = "x", indent = 4 })
run:new_line("table.lua", { on_line = 1, text = "b = 0,", indent = 2 })
run:new_line("table.lua", { on_line = 5, text = "4,", indent = 4 })
run:new_line("table.lua", { on_line = 7, text = "4,", indent = 4 })
run:new_line("loop.lua", { on_line = 4, text = "x = x + 1", indent = 2 })
run:new_line("cond.lua", { on_line = 5, text = "x = x + 1", indent = 2 })
run:new_line("cond.lua", { on_line = 7, text = "x = x + 1", indent = 2 })
run:new_line("cond.lua", { on_line = 8, text = "x = x + 1", indent = 4 })
end)
end)

View file

@ -1,38 +1,38 @@
local Runner = require('tests.indent.common').Runner
local Runner = require("tests.indent.common").Runner
local run = Runner:new(it, 'tests/indent/python', {
local run = Runner:new(it, "tests/indent/python", {
tabstop = 4,
shiftwidth = 4,
softtabstop = 0,
expandtab = true,
})
describe('indent Python:', function()
describe('whole file:', function()
run:whole_file('.')
describe("indent Python:", function()
describe("whole file:", function()
run:whole_file "."
end)
describe('new line:', function()
run:new_line('aligned_indent.py', { on_line = 1, text = 'arg3,', indent = 19 })
run:new_line('basic_blocks.py', { on_line = 1, text = 'wait,', indent = 4 })
run:new_line('basic_blocks.py', { on_line = 6, text = 'x += 1', indent = 4 })
run:new_line('basic_blocks.py', { on_line = 10, text = 'x += 1', indent = 8 })
run:new_line('basic_blocks.py', { on_line = 7, text = 'x += 1', indent = 4 }, '7, after last line of a block')
run:new_line('basic_blocks.py', { on_line = 11, text = 'x += 1', indent = 8 }, '11, after last line of a block')
run:new_line('basic_collections.py', { on_line = 3, text = '4,', indent = 4 })
run:new_line('comprehensions.py', { on_line = 8, text = 'if x != 2', indent = 4 })
run:new_line('control_flow.py', { on_line = 23, text = 'x = 4', indent = 4 })
run:new_line('hanging_indent.py', { on_line = 1, text = 'arg0,', indent = 8 })
run:new_line('hanging_indent.py', { on_line = 5, text = '0,', indent = 4 })
run:new_line('join_lines.py', { on_line = 1, text = '+ 1 \\', indent = 4 })
run:new_line('join_lines.py', { on_line = 4, text = '+ 1 \\', indent = 4 })
run:new_line('join_lines.py', { on_line = 7, text = '+ 1 \\', indent = 4 })
run:new_line('nested_collections.py', { on_line = 5, text = '0,', indent = 12 })
run:new_line('nested_collections.py', { on_line = 6, text = ',0', indent = 12 })
run:new_line('nested_collections.py', { on_line = 29, text = '[1, 2],', indent = 12 })
run:new_line('nested_collections.py', { on_line = 39, text = '0,', indent = 5 })
run:new_line('strings.py', { on_line = 14, text = 'x', indent = 4 })
run:new_line('strings.py', { on_line = 15, text = 'x', indent = 0 })
run:new_line('strings.py', { on_line = 16, text = 'x', indent = 8 })
describe("new line:", function()
run:new_line("aligned_indent.py", { on_line = 1, text = "arg3,", indent = 19 })
run:new_line("basic_blocks.py", { on_line = 1, text = "wait,", indent = 4 })
run:new_line("basic_blocks.py", { on_line = 6, text = "x += 1", indent = 4 })
run:new_line("basic_blocks.py", { on_line = 10, text = "x += 1", indent = 8 })
run:new_line("basic_blocks.py", { on_line = 7, text = "x += 1", indent = 4 }, "7, after last line of a block")
run:new_line("basic_blocks.py", { on_line = 11, text = "x += 1", indent = 8 }, "11, after last line of a block")
run:new_line("basic_collections.py", { on_line = 3, text = "4,", indent = 4 })
run:new_line("comprehensions.py", { on_line = 8, text = "if x != 2", indent = 4 })
run:new_line("control_flow.py", { on_line = 23, text = "x = 4", indent = 4 })
run:new_line("hanging_indent.py", { on_line = 1, text = "arg0,", indent = 8 })
run:new_line("hanging_indent.py", { on_line = 5, text = "0,", indent = 4 })
run:new_line("join_lines.py", { on_line = 1, text = "+ 1 \\", indent = 4 })
run:new_line("join_lines.py", { on_line = 4, text = "+ 1 \\", indent = 4 })
run:new_line("join_lines.py", { on_line = 7, text = "+ 1 \\", indent = 4 })
run:new_line("nested_collections.py", { on_line = 5, text = "0,", indent = 12 })
run:new_line("nested_collections.py", { on_line = 6, text = ",0", indent = 12 })
run:new_line("nested_collections.py", { on_line = 29, text = "[1, 2],", indent = 12 })
run:new_line("nested_collections.py", { on_line = 39, text = "0,", indent = 5 })
run:new_line("strings.py", { on_line = 14, text = "x", indent = 4 })
run:new_line("strings.py", { on_line = 15, text = "x", indent = 0 })
run:new_line("strings.py", { on_line = 16, text = "x", indent = 8 })
end)
end)

View file

@ -1,53 +1,53 @@
local Runner = require('tests.indent.common').Runner
local Runner = require("tests.indent.common").Runner
local run = Runner:new(it, 'tests/indent/rust', {
local run = Runner:new(it, "tests/indent/rust", {
tabstop = 4,
shiftwidth = 4,
softtabstop = 0,
expandtab = true,
})
describe('indent Rust:', function()
describe('whole file:', function()
run:whole_file('.')
describe("indent Rust:", function()
describe("whole file:", function()
run:whole_file "."
end)
describe('new line:', function()
run:new_line('array.rs', { on_line = 2, text = '0,', indent = 4 })
run:new_line('array.rs', { on_line = 8, text = '0,', indent = 8 })
run:new_line('comment.rs', { on_line = 3, text = 'a', indent = '/// ' })
run:new_line('cond.rs', { on_line = 11, text = 'x += 1;', indent = 12 })
run:new_line('cond.rs', { on_line = 2, text = 'x += 1;', indent = 8 })
run:new_line('cond.rs', { on_line = 4, text = 'x += 1;', indent = 8 })
run:new_line('cond.rs', { on_line = 6, text = 'x += 1;', indent = 8 })
run:new_line('enum.rs', { on_line = 2, text = 'Q,', indent = 4 })
run:new_line('enum.rs', { on_line = 4, text = 'i32,', indent = 8 })
run:new_line('enum.rs', { on_line = 8, text = 'z: u32,', indent = 8 })
run:new_line('func.rs', { on_line = 1, text = 'let _x = 1;', indent = 4 })
run:new_line('func.rs', { on_line = 6, text = 'z: i32,', indent = 4 })
run:new_line('impl.rs', { on_line = 3, text = 'const FOO: u32 = 1;', indent = 4 })
run:new_line('impl.rs', { on_line = 4, text = 'let _x = 1;', indent = 8 })
run:new_line('loop.rs', { on_line = 10, text = 'x += 1;', indent = 8 })
run:new_line('loop.rs', { on_line = 2, text = 'x += 1;', indent = 8 })
run:new_line('loop.rs', { on_line = 6, text = 'x += 1;', indent = 8 })
run:new_line('macro.rs', { on_line = 1, text = '() => {},', indent = 4 })
run:new_line('macro.rs', { on_line = 12, text = 'B C', indent = 4 })
run:new_line('macro.rs', { on_line = 2, text = 'struct $c;', indent = 8 })
run:new_line('match.rs', { on_line = 2, text = '-1 => -1,', indent = 8 })
run:new_line('match.rs', { on_line = 7, text = 'let y = 1;', indent = 12 })
run:new_line('mod.rs', { on_line = 1, text = 'const Z: i32 = 1;', indent = 4 })
run:new_line('mod.rs', { on_line = 2, text = 'const Z: i32 = 1;', indent = 4 })
run:new_line('mod.rs', { on_line = 6, text = 'const Z: i32 = 1;', indent = 8 })
run:new_line('string.rs', { on_line = 2, text = 'brave new', indent = 0 })
run:new_line('string.rs', { on_line = 5, text = 'brave new \\', indent = 8 })
run:new_line('string.rs', { on_line = 9, text = 'brave new \\', indent = 8 })
run:new_line('struct.rs', { on_line = 1, text = 'z: i32,', indent = 4 })
run:new_line('struct.rs', { on_line = 2, text = 'z: i32,', indent = 4 })
run:new_line('trait.rs', { on_line = 4, text = 'fn baz();', indent = 4 })
run:new_line('trait.rs', { on_line = 7, text = 'fn baz();', indent = 4 })
run:new_line('trait.rs', { on_line = 8, text = '()', indent = 8 })
run:new_line('where.rs', { on_line = 17, text = 'T: Debug,', indent = 4 })
run:new_line('where.rs', { on_line = 2, text = 'T: Debug,', indent = 4 })
run:new_line('where.rs', { on_line = 9, text = 'T: Debug,', indent = 4 })
describe("new line:", function()
run:new_line("array.rs", { on_line = 2, text = "0,", indent = 4 })
run:new_line("array.rs", { on_line = 8, text = "0,", indent = 8 })
run:new_line("comment.rs", { on_line = 3, text = "a", indent = "/// " })
run:new_line("cond.rs", { on_line = 11, text = "x += 1;", indent = 12 })
run:new_line("cond.rs", { on_line = 2, text = "x += 1;", indent = 8 })
run:new_line("cond.rs", { on_line = 4, text = "x += 1;", indent = 8 })
run:new_line("cond.rs", { on_line = 6, text = "x += 1;", indent = 8 })
run:new_line("enum.rs", { on_line = 2, text = "Q,", indent = 4 })
run:new_line("enum.rs", { on_line = 4, text = "i32,", indent = 8 })
run:new_line("enum.rs", { on_line = 8, text = "z: u32,", indent = 8 })
run:new_line("func.rs", { on_line = 1, text = "let _x = 1;", indent = 4 })
run:new_line("func.rs", { on_line = 6, text = "z: i32,", indent = 4 })
run:new_line("impl.rs", { on_line = 3, text = "const FOO: u32 = 1;", indent = 4 })
run:new_line("impl.rs", { on_line = 4, text = "let _x = 1;", indent = 8 })
run:new_line("loop.rs", { on_line = 10, text = "x += 1;", indent = 8 })
run:new_line("loop.rs", { on_line = 2, text = "x += 1;", indent = 8 })
run:new_line("loop.rs", { on_line = 6, text = "x += 1;", indent = 8 })
run:new_line("macro.rs", { on_line = 1, text = "() => {},", indent = 4 })
run:new_line("macro.rs", { on_line = 12, text = "B C", indent = 4 })
run:new_line("macro.rs", { on_line = 2, text = "struct $c;", indent = 8 })
run:new_line("match.rs", { on_line = 2, text = "-1 => -1,", indent = 8 })
run:new_line("match.rs", { on_line = 7, text = "let y = 1;", indent = 12 })
run:new_line("mod.rs", { on_line = 1, text = "const Z: i32 = 1;", indent = 4 })
run:new_line("mod.rs", { on_line = 2, text = "const Z: i32 = 1;", indent = 4 })
run:new_line("mod.rs", { on_line = 6, text = "const Z: i32 = 1;", indent = 8 })
run:new_line("string.rs", { on_line = 2, text = "brave new", indent = 0 })
run:new_line("string.rs", { on_line = 5, text = "brave new \\", indent = 8 })
run:new_line("string.rs", { on_line = 9, text = "brave new \\", indent = 8 })
run:new_line("struct.rs", { on_line = 1, text = "z: i32,", indent = 4 })
run:new_line("struct.rs", { on_line = 2, text = "z: i32,", indent = 4 })
run:new_line("trait.rs", { on_line = 4, text = "fn baz();", indent = 4 })
run:new_line("trait.rs", { on_line = 7, text = "fn baz();", indent = 4 })
run:new_line("trait.rs", { on_line = 8, text = "()", indent = 8 })
run:new_line("where.rs", { on_line = 17, text = "T: Debug,", indent = 4 })
run:new_line("where.rs", { on_line = 2, text = "T: Debug,", indent = 4 })
run:new_line("where.rs", { on_line = 9, text = "T: Debug,", indent = 4 })
end)
end)