git.iko.soy/typeable/pandoc
on master help sign in
test/lua/module/pandoc.lua: fix non-determinism in test
commit6704b66c33fa75b4b153cff809947489b267f2a8 authorAlbert Krewinkel <albert@zeitkraut.de> dateTue 11 Jun 2019, 21:17 (7 years ago) parent7f9b32e
1 file changed+11−4
test/lua/module/pandoc.lua+11−4
test/lua/module/pandoc.lua+11−4
@@ -20,16 +20,23 @@ return {
2020 test(
2121 'accepts string-indexed table or list of pairs as attributes',
2222 function ()
23− local attributes_table = {one = '1', two = '2'}
2423 local attributes_list = pandoc.List:new {{'one', '1'}, {'two', '2'}}
25− local attr_from_table = pandoc.Attr('', {}, attributes_table)
2624 local attr_from_list = pandoc.Attr('', {}, attributes_list:clone())
25+
2726 assert.are_same(
28− pandoc.List:new(attr_from_table.attributes),
27+ pandoc.List:new(attr_from_list.attributes),
2928 attributes_list
3029 )
30+
31+ local attributes_table = {one = '1', two = '2'}
32+ local attr_from_table = pandoc.Attr('', {}, attributes_table)
33+
34+ local assoc_list_from_table =
35+ pandoc.List:new(attr_from_table.attributes)
36+ -- won't work in general, but does in this special case
37+ table.sort(assoc_list_from_table, function(x, y) return x[1]<y[1] end)
3138 assert.are_same(
32− pandoc.List:new(attr_from_list.attributes),
39+ assoc_list_from_table,
3340 attributes_list
3441 )
3542 end