diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2023-12-04 14:32:39 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-04 14:32:39 -0800 |
commit | c3836e40a2bffbc1d4e06531145b7825788dd818 (patch) | |
tree | 895e994179074983789a5f893b96dc75d39f6e6b /test/unit/os/fileio_spec.lua | |
parent | 45fe4d11add933df76a2ea4bf52ce8904f4a778b (diff) | |
download | rneovim-c3836e40a2bffbc1d4e06531145b7825788dd818.tar.gz rneovim-c3836e40a2bffbc1d4e06531145b7825788dd818.tar.bz2 rneovim-c3836e40a2bffbc1d4e06531145b7825788dd818.zip |
build: enable lintlua for test/unit/ dir #26396
Problem:
Not all Lua code is checked by stylua. Automating code-style is an
important mechanism for reducing time spent on accidental
(non-essential) complexity.
Solution:
- Enable lintlua for `test/unit/` directory.
- TODO: only `test/functional/` remains unchecked.
previous: 45fe4d11add933df76a2ea4bf52ce8904f4a778b
previous: 517f0cc634b985057da5b95cf4ad659ee456a77e
Diffstat (limited to 'test/unit/os/fileio_spec.lua')
-rw-r--r-- | test/unit/os/fileio_spec.lua | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/test/unit/os/fileio_spec.lua b/test/unit/os/fileio_spec.lua index fd30ca70da..30e4fad88f 100644 --- a/test/unit/os/fileio_spec.lua +++ b/test/unit/os/fileio_spec.lua @@ -26,7 +26,7 @@ local linkb = dir .. '/broken.lnk' local filec = dir .. '/created-file.dat' before_each(function() - mkdir(dir); + mkdir(dir) local f1 = io.open(file1, 'w') f1:write(fcontents) @@ -56,7 +56,7 @@ local function file_open(fname, flags, mode) end local function file_open_new(fname, flags, mode) - local ret1 = ffi.new('int[?]', 1, {0}) + local ret1 = ffi.new('int[?]', 1, { 0 }) local ret2 = ffi.gc(m.file_open_new(ret1, fname, flags, mode), nil) return ret1[0], ret2 end @@ -68,7 +68,7 @@ local function file_open_fd(fd, flags) end local function file_open_fd_new(fd, flags) - local ret1 = ffi.new('int[?]', 1, {0}) + local ret1 = ffi.new('int[?]', 1, { 0 }) local ret2 = ffi.gc(m.file_open_fd_new(ret1, fd, flags), nil) return ret1[0], ret2 end @@ -116,7 +116,7 @@ describe('file_open_fd', function() local fd = m.os_open(file1, m.kO_RDONLY, 0) local err, fp = file_open_fd(fd, m.kFileReadOnly) eq(0, err) - eq({#fcontents, fcontents}, {file_read(fp, #fcontents)}) + eq({ #fcontents, fcontents }, { file_read(fp, #fcontents) }) eq(0, m.file_close(fp, false)) end) itp('can use file descriptor returned by os_open for writing', function() @@ -136,7 +136,7 @@ describe('file_open_fd_new', function() local fd = m.os_open(file1, m.kO_RDONLY, 0) local err, fp = file_open_fd_new(fd, m.kFileReadOnly) eq(0, err) - eq({#fcontents, fcontents}, {file_read(fp, #fcontents)}) + eq({ #fcontents, fcontents }, { file_read(fp, #fcontents) }) eq(0, m.file_free(fp, false)) end) itp('can use file descriptor returned by os_open for writing', function() @@ -193,7 +193,9 @@ describe('file_open', function() local err, _ = file_open(linkf, m.kFileNoSymlink, 384) -- err is UV_EMLINK in FreeBSD, but if I use `ok(err == m.UV_ELOOP or err == -- m.UV_EMLINK)`, then I loose the ability to see actual `err` value. - if err ~= m.UV_ELOOP then eq(m.UV_EMLINK, err) end + if err ~= m.UV_ELOOP then + eq(m.UV_EMLINK, err) + end end) itp('can open an existing file write-only with kFileCreate', function() @@ -249,8 +251,7 @@ describe('file_open', function() eq(nil, attrs) end) - itp('can truncate an existing file with kFileTruncate when opening a symlink', - function() + itp('can truncate an existing file with kFileTruncate when opening a symlink', function() local err, fp = file_open(linkf, m.kFileTruncate, 384) eq(0, err) eq(true, fp.wr) @@ -356,10 +357,9 @@ describe('file_read', function() local exp_s = fcontents:sub(shift + 1, shift + size) if shift + size >= #fcontents then exp_err = #fcontents - shift - exp_s = (fcontents:sub(shift + 1, shift + size) - .. (('\0'):rep(size - exp_err))) + exp_s = (fcontents:sub(shift + 1, shift + size) .. (('\0'):rep(size - exp_err))) end - eq({exp_err, exp_s}, {file_read(fp, size)}) + eq({ exp_err, exp_s }, { file_read(fp, size) }) shift = shift + size end eq(0, m.file_close(fp, false)) @@ -369,8 +369,8 @@ describe('file_read', function() local err, fp = file_open(file1, 0, 384) eq(0, err) eq(false, fp.wr) - eq({#fcontents, fcontents}, {file_read(fp, #fcontents)}) - eq({0, ('\0'):rep(#fcontents)}, {file_read(fp, #fcontents)}) + eq({ #fcontents, fcontents }, { file_read(fp, #fcontents) }) + eq({ 0, ('\0'):rep(#fcontents) }, { file_read(fp, #fcontents) }) eq(0, m.file_close(fp, false)) end) @@ -378,9 +378,8 @@ describe('file_read', function() local err, fp = file_open(file1, 0, 384) eq(0, err) eq(false, fp.wr) - eq({5, fcontents:sub(1, 5)}, {file_read(fp, 5)}) - eq({#fcontents - 5, fcontents:sub(6) .. (('\0'):rep(5))}, - {file_read(fp, #fcontents)}) + eq({ 5, fcontents:sub(1, 5) }, { file_read(fp, 5) }) + eq({ #fcontents - 5, fcontents:sub(6) .. (('\0'):rep(5)) }, { file_read(fp, #fcontents) }) eq(0, m.file_close(fp, false)) end) @@ -395,10 +394,9 @@ describe('file_read', function() local exp_s = fcontents:sub(shift + 1, shift + size) if shift + size >= #fcontents then exp_err = #fcontents - shift - exp_s = (fcontents:sub(shift + 1, shift + size) - .. (('\0'):rep(size - exp_err))) + exp_s = (fcontents:sub(shift + 1, shift + size) .. (('\0'):rep(size - exp_err))) end - eq({exp_err, exp_s}, {file_read(fp, size)}) + eq({ exp_err, exp_s }, { file_read(fp, size) }) shift = shift + size end eq(0, m.file_close(fp, false)) |