1
0

Added new tests for various unicode issues, mostly aligment and sorting.

This commit is contained in:
Jon Michael Aanes 2017-06-15 19:03:42 +02:00
parent b37a02c850
commit 965e99abcc
3 changed files with 32 additions and 1 deletions

View File

@ -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}',
}
--------------------------------------------------------------------------------

View File

@ -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

View File

@ -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