aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2019-06-12 18:58:38 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2019-06-12 09:58:38 -0700
commit11bb8627677fb8b49af92d7c55aec07c69f95843 (patch)
tree3bd8a3ea839a94747b2cc41e78ef7f062c7489f9 /test
parentd81b9f55c142f89db38edd44db999ef2de162a8d (diff)
downloadpandoc-11bb8627677fb8b49af92d7c55aec07c69f95843.tar.gz
Lua: add a `clone()` method to all AST elements (#5572)
Closes: #5568
Diffstat (limited to 'test')
-rw-r--r--test/lua/module/pandoc.lua38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/lua/module/pandoc.lua b/test/lua/module/pandoc.lua
index 1c02c8720..ca2168805 100644
--- a/test/lua/module/pandoc.lua
+++ b/test/lua/module/pandoc.lua
@@ -87,6 +87,44 @@ return {
end)
},
},
+
+ group 'clone' {
+ test('clones Attr', function ()
+ local attr = pandoc.Attr('test', {'my-class'}, {foo = 'bar'})
+ local cloned = attr:clone()
+ attr.identifier = ''
+ attr.classes = {}
+ attr.attributes = {}
+ assert.are_same(cloned.identifier, 'test')
+ assert.are_same(cloned.classes, {'my-class'})
+ assert.are_same(cloned.attributes.foo, 'bar')
+ end),
+ test('clones ListAttributes', function ()
+ local la = pandoc.ListAttributes(2, pandoc.DefaultStyle, pandoc.Period)
+ local cloned = la:clone()
+ la.start = 9
+ assert.are_same(cloned.start, 2)
+ end),
+ test('clones Para', function ()
+ local para = pandoc.Para {pandoc.Str 'Hello'}
+ local cloned = para:clone()
+ para.content[1].text = 'bye'
+ assert.are_same(cloned, pandoc.Para {pandoc.Str 'Hello'})
+ end),
+ test('clones Str', function ()
+ local str = pandoc.Str 'Hello'
+ local cloned = str:clone()
+ str.text = 'bye'
+ assert.are_same(cloned.text, 'Hello')
+ end),
+ test('clones Citation', function ()
+ local cite = pandoc.Citation('leibniz', pandoc.AuthorInText)
+ local cloned = cite:clone()
+ cite.id = 'newton'
+ assert.are_same(cloned.id, 'leibniz')
+ end),
+ },
+
group 'pipe' {
test('external string processing', function ()
if os_is_windows() then