From c3836e40a2bffbc1d4e06531145b7825788dd818 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 4 Dec 2023 14:32:39 -0800 Subject: 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 --- test/unit/eval/encode_spec.lua | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'test/unit/eval/encode_spec.lua') diff --git a/test/unit/eval/encode_spec.lua b/test/unit/eval/encode_spec.lua index 058c55093e..498346d7cc 100644 --- a/test/unit/eval/encode_spec.lua +++ b/test/unit/eval/encode_spec.lua @@ -22,80 +22,83 @@ describe('encode_list_write()', function() itp('writes empty string', function() local l = list() eq(0, encode_list_write(l, '')) - eq({[type_key]=list_type}, lst2tbl(l)) + eq({ [type_key] = list_type }, lst2tbl(l)) end) itp('writes ASCII string literal with printable characters', function() local l = list() eq(0, encode_list_write(l, 'abc')) - eq({'abc'}, lst2tbl(l)) + eq({ 'abc' }, lst2tbl(l)) end) itp('writes string starting with NL', function() local l = list() eq(0, encode_list_write(l, '\nabc')) - eq({null_string, 'abc'}, lst2tbl(l)) + eq({ null_string, 'abc' }, lst2tbl(l)) end) itp('writes string starting with NL twice', function() local l = list() eq(0, encode_list_write(l, '\nabc')) - eq({null_string, 'abc'}, lst2tbl(l)) + eq({ null_string, 'abc' }, lst2tbl(l)) eq(0, encode_list_write(l, '\nabc')) - eq({null_string, 'abc', 'abc'}, lst2tbl(l)) + eq({ null_string, 'abc', 'abc' }, lst2tbl(l)) end) itp('writes string ending with NL', function() local l = list() eq(0, encode_list_write(l, 'abc\n')) - eq({'abc', null_string}, lst2tbl(l)) + eq({ 'abc', null_string }, lst2tbl(l)) end) itp('writes string ending with NL twice', function() local l = list() eq(0, encode_list_write(l, 'abc\n')) - eq({'abc', null_string}, lst2tbl(l)) + eq({ 'abc', null_string }, lst2tbl(l)) eq(0, encode_list_write(l, 'abc\n')) - eq({'abc', 'abc', null_string}, lst2tbl(l)) + eq({ 'abc', 'abc', null_string }, lst2tbl(l)) end) itp('writes string starting, ending and containing NL twice', function() local l = list() eq(0, encode_list_write(l, '\na\nb\n')) - eq({null_string, 'a', 'b', null_string}, lst2tbl(l)) + eq({ null_string, 'a', 'b', null_string }, lst2tbl(l)) eq(0, encode_list_write(l, '\na\nb\n')) - eq({null_string, 'a', 'b', null_string, 'a', 'b', null_string}, lst2tbl(l)) + eq({ null_string, 'a', 'b', null_string, 'a', 'b', null_string }, lst2tbl(l)) end) itp('writes string starting, ending and containing NUL with NL between twice', function() local l = list() eq(0, encode_list_write(l, '\0\n\0\n\0')) - eq({'\n', '\n', '\n'}, lst2tbl(l)) + eq({ '\n', '\n', '\n' }, lst2tbl(l)) eq(0, encode_list_write(l, '\0\n\0\n\0')) - eq({'\n', '\n', '\n\n', '\n', '\n'}, lst2tbl(l)) + eq({ '\n', '\n', '\n\n', '\n', '\n' }, lst2tbl(l)) end) itp('writes string starting, ending and containing NL with NUL between twice', function() local l = list() eq(0, encode_list_write(l, '\n\0\n\0\n')) - eq({null_string, '\n', '\n', null_string}, lst2tbl(l)) + eq({ null_string, '\n', '\n', null_string }, lst2tbl(l)) eq(0, encode_list_write(l, '\n\0\n\0\n')) - eq({null_string, '\n', '\n', null_string, '\n', '\n', null_string}, lst2tbl(l)) + eq({ null_string, '\n', '\n', null_string, '\n', '\n', null_string }, lst2tbl(l)) end) itp('writes string containing a single NL twice', function() local l = list() eq(0, encode_list_write(l, '\n')) - eq({null_string, null_string}, lst2tbl(l)) + eq({ null_string, null_string }, lst2tbl(l)) eq(0, encode_list_write(l, '\n')) - eq({null_string, null_string, null_string}, lst2tbl(l)) + eq({ null_string, null_string, null_string }, lst2tbl(l)) end) itp('writes string containing a few NLs twice', function() local l = list() eq(0, encode_list_write(l, '\n\n\n')) - eq({null_string, null_string, null_string, null_string}, lst2tbl(l)) + eq({ null_string, null_string, null_string, null_string }, lst2tbl(l)) eq(0, encode_list_write(l, '\n\n\n')) - eq({null_string, null_string, null_string, null_string, null_string, null_string, null_string}, lst2tbl(l)) + eq( + { null_string, null_string, null_string, null_string, null_string, null_string, null_string }, + lst2tbl(l) + ) end) end) -- cgit