mirror of
https://github.com/neovim/neovim.git
synced 2026-03-29 11:52:04 +00:00
vim-patch:partial:9.1.1955: sort() does not handle large numbers correctly (#36840)
Problem: sort() does not handle large numbers correctly
(Igbanam Ogbuluijah)
Solution: Don't truncate the return value of tv_get_number_chk()
(Yegappan Lakshmanan)
closes: vim/vim#18868
04794efe12
Use a Lua test for now, as the Vimscript test uses tuples.
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
@@ -66,4 +66,29 @@ describe('sort()', function()
|
||||
pcall_err(command, 'let sl = sort([1, 0, [], 3, 2], "Cmp")')
|
||||
)
|
||||
end)
|
||||
|
||||
it('handles large numbers properly', function()
|
||||
local to_sort = {
|
||||
{ 229539777187355, 229539777187355 },
|
||||
{ 487766135067138, 491977135306566 },
|
||||
{ 188325333471071, 188931909913550 },
|
||||
{ 264028451845520, 265514296554744 },
|
||||
{ 245727634348687, 249469249579525 },
|
||||
{ 375117820166731, 378942174241518 },
|
||||
{ 535474757750378, 535849288071548 },
|
||||
}
|
||||
local expected = {
|
||||
{ 188325333471071, 188931909913550 },
|
||||
{ 229539777187355, 229539777187355 },
|
||||
{ 245727634348687, 249469249579525 },
|
||||
{ 264028451845520, 265514296554744 },
|
||||
{ 375117820166731, 378942174241518 },
|
||||
{ 487766135067138, 491977135306566 },
|
||||
{ 535474757750378, 535849288071548 },
|
||||
}
|
||||
eq(expected, fn.sort(to_sort))
|
||||
api.nvim_set_var('to_sort', to_sort)
|
||||
eq(expected, api.nvim_eval('sort(g:to_sort)'))
|
||||
eq(expected, api.nvim_eval('sort(g:to_sort, {a, b -> a[0] - b[0]})'))
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user