test/lua/module/pandoc.lua: fix non-determinism in test

This commit is contained in:
Albert Krewinkel 2019-06-11 21:17:06 +02:00
parent 7f9b32e36a
commit 6704b66c33
No known key found for this signature in database
GPG key ID: 388DC0B21F631124

View file

@ -20,18 +20,25 @@ return {
test(
'accepts string-indexed table or list of pairs as attributes',
function ()
local attributes_table = {one = '1', two = '2'}
local attributes_list = pandoc.List:new {{'one', '1'}, {'two', '2'}}
local attr_from_table = pandoc.Attr('', {}, attributes_table)
local attr_from_list = pandoc.Attr('', {}, attributes_list:clone())
assert.are_same(
pandoc.List:new(attr_from_table.attributes),
attributes_list
)
assert.are_same(
pandoc.List:new(attr_from_list.attributes),
attributes_list
)
local attributes_table = {one = '1', two = '2'}
local attr_from_table = pandoc.Attr('', {}, attributes_table)
local assoc_list_from_table =
pandoc.List:new(attr_from_table.attributes)
-- won't work in general, but does in this special case
table.sort(assoc_list_from_table, function(x, y) return x[1]<y[1] end)
assert.are_same(
assoc_list_from_table,
attributes_list
)
end
)
},