local tasty = require 'tasty' local test = tasty.test_case local group = tasty.test_group local assert = tasty.assert function os_is_windows () return package.config:sub(1,1) == '\\' end return { group 'Attr' { group 'Constructor' { test('returns null-Attr if no arguments are given', function () local attr = pandoc.Attr() assert.are_equal(attr.identifier, '') assert.are_same(attr.classes, {}) assert.are_same(attr.attributes, {}) end), test( 'accepts string-indexed table or list of pairs as attributes', function () local attributes_list = pandoc.List:new {{'one', '1'}, {'two', '2'}} local attr_from_list = pandoc.Attr('', {}, attributes_list:clone()) 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]