diff --git a/test/test_function.lua b/test/test_function.lua index 6f8c3b9..0419fc5 100644 --- a/test/test_function.lua +++ b/test/test_function.lua @@ -391,6 +391,15 @@ format_test { expect = '{\n abs = function (x) ... end,\n max = function (a, b) ... end\n}', } +format_test { + name = 'Functions with unicode-named parameters should align nicely', + adv_getlocal = true, + input = { a = function (ψ) return ψ end, + b = function (a) return a end + }, + expect = '{\n a = function (ψ) ... end\n b = function (a) ... end\n}', +} + -------------------------------------------------------------------------------- diff --git a/test/test_pretty.lua b/test/test_pretty.lua index 7c91699..306223c 100644 --- a/test/test_pretty.lua +++ b/test/test_pretty.lua @@ -18,7 +18,7 @@ if not loadstring then loadstring = load end -- Lua 5.3 compa local function format_test (t) if t.longterm then return end if t.adv_getlocal and not HAS_ADV_GETLOCAL then return end - SUITE:addTest(t.name or t.expect:gsub('[ \n\t]+', ' '), function () + SUITE:addTest(t.name or t.expect, function () local actual_result = format(t.input, t.options) if not t.approx or type(actual_result) ~= 'string' then assert_equal(t.expect, actual_result) @@ -220,6 +220,12 @@ format_test { expect = '{ a = { 1, 2, 3 }, b = { 4, 5, 6 } }', } +format_test { + name = 'Unicode characters can be used as string keys in tables', + input = { a = 1, ψ = 2 }, + expect = '{ a = 1, ψ = 2 }', +} + format_test { input = { [100] = 'Hi', [300] = 'Hello' }, expect = '{ [100] = \'Hi\', [300] = \'Hello\' }', @@ -296,6 +302,16 @@ format_test { expect = '{\n { a = \'hello\', b = \'hi\' },\n { a = \'hi\', b = \'hello\' }\n}', } +format_test { + name = 'Proper alignment when using unicode characters as keys', + input = { + djævle = 'dyr?', + europa = 'måne', + øå = 'en å på en ø?', + }, + expect = '{\n djævle = \'dyr?\',\n europa = \'måne\',\n øå = \'en å på en ø?\'\n}', +} + -------------------------------------------------------------------------------- -- Table recursion diff --git a/test/test_sorting.lua b/test/test_sorting.lua index c8aa73c..8fcf1b4 100644 --- a/test/test_sorting.lua +++ b/test/test_sorting.lua @@ -66,6 +66,12 @@ format_test { expect = '{ 1, nil, 3 }', } +format_test { + name = 'øl kommer tydeligt før ål', + input = { øl = 1, ål = 2 }, + expect = '{ øl = 1, ål = 2 }', +} + -------------------------------------------------------------------------------- -- Alphanum Algorithm Example 1