aboutsummaryrefslogtreecommitdiff
path: root/test/lua/module
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2021-12-21 21:25:16 +0100
committerAlbert Krewinkel <albert@zeitkraut.de>2021-12-21 21:25:16 +0100
commitedb04a78dba3490dc28ef68d5133b0220a0426fa (patch)
treec12356c9e1f5cdf972f4a980d6952fce729ef193 /test/lua/module
parent17a32a99a5eefadc5ebe66d441b6c4f7a0d2f438 (diff)
downloadpandoc-edb04a78dba3490dc28ef68d5133b0220a0426fa.tar.gz
Lua tests: add more tests for `pandoc.utils.stringify`.
Diffstat (limited to 'test/lua/module')
-rw-r--r--test/lua/module/pandoc-utils.lua47
1 files changed, 45 insertions, 2 deletions
diff --git a/test/lua/module/pandoc-utils.lua b/test/lua/module/pandoc-utils.lua
index db363ebe6..73886346c 100644
--- a/test/lua/module/pandoc-utils.lua
+++ b/test/lua/module/pandoc-utils.lua
@@ -135,7 +135,7 @@ return {
},
group 'stringify' {
- test('inlines', function ()
+ test('Inline', function ()
local inline = pandoc.Emph{
pandoc.Str 'Cogito',
pandoc.Space(),
@@ -144,7 +144,50 @@ return {
pandoc.Str 'sum.',
}
assert.are_equal('Cogito ergo sum.', utils.stringify(inline))
- end)
+ end),
+ test('Block', function ()
+ local block = pandoc.Para{
+ pandoc.Str 'Make',
+ pandoc.Space(),
+ pandoc.Str 'it',
+ pandoc.Space(),
+ pandoc.Str 'so.',
+ }
+ assert.are_equal('Make it so.', utils.stringify(block))
+ end),
+ test('boolean', function ()
+ assert.are_equal('true', utils.stringify(true))
+ assert.are_equal('false', utils.stringify(false))
+ end),
+ test('number', function ()
+ assert.are_equal('5', utils.stringify(5))
+ assert.are_equal('23.23', utils.stringify(23.23))
+ end),
+ test('Attr', function ()
+ local attr = pandoc.Attr('foo', {'bar'}, {a = 'b'})
+ assert.are_equal('', utils.stringify(attr))
+ end),
+ test('List', function ()
+ local list = pandoc.List{pandoc.Str 'a', pandoc.Blocks('b')}
+ assert.are_equal('ab', utils.stringify(list))
+ end),
+ test('Blocks', function ()
+ local blocks = pandoc.Blocks{pandoc.Para 'a', pandoc.Header(1, 'b')}
+ assert.are_equal('ab', utils.stringify(blocks))
+ end),
+ test('Inlines', function ()
+ local inlines = pandoc.Inlines{pandoc.Str 'a', pandoc.Subscript('b')}
+ assert.are_equal('ab', utils.stringify(inlines))
+ end),
+ test('Meta', function ()
+ local meta = pandoc.Meta{
+ a = pandoc.Inlines 'a text',
+ b = 'movie',
+ c = pandoc.List{pandoc.Inlines{pandoc.Str '!'}}
+ }
+ -- nested MetaString values are not stringified.
+ assert.are_equal('a text!', utils.stringify(meta))
+ end),
},
group 'to_roman_numeral' {