1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
local tasty = require 'tasty'
local test = tasty.test_case
local group = tasty.test_group
local assert = tasty.assert
return {
group 'ListAttributes' {
test('has field `start`', function ()
local la = ListAttributes(7, DefaultStyle, Period)
assert.are_equal(la.start, 7)
end),
test('has field `style`', function ()
local la = ListAttributes(1, Example, Period)
assert.are_equal(la.style, 'Example')
end),
test('has field `delimiter`', function ()
local la = ListAttributes(1, Example, Period)
assert.are_equal(la.delimiter, 'Period')
end),
test('can be compared on equality', function ()
assert.are_equal(
ListAttributes(2, DefaultStyle, Period),
ListAttributes(2, DefaultStyle, Period)
)
assert.is_falsy(
ListAttributes(2, DefaultStyle, Period) ==
ListAttributes(4, DefaultStyle, Period)
)
end),
test('can be modified through `start`', function ()
local la = ListAttributes(3, Decimal, OneParen)
la.start = 20
assert.are_equal(la, ListAttributes(20, Decimal, OneParen))
end),
test('can be modified through `style`', function ()
local la = ListAttributes(3, Decimal, OneParen)
la.style = LowerRoman
assert.are_equal(la, ListAttributes(3, LowerRoman, OneParen))
end),
test('can be modified through `delimiter`', function ()
local la = ListAttributes(5, UpperAlpha, DefaultDelim)
la.delimiter = TwoParens
assert.are_equal(la, ListAttributes(5, UpperAlpha, TwoParens))
end),
test('can be cloned', function ()
local la = ListAttributes(2, DefaultStyle, Period)
local cloned = la:clone()
assert.are_equal(la, cloned)
la.start = 9
assert.are_same(cloned.start, 2)
end),
group 'Constructor' {
test('omitting a start numer sets it to 1', function ()
assert.are_equal(ListAttributes().start, 1)
end),
test('omitting a style sets it to DefaultStyle', function ()
assert.are_equal(ListAttributes(0).style, DefaultStyle)
end),
test('omitting a delimiter sets it to DefaultDelim', function ()
assert.are_equal(ListAttributes(0, UpperRoman).delimiter, DefaultDelim)
end)
}
},
}
|