summaryrefslogtreecommitdiff
path: root/test/lua
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2022-09-29 17:24:31 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2022-09-30 08:33:40 -0700
commit5be9052f5fb7283372b3d5497bef499718a34992 (patch)
tree80e5805786ef7ab08f363135861e1aa9c8868f6f /test/lua
parent79980eee4a1854921d7fb8b14848894b53cc21a7 (diff)
[API Change] Extract Lua code into new package pandoc-lua-engine
The flag 'lua53` must now be used with that package if pandoc is to be compiled against Lua 5.3.
Diffstat (limited to 'test/lua')
-rw-r--r--test/lua/attr-test.lua6
-rw-r--r--test/lua/block-count.lua11
-rw-r--r--test/lua/blocks-filter.lua8
-rw-r--r--test/lua/hello-world-doc.lua10
-rw-r--r--test/lua/implicit-doc-filter.lua6
-rw-r--r--test/lua/inlines-filter.lua19
-rw-r--r--test/lua/markdown-reader.lua12
-rw-r--r--test/lua/math.lua10
-rw-r--r--test/lua/meta.lua6
-rw-r--r--test/lua/metatable-catch-all.lua20
-rw-r--r--test/lua/module/globals.lua108
-rw-r--r--test/lua/module/pandoc-list.lua160
-rw-r--r--test/lua/module/pandoc-mediabag.lua72
-rw-r--r--test/lua/module/pandoc-path.lua44
-rw-r--r--test/lua/module/pandoc-template.lua65
-rw-r--r--test/lua/module/pandoc-types.lua86
-rw-r--r--test/lua/module/pandoc-utils.lua333
-rw-r--r--test/lua/module/pandoc.lua356
-rw-r--r--test/lua/module/partial.test0
-rw-r--r--test/lua/module/tiny.epubbin3097 -> 0 bytes
-rw-r--r--test/lua/plain-to-para.lua6
-rw-r--r--test/lua/require-file.lua2
-rw-r--r--test/lua/script-name.lua3
-rw-r--r--test/lua/single-to-double-quoted.lua10
-rw-r--r--test/lua/smallcaps-title.lua12
-rw-r--r--test/lua/smart-constructors.lua10
-rw-r--r--test/lua/strmacro.lua11
-rw-r--r--test/lua/undiv.lua3
-rw-r--r--test/lua/uppercase-header.lua9
29 files changed, 0 insertions, 1398 deletions
diff --git a/test/lua/attr-test.lua b/test/lua/attr-test.lua
deleted file mode 100644
index 68dc0012d..000000000
--- a/test/lua/attr-test.lua
+++ /dev/null
@@ -1,6 +0,0 @@
-function Div (div)
- div.attributes.five = ("%d"):format(div.attributes.two + div.attributes.three)
- div.attributes.two = nil
- div.attributes.one = "eins"
- return div
-end
diff --git a/test/lua/block-count.lua b/test/lua/block-count.lua
deleted file mode 100644
index 508b05ea8..000000000
--- a/test/lua/block-count.lua
+++ /dev/null
@@ -1,11 +0,0 @@
-local num_blocks = 0
-
-function Block(el)
- num_blocks = num_blocks + 1
-end
-
-function Pandoc(blocks, meta)
- return pandoc.Pandoc {
- pandoc.Para{pandoc.Str(num_blocks)}
- }
-end
diff --git a/test/lua/blocks-filter.lua b/test/lua/blocks-filter.lua
deleted file mode 100644
index 4e944e922..000000000
--- a/test/lua/blocks-filter.lua
+++ /dev/null
@@ -1,8 +0,0 @@
-function Blocks (blks)
- -- verify that this looks like a `pandoc.List`
- if not blks.find or not blks.map or not blks.filter then
- error("table doesn't seem to be an instance of pandoc.List")
- end
- -- return plain block containing the number of elements in the list
- return {pandoc.Plain {pandoc.Str(tostring(#blks))}}
-end
diff --git a/test/lua/hello-world-doc.lua b/test/lua/hello-world-doc.lua
deleted file mode 100644
index 62236584e..000000000
--- a/test/lua/hello-world-doc.lua
+++ /dev/null
@@ -1,10 +0,0 @@
-return {
- {
- Pandoc = function(doc)
- local meta = {}
- local hello = { pandoc.Str "Hello,", pandoc.Space(), pandoc.Str "World!" }
- local blocks = { pandoc.Para(hello) }
- return pandoc.Pandoc(blocks, meta)
- end
- }
-}
diff --git a/test/lua/implicit-doc-filter.lua b/test/lua/implicit-doc-filter.lua
deleted file mode 100644
index f053dc1b2..000000000
--- a/test/lua/implicit-doc-filter.lua
+++ /dev/null
@@ -1,6 +0,0 @@
-function Pandoc (doc)
- local meta = {}
- local hello = { pandoc.Str "Hello,", pandoc.Space(), pandoc.Str "World!" }
- local blocks = { pandoc.Para(hello) }
- return pandoc.Pandoc(blocks, meta)
-end
diff --git a/test/lua/inlines-filter.lua b/test/lua/inlines-filter.lua
deleted file mode 100644
index 69608bd77..000000000
--- a/test/lua/inlines-filter.lua
+++ /dev/null
@@ -1,19 +0,0 @@
-function isWorldAfterSpace (fst, snd)
- return fst and fst.t == 'LineBreak'
- and snd and snd.t == 'Str' and snd.text == 'World!'
-end
-
-function Inlines (inlns)
- -- verify that this looks like a `pandoc.List`
- if not inlns.find or not inlns.map or not inlns.filter then
- error("table doesn't seem to be an instance of pandoc.List")
- end
-
- -- Remove spaces before string "World"
- for i = #inlns-1,1,-1 do
- if isWorldAfterSpace(inlns[i], inlns[i+1]) then
- inlns[i] = pandoc.Space()
- end
- end
- return inlns
-end
diff --git a/test/lua/markdown-reader.lua b/test/lua/markdown-reader.lua
deleted file mode 100644
index 1530a15a2..000000000
--- a/test/lua/markdown-reader.lua
+++ /dev/null
@@ -1,12 +0,0 @@
-return {
- {
- RawBlock = function (elem)
- if elem.format == "markdown" then
- local pd = pandoc.read(elem.text, "markdown")
- return pd.blocks[1]
- else
- return elem
- end
- end,
- }
-}
diff --git a/test/lua/math.lua b/test/lua/math.lua
deleted file mode 100644
index 34307dd9e..000000000
--- a/test/lua/math.lua
+++ /dev/null
@@ -1,10 +0,0 @@
-return {
- {
- Math = function (elem)
- if elem.mathtype == "DisplayMath" then
- elem.mathtype = "InlineMath"
- end
- return elem
- end,
- }
-}
diff --git a/test/lua/meta.lua b/test/lua/meta.lua
deleted file mode 100644
index 5e2946203..000000000
--- a/test/lua/meta.lua
+++ /dev/null
@@ -1,6 +0,0 @@
-function Meta (meta)
- meta.old = nil
- meta.new = "new"
- meta.bool = (meta.bool == false)
- return meta
-end
diff --git a/test/lua/metatable-catch-all.lua b/test/lua/metatable-catch-all.lua
deleted file mode 100644
index 05df16bbf..000000000
--- a/test/lua/metatable-catch-all.lua
+++ /dev/null
@@ -1,20 +0,0 @@
-local num_inlines = 0
-
-function catch_all(el)
- if el.tag and pandoc.Inline.constructor[el.tag] then
- num_inlines = num_inlines + 1
- end
-end
-
-function Pandoc(blocks, meta)
- return pandoc.Pandoc {
- pandoc.Para{pandoc.Str(num_inlines)}
- }
-end
-
-return {
- setmetatable(
- {Pandoc = Pandoc},
- {__index = function(_) return catch_all end}
- )
-}
diff --git a/test/lua/module/globals.lua b/test/lua/module/globals.lua
deleted file mode 100644
index 85b287cf2..000000000
--- a/test/lua/module/globals.lua
+++ /dev/null
@@ -1,108 +0,0 @@
-local tasty = require 'tasty'
-
-local test = tasty.test_case
-local group = tasty.test_group
-local assert = tasty.assert
-
--- These tests exist mainly to catch changes to the JSON representation of
--- WriterOptions and its components. UPDATE THE DOCS if anything changes.
-return {
- group 'PANDOC_WRITER_OPTIONS' {
- test('cite_method', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.cite_method), 'string')
- end),
- test('columns', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.columns), 'number')
- end),
- test('dpi', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.dpi), 'number')
- end),
- test('email_obfuscation', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.email_obfuscation), 'string')
- end),
- test('epub_chapter_level', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.epub_chapter_level), 'number')
- end),
- test('epub_fonts', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.epub_fonts), 'table')
- end),
- test('epub_metadata', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.epub_metadata), 'nil')
- end),
- test('epub_subdirectory', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.epub_subdirectory), 'string')
- end),
- test('extensions', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.extensions), 'table')
- for _, v in ipairs(PANDOC_WRITER_OPTIONS.extensions) do
- assert.are_equal(type(v), 'string')
- end
- end),
- test('highlight_style', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.highlight_style), 'table')
- end),
- test('html_math_method', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.html_math_method), 'string')
- end),
- test('html_q_tags', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.html_q_tags), 'boolean')
- end),
- test('identifier_prefix', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.identifier_prefix), 'string')
- end),
- test('incremental', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.incremental), 'boolean')
- end),
- test('listings', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.listings), 'boolean')
- end),
- test('number_offset', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.number_offset), 'table')
- for _, v in ipairs(PANDOC_WRITER_OPTIONS.number_offset) do
- assert.are_equal(type(v), 'number')
- end
- end),
- test('number_sections', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.number_sections), 'boolean')
- end),
- test('prefer_ascii', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.prefer_ascii), 'boolean')
- end),
- test('reference_doc', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.reference_doc), 'nil')
- end),
- test('reference_links', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.reference_links), 'boolean')
- end),
- test('reference_location', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.reference_location), 'string')
- end),
- test('section_divs', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.section_divs), 'boolean')
- end),
- test('setext_headers', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.setext_headers), 'boolean')
- end),
- test('slide_level', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.slide_level), 'nil')
- end),
- test('tab_stop', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.tab_stop), 'number')
- end),
- test('table_of_contents', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.table_of_contents), 'boolean')
- end),
- test('toc_depth', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.toc_depth), 'number')
- end),
- test('top_level_division', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.top_level_division), 'string')
- end),
- test('variables', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.variables), 'table')
- end),
- test('wrap_text', function ()
- assert.are_equal(type(PANDOC_WRITER_OPTIONS.wrap_text), 'string')
- end),
- }
-}
diff --git a/test/lua/module/pandoc-list.lua b/test/lua/module/pandoc-list.lua
deleted file mode 100644
index 27790ce96..000000000
--- a/test/lua/module/pandoc-list.lua
+++ /dev/null
@@ -1,160 +0,0 @@
-local tasty = require 'tasty'
-local List = require 'pandoc.List'
-
-local assert = tasty.assert
-local test = tasty.test_case
-local group = tasty.test_group
-
-return {
- group 'List as function' {
- test('equivalent to List:new', function (x)
- local new = List:new {'ramen'}
- local list = List {'ramen'}
- assert.are_same(new, list)
- assert.are_equal(getmetatable(new), getmetatable(list))
- end)
- },
-
- group 'clone' {
- test('changing the clone does not affect original', function ()
- local orig = List:new {23, 42}
- local copy = orig:clone()
- copy[1] = 5
- assert.are_same({23, 42}, orig)
- assert.are_same({5, 42}, copy)
- end),
- test('result is a list', function ()
- local orig = List:new {23, 42}
- assert.are_equal(List, getmetatable(orig:clone()))
- end),
- },
-
- group 'extend' {
- test('extends list with other list', function ()
- local primes = List:new {2, 3, 5, 7}
- primes:extend {11, 13, 17}
- assert.are_same({2, 3, 5, 7, 11, 13, 17}, primes)
- end)
- },
-
- group 'filter' {
- test('keep elements for which property is truthy', function ()
- local is_small_prime = function (x)
- return List.includes({2, 3, 5, 7}, x)
- end
- local numbers = List:new {4, 7, 2, 9, 5, 11}
- assert.are_same({7, 2, 5}, numbers:filter(is_small_prime))
- end),
- },
-
- group 'find' {
- test('returns element and index if found', function ()
- local list = List:new {5, 23, 71}
- local elem, idx = list:find(71)
- assert.are_same(71, elem)
- assert.are_same(3, idx)
- end),
- test('respects start index', function ()
- local list = List:new {19, 23, 29, 71}
- assert.are_equal(23, list:find(23, 1))
- assert.are_equal(23, list:find(23, 2))
- assert.is_nil(list:find(23, 3))
- end),
- test('returns nil if element not found', function ()
- assert.is_nil((List:new {18, 20, 22, 0, 24}):find('0'))
- end),
- },
-
- group 'find_if' {
- test('returns element and index if found', function ()
- local perm_prime = List:new {2, 3, 5, 7, 11, 13, 17, 31, 37, 71}
- local elem, idx = perm_prime:find_if(function (x) return x >= 10 end)
- assert.are_same(11, elem)
- assert.are_same(5, idx)
- end),
- test('returns nil if element not found', function ()
- local is_null = function (n) return List.includes({23,35,46,59}, n) end
- assert.is_nil((List:new {18, 20, 22, 24, 27}):find_if(is_null))
- end),
- },
-
- group 'includes' {
- test('finds elements in list', function ()
- local lst = List:new {'one', 'two', 'three'}
- assert.is_truthy(lst:includes('one'))
- assert.is_truthy(lst:includes('two'))
- assert.is_truthy(lst:includes('three'))
- assert.is_falsy(lst:includes('four'))
- end)
- },
-
- group 'insert' {
- test('insert value at end of list.', function ()
- local count_norsk = List {'en', 'to', 'tre'}
- count_norsk:insert('fire')
- assert.are_same({'en', 'to', 'tre', 'fire'}, count_norsk)
- end),
- test('insert value in the middle of list.', function ()
- local count_norsk = List {'fem', 'syv'}
- count_norsk:insert(2, 'seks')
- assert.are_same({'fem', 'seks', 'syv'}, count_norsk)
- end)
- },
-
- group 'map' {
- test('applies function to elements', function ()
- local primes = List:new {2, 3, 5, 7}
- local squares = primes:map(function (x) return x^2 end)
- assert.are_same({4, 9, 25, 49}, squares)
- end),
- test('leaves original list unchanged', function ()
- local primes = List:new {2, 3, 5, 7}
- local squares = primes:map(function (x) return x^2 end)
- assert.are_same({2, 3, 5, 7}, primes)
- end)
- },
-
- group 'new' {
- test('make table usable as list', function ()
- local test = List:new{1, 1, 2, 3, 5}
- assert.are_same(
- {1, 1, 4, 9, 25},
- test:map(function (x) return x^2 end)
- )
- end),
- test('return empty list if no argument is given', function ()
- assert.are_same({}, List:new())
- end),
- test('metatable of result is pandoc.List', function ()
- local test = List:new{5}
- assert.are_equal(List, getmetatable(test))
- end)
- },
-
- group 'remove' {
- test('remove value at end of list.', function ()
- local understand = List {'jeg', 'forstår', 'ikke'}
- local norsk_not = understand:remove()
- assert.are_same({'jeg', 'forstår'}, understand)
- assert.are_equal('ikke', norsk_not)
- end),
- test('remove value at beginning of list.', function ()
- local count_norsk = List {'en', 'to', 'tre'}
- count_norsk:remove(1)
- assert.are_same({'to', 'tre'}, count_norsk)
- end)
- },
-
- group 'sort' {
- test('sort numeric list', function ()
- local numbers = List {71, 5, -1, 42, 23, 0, 1}
- numbers:sort()
- assert.are_same({-1, 0, 1, 5, 23, 42, 71}, numbers)
- end),
- test('reverse-sort numeric', function ()
- local numbers = List {71, 5, -1, 42, 23, 0, 1}
- numbers:sort(function (x, y) return x > y end)
- assert.are_same({71, 42, 23, 5, 1, 0, -1}, numbers)
- end)
- },
-}
diff --git a/test/lua/module/pandoc-mediabag.lua b/test/lua/module/pandoc-mediabag.lua
deleted file mode 100644
index 5ff65ee44..000000000
--- a/test/lua/module/pandoc-mediabag.lua
+++ /dev/null
@@ -1,72 +0,0 @@
-local tasty = require 'tasty'
-
-local test = tasty.test_case
-local group = tasty.test_group
-local assert = tasty.assert
-
-local mediabag = require 'pandoc.mediabag'
-
-return {
- group 'insert' {
- test('insert adds an item to the mediabag', function ()
- local fp = "media/hello.txt"
- local mt = "text/plain"
- local contents = "Hello, World!"
- assert.are_same(mediabag.list(), {})
- mediabag.insert(fp, mt, contents)
- assert.are_same(
- mediabag.list(),
- {{['path'] = fp, ['type'] = mt, ['length'] = 13}}
- )
- mediabag.empty() -- clean up
- end),
- test('is idempotent', function ()
- local fp = "media/hello.txt"
- local mt = "text/plain"
- local contents = "Hello, World!"
- mediabag.insert(fp, mt, contents)
- mediabag.insert(fp, mt, contents)
- assert.are_same(
- mediabag.list(),
- {{['path'] = fp, ['type'] = mt, ['length'] = 13}}
- )
- mediabag.empty() -- clean up
- end),
- },
-
- group 'delete' {
- test('removes an item', function ()
- assert.are_same(mediabag.list(), {})
- mediabag.insert('test.html', 'text/html', '<aside>Who cares?</aside>')
- mediabag.insert('test.css', 'text/plain', 'aside { color: red; }')
- assert.are_equal(#mediabag.list(), 2)
- mediabag.delete('test.html')
- assert.are_same(
- mediabag.list(),
- {{['path'] = 'test.css', ['type'] = 'text/plain', ['length'] = 21}}
- )
- mediabag.empty() -- clean up
- end),
- },
-
- group 'items' {
- test('iterates over all items', function ()
- local input_items = {
- ['test.html'] = {'text/html', '<aside>Really?</aside>'},
- ['test.css'] = {'text/plain', 'aside { color: red; }'},
- ['test.js'] = {'application/javascript', 'alert("HI MOM!")'}
- }
- -- fill mediabag
- for name, v in pairs(input_items) do
- mediabag.insert(name, v[1], v[2])
- end
-
- local seen_items = {}
- for fp, mt, c in mediabag.items() do
- seen_items[fp] = {mt, c}
- end
- assert.are_same(seen_items, input_items)
- mediabag.empty() -- clean up
- end)
- }
-}
diff --git a/test/lua/module/pandoc-path.lua b/test/lua/module/pandoc-path.lua
deleted file mode 100644
index 81c11e7b7..000000000
--- a/test/lua/module/pandoc-path.lua
+++ /dev/null
@@ -1,44 +0,0 @@
-local tasty = require 'tasty'
-local path = require 'pandoc.path'
-
-local assert = tasty.assert
-local test = tasty.test_case
-local group = tasty.test_group
-
-return {
- group 'path separator' {
- test('is string', function ()
- assert.are_same(type(path.separator), 'string')
- end),
- test('is slash or backslash', function ()
- assert.is_truthy(path.separator:match '^[/\\]$')
- end),
- },
- group 'search path separator' {
- test('is string', function ()
- assert.are_same(type(path.search_path_separator), 'string')
- end),
- test('is colon or semicolon', function ()
- assert.is_truthy(path.search_path_separator:match '^[:;]$')
- end)
- },
- group 'module' {
- test('check function existence', function ()
- local functions = {
- 'directory',
- 'filename',
- 'is_absolute',
- 'is_relative',
- 'join',
- 'make_relative',
- 'normalize',
- 'split',
- 'split_extension',
- 'split_search_path',
- }
- for _, f in ipairs(functions) do
- assert.are_equal(type(path[f]), 'function')
- end
- end)
- }
-}
diff --git a/test/lua/module/pandoc-template.lua b/test/lua/module/pandoc-template.lua
deleted file mode 100644
index c288b2016..000000000
--- a/test/lua/module/pandoc-template.lua
+++ /dev/null
@@ -1,65 +0,0 @@
-local tasty = require 'tasty'
-local template = require 'pandoc.template'
-
-local assert = tasty.assert
-local test = tasty.test_case
-local group = tasty.test_group
-
-return {
- test('is table', function ()
- assert.are_equal(type(template), 'table')
- end),
- group 'default' {
- test('is function', function ()
- assert.are_equal(type(template.default), 'function')
- end),
- test('returns a string for known format', function ()
- assert.are_equal(
- pandoc.utils.type(template.default 'json'),
- 'string'
- )
- assert.are_equal(
- pandoc.utils.type(template.default 'markdown'),
- 'string'
- )
- end),
- test('fails on unknown format', function ()
- local success, msg = pcall(function ()
- return pandoc.utils.type(template.default 'nosuchformat')
- end)
- assert.is_falsy(success)
- end),
- },
- group 'compile' {
- test('is function', function ()
- assert.are_equal(type(template.compile), 'function')
- end),
- test('returns a Template', function ()
- assert.are_equal(
- pandoc.utils.type(template.compile('$title$')),
- 'pandoc Template'
- )
- end),
- test('returns a Template', function ()
- local templ_path = pandoc.path.join{'lua', 'module', 'default.test'}
- assert.are_equal(
- pandoc.utils.type(template.compile('${ partial() }', templ_path)),
- 'pandoc Template'
- )
- end),
- test('fails if template has non-existing partial', function ()
- assert.error_matches(
- function () return template.compile('${ nosuchpartial() }') end,
- 'PandocCouldNotFindDataFileError'
- )
- end),
- test('works with default template that uses partials', function ()
- local jats_template = template.default 'jats'
- assert.are_equal(type(jats_template), 'string')
- assert.are_equal(
- pandoc.utils.type(template.compile(jats_template)),
- 'pandoc Template'
- )
- end),
- },
-}
diff --git a/test/lua/module/pandoc-types.lua b/test/lua/module/pandoc-types.lua
deleted file mode 100644
index d9c9f82ac..000000000
--- a/test/lua/module/pandoc-types.lua
+++ /dev/null
@@ -1,86 +0,0 @@
-local tasty = require 'tasty'
-local types = require 'pandoc.types'
-local Version = types.Version
-
-local assert = tasty.assert
-local test = tasty.test_case
-local group = tasty.test_group
-
-return {
- group 'Version' {
-
- group 'constructor' {
- test('has type `userdata`', function ()
- assert.are_same(type(Version {2}), 'userdata')
- end),
- test('accepts list of integers', function ()
- assert.are_same(type(Version {2, 7, 3}), 'userdata')
- end),
- test('accepts a single integer', function ()
- assert.are_same(Version(5), Version {5})
- end),
- test('accepts version as string', function ()
- assert.are_same(
- Version '4.45.1',
- Version {4, 45, 1}
- )
- end),
- test('non-version string is rejected', function ()
- local success, msg = pcall(function () Version '11friends' end)
- assert.is_falsy(success)
- assert.is_truthy(tostring(msg):match('11friends'))
- end)
- },
-
- group 'comparison' {
- test('smaller (equal) than', function ()
- assert.is_truthy(Version {2, 58, 3} < Version {2, 58, 4})
- assert.is_falsy(Version {2, 60, 1} < Version {2, 59, 2})
- assert.is_truthy(Version {0, 14, 3} < Version {0, 14, 3, 1})
- assert.is_truthy(Version {3, 58, 3} <= Version {4})
- assert.is_truthy(Version {0, 14, 3} <= Version {0, 14, 3, 1})
- end),
- test('larger (equal) than', function ()
- assert.is_truthy(Version{2,58,3} > Version {2, 57, 4})
- assert.is_truthy(Version{2,58,3} > Version {2, 58, 2})
- assert.is_truthy(Version {0, 8} >= Version {0, 8})
- assert.is_falsy(Version {0, 8} >= Version {0, 8, 2})
- end),
- test('equality', function ()
- assert.is_truthy(Version '8.8', Version {8, 8})
- end),
- test('second argument can be a version string', function ()
- assert.is_truthy(Version '8' < '9.1')
- assert.is_falsy(Version '8.8' < '8.7')
- end),
- },
-
- group 'conversion to string' {
- test('converting from and to string is a noop', function ()
- local version_string = '1.19.4'
- assert.are_equal(tostring(Version(version_string)), version_string)
- end)
- },
-
- group 'convenience functions' {
- test('throws error if version is too old', function ()
- local actual = Version {2, 8}
- local expected = Version {2, 9}
- assert.error_matches(
- function () actual:must_be_at_least(expected) end,
- 'expected version 2.9 or newer, got 2.8'
- )
- end),
- test('does nothing if expected version is older than actual', function ()
- local actual = Version '2.9'
- local expected = Version '2.8'
- actual:must_be_at_least(expected)
- end),
- test('does nothing if expected version equals to actual', function ()
- local actual = Version '2.8'
- local expected = Version '2.8'
- actual:must_be_at_least(expected)
- end)
- }
- }
-}
diff --git a/test/lua/module/pandoc-utils.lua b/test/lua/module/pandoc-utils.lua
deleted file mode 100644
index 4cf2c84a7..000000000
--- a/test/lua/module/pandoc-utils.lua
+++ /dev/null
@@ -1,333 +0,0 @@
-local tasty = require 'tasty'
-local utils = require 'pandoc.utils'
-
-local assert = tasty.assert
-local test = tasty.test_case
-local group = tasty.test_group
-
-return {
- group 'blocks_to_inlines' {
- test('default separator', function ()
- local blocks = {
- pandoc.Para { pandoc.Str 'Paragraph1' },
- pandoc.Para { pandoc.Emph { pandoc.Str 'Paragraph2' } }
- }
- local expected = {
- pandoc.Str 'Paragraph1',
- pandoc.Space(), pandoc.Str '¶', pandoc.Space(),
- pandoc.Emph { pandoc.Str 'Paragraph2' }
- }
- assert.are_same(
- expected,
- utils.blocks_to_inlines(blocks)
- )
- end),
- test('custom separator', function ()
- local blocks = {
- pandoc.Para{ pandoc.Str 'Paragraph1' },
- pandoc.Para{ pandoc.Emph 'Paragraph2' }
- }
- local expected = {
- pandoc.Str 'Paragraph1',
- pandoc.LineBreak(),
- pandoc.Emph { pandoc.Str 'Paragraph2' }
- }
- assert.are_same(
- expected,
- utils.blocks_to_inlines(blocks, { pandoc.LineBreak() })
- )
- end)
- },
-
- group 'equals' {
- test('compares Pandoc elements', function ()
- assert.is_truthy(
- utils.equals(pandoc.Pandoc{'foo'}, pandoc.Pandoc{'foo'})
- )
- end),
- test('compares Block elements', function ()
- assert.is_truthy(
- utils.equals(pandoc.Plain{'foo'}, pandoc.Plain{'foo'})
- )
- assert.is_falsy(
- utils.equals(pandoc.Para{'foo'}, pandoc.Plain{'foo'})
- )
- end),
- test('compares Inline elements', function ()
- assert.is_truthy(
- utils.equals(pandoc.Emph{'foo'}, pandoc.Emph{'foo'})
- )
- assert.is_falsy(
- utils.equals(pandoc.Emph{'foo'}, pandoc.Strong{'foo'})
- )
- end),
- test('compares Inline with Block elements', function ()
- assert.is_falsy(
- utils.equals(pandoc.Emph{'foo'}, pandoc.Plain{'foo'})
- )
- assert.is_falsy(
- utils.equals(pandoc.Para{'foo'}, pandoc.Strong{'foo'})
- )
- end),
- test('compares Pandoc with Block elements', function ()
- assert.is_falsy(
- utils.equals(pandoc.Pandoc{'foo'}, pandoc.Plain{'foo'})
- )
- assert.is_falsy(
- utils.equals(pandoc.Para{'foo'}, pandoc.Pandoc{'foo'})
- )
- end),
- },
-
- group 'make_sections' {
- test('sanity check', function ()
- local blks = {
- pandoc.Header(1, {pandoc.Str 'First'}),
- pandoc.Header(2, {pandoc.Str 'Second'}),
- pandoc.Header(2, {pandoc.Str 'Third'}),
- }
- local hblks = utils.make_sections(true, 1, blks)
- assert.are_equal('Div', hblks[1].t)
- assert.are_equal('Header', hblks[1].content[1].t)
- assert.are_equal('1', hblks[1].content[1].attributes['number'])
- end)
- },
-
- group 'normalize_date' {
- test('09 Nov 1989', function ()
- assert.are_equal('1989-11-09', utils.normalize_date '09 Nov 1989')
- end),
- test('12/31/2017', function ()
- assert.are_equal('2017-12-31', utils.normalize_date '12/31/2017')
- end),
- },
-
- group 'references' {
- test('gets references from doc', function ()
- local ref = {
- ['author'] = {
- {given = 'Max', family = 'Mustermann'}
- },
- ['container-title'] = pandoc.Inlines('JOSS'),
- ['id'] = 'test',
- ['issued'] = {['date-parts'] = {{2021}}},
- ['title'] = pandoc.Inlines{
- pandoc.Quoted('DoubleQuote', 'Interesting'),
- pandoc.Space(),
- 'work'
- },
- ['type'] = 'article-journal',
- }
- local nocite = pandoc.Cite(
- '@test',
- {pandoc.Citation('test', 'NormalCitation')}
- )
- local doc = pandoc.Pandoc({}, {nocite = nocite, references = {ref}})
- assert.are_same({ref}, pandoc.utils.references(doc))
- end)
- },
-
- group 'sha1' {
- test('hashing', function ()
- local ref_hash = '0a0a9f2a6772942557ab5355d76af442f8f65e01'
- assert.are_equal(ref_hash, utils.sha1 'Hello, World!')
- end)
- },
-
- group 'stringify' {
- test('Inline', function ()
- local inline = pandoc.Emph{
- pandoc.Str 'Cogito',
- pandoc.Space(),
- pandoc.Str 'ergo',
- pandoc.Space(),
- pandoc.Str 'sum.',
- }
- assert.are_equal('Cogito ergo sum.', utils.stringify(inline))
- 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 'funny and ',
- b = 'good movie',
- c = pandoc.List{pandoc.Inlines{pandoc.Str '!'}}
- }
- assert.are_equal('funny and good movie!', utils.stringify(meta))
- end),
- },
-
- group 'to_roman_numeral' {
- test('convertes number', function ()
- assert.are_equal('MDCCCLXXXVIII', utils.to_roman_numeral(1888))
- end),
- test('fails on non-convertible argument', function ()
- assert.is_falsy(pcall(utils.to_roman_numeral, 'not a number'))
- end)
- },
-
- group 'type' {
- test('nil', function ()
- assert.are_equal(utils.type(nil), 'nil')
- end),
- test('boolean', function ()
- assert.are_equal(utils.type(true), 'boolean')
- assert.are_equal(utils.type(false), 'boolean')
- end),
- test('number', function ()
- assert.are_equal(utils.type(5), 'number')
- assert.are_equal(utils.type(-3.02), 'number')
- end),
- test('string', function ()
- assert.are_equal(utils.type(''), 'string')
- assert.are_equal(utils.type('asdf'), 'string')
- end),
- test('plain table', function ()
- assert.are_equal(utils.type({}), 'table')
- end),
- test('List', function ()
- assert.are_equal(utils.type(pandoc.List{}), 'List')
- end),
- test('Inline', function ()
- assert.are_equal(utils.type(pandoc.Str 'a'), 'Inline')
- assert.are_equal(utils.type(pandoc.Emph 'emphasized'), 'Inline')
- end),
- test('Inlines', function ()
- assert.are_equal(utils.type(pandoc.Inlines{pandoc.Str 'a'}), 'Inlines')
- assert.are_equal(utils.type(pandoc.Inlines{pandoc.Emph 'b'}), 'Inlines')
- end),
- test('Blocks', function ()
- assert.are_equal(utils.type(pandoc.Para 'a'), 'Block')
- assert.are_equal(utils.type(pandoc.CodeBlock 'true'), 'Block')
- end),
- test('Inlines', function ()
- assert.are_equal(utils.type(pandoc.Blocks{'a'}), 'Blocks')
- assert.are_equal(utils.type(pandoc.Blocks{pandoc.CodeBlock 'b'}), 'Blocks')
- end),
- },
-
- group 'to_simple_table' {
- test('convertes Table', function ()
- function simple_cell (blocks)
- return {
- attr = pandoc.Attr(),
- alignment = "AlignDefault",
- contents = blocks,
- col_span = 1,
- row_span = 1,
- }
- end
- local tbl = pandoc.Table(
- {long = {pandoc.Plain {
- pandoc.Str "the", pandoc.Space(), pandoc.Str "caption"}}},
- {{pandoc.AlignDefault, nil}},
- pandoc.TableHead{pandoc.Row{simple_cell{pandoc.Plain "head1"}}},
- {{
- attr = pandoc.Attr(),
- body = {pandoc.Row{simple_cell{pandoc.Plain "cell1"}}},
- head = {},
- row_head_columns = 0
- }},
- pandoc.TableFoot(),
- pandoc.Attr()
- )
- local stbl = utils.to_simple_table(tbl)
- assert.are_equal('SimpleTable', stbl.t)
- assert.are_equal('head1', utils.stringify(stbl.headers[1]))
- assert.are_equal('cell1', utils.stringify(stbl.rows[1][1]))
- assert.are_equal('the caption', utils.stringify(pandoc.Span(stbl.caption)))
- end),
- test('fails on para', function ()
- assert.is_falsy(pcall(utils.to_simple_table, pandoc.Para "nope"))
- end),
- },
- group 'from_simple_table' {
- test('converts SimpleTable to Table', function ()
- local caption = {pandoc.Str "Overview"}
- local aligns = {pandoc.AlignDefault, pandoc.AlignDefault}
- local widths = {0, 0} -- let pandoc determine col widths
- local headers = {
- {pandoc.Plain "Language"},
- {pandoc.Plain "Typing"}
- }
- local rows = {
- {{pandoc.Plain "Haskell"}, {pandoc.Plain "static"}},
- {{pandoc.Plain "Lua"}, {pandoc.Plain "Dynamic"}},
- }
- local simple_table = pandoc.SimpleTable(
- caption,
- aligns,
- widths,
- headers,
- rows
- )
- local tbl = utils.from_simple_table(simple_table)
- assert.are_equal("Table", tbl.t)
- assert.are_same(
- {pandoc.Plain(caption)},
- tbl.caption.long
- )
- -- reversible
- assert.are_same(simple_table, utils.to_simple_table(tbl))
- end),
- test('empty caption', function ()
- local simple_table = pandoc.SimpleTable(
- {},
- {pandoc.AlignDefault},
- {0},
- {{pandoc.Plain 'a'}},
- {{{pandoc.Plain 'b'}}}
- )
- local tbl = utils.from_simple_table(simple_table)
- assert.are_equal(
- pandoc.Blocks{},
- tbl.caption.long
- )
- assert.is_nil(tbl.caption.short)
- end),
- test('empty body', function ()
- local simple_table = pandoc.SimpleTable(
- pandoc.Inlines('a nice caption'),
- {pandoc.AlignDefault},
- {0},
- {{pandoc.Plain 'a'}},
- {}
- )
- local tbl = utils.from_simple_table(simple_table)
- tbl.bodies:map(print)
- assert.are_same(pandoc.List(), tbl.bodies)
- end),
- }
-}
diff --git a/test/lua/module/pandoc.lua b/test/lua/module/pandoc.lua
deleted file mode 100644
index 397182438..000000000
--- a/test/lua/module/pandoc.lua
+++ /dev/null
@@ -1,356 +0,0 @@
-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
-
--- Constructor behavior is tested in the hslua-pandoc-types module, so
--- we just make sure the functions are present.
-return {
- group 'Constructors' {
- group 'Misc' {
- test('pandoc.Attr is a function', function ()
- assert.are_equal(type(pandoc.Attr), 'function')
- end),
- test('pandoc.AttributeList is a function', function ()
- assert.are_equal(type(pandoc.AttributeList), 'function')
- end),
- test('pandoc.Blocks is a function', function ()
- assert.are_equal(type(pandoc.Blocks), 'function')
- end),
- test('pandoc.Citation is a function', function ()
- assert.are_equal(type(pandoc.Citation), 'function')
- end),
- test('pandoc.Inlines is a function', function ()
- assert.are_equal(type(pandoc.Inlines), 'function')
- end),
- test('pandoc.SimpleTable is a function', function ()
- assert.are_equal(type(pandoc.SimpleTable), 'function')
- end),
- test('pandoc.Meta is a function', function ()
- assert.are_equal(type(pandoc.Meta), 'function')
- end),
- test('pandoc.Pandoc is a function', function ()
- assert.are_equal(type(pandoc.Pandoc), 'function')
- end),
- },
- group "Inline elements" {
- test('pandoc.AttributeList is a function', function ()
- assert.are_equal(type(pandoc.Cite), 'function')
- end),
- test('pandoc.AttributeList is a function', function ()
- assert.are_equal(type(pandoc.Code), 'function')
- end),
- test('pandoc.Emph is a function', function ()
- assert.are_equal(type(pandoc.Emph), 'function')
- end),
- test('pandoc.Image is a function', function ()
- assert.are_equal(type(pandoc.Image), 'function')
- end),
- test('pandoc.Link is a function', function ()
- assert.are_equal(type(pandoc.Link), 'function')
- end),
- test('pandoc.Math is a function', function ()
- assert.are_equal(type(pandoc.Math), 'function')
- end),
- test('pandoc.Note is a function', function ()
- assert.are_equal(type(pandoc.Note), 'function')
- end),
- test('pandoc.Quoted is a function', function ()
- assert.are_equal(type(pandoc.Quoted), 'function')
- end),
- test('pandoc.SmallCaps is a function', function ()
- assert.are_equal(type(pandoc.SmallCaps), 'function')
- end),
- test('pandoc.SoftBreak is a function', function ()
- assert.are_equal(type(pandoc.SoftBreak), 'function')
- end),
- test('pandoc.Span is a function', function ()
- assert.are_equal(type(pandoc.Span), 'function')
- end),
- test('pandoc.Str is a function', function ()
- assert.are_equal(type(pandoc.Str), 'function')
- end),
- test('pandoc.Strikeout is a function', function ()
- assert.are_equal(type(pandoc.Strikeout), 'function')
- end),
- test('pandoc.Strong is a function', function ()
- assert.are_equal(type(pandoc.Strong), 'function')
- end),
- test('pandoc.Subscript is a function', function ()
- assert.are_equal(type(pandoc.Subscript), 'function')
- end),
- test('pandoc.Superscript is a function', function ()
- assert.are_equal(type(pandoc.Superscript), 'function')
- end),
- test('pandoc.Underline is a function', function ()
- assert.are_equal(type(pandoc.Underline), 'function')
- end),
- },
- group "Block elements" {
- test('pandoc.BlockQuote is a function', function ()
- assert.are_equal(type(pandoc.BlockQuote), 'function')
- end),
- test('pandoc.BulletList is a function', function ()
- assert.are_equal(type(pandoc.BulletList), 'function')
- end),
- test('pandoc.CodeBlock is a function', function ()
- assert.are_equal(type(pandoc.CodeBlock), 'function')
- end),
- test('pandoc.DefinitionList is a function', function ()
- assert.are_equal(type(pandoc.DefinitionList), 'function')
- end),
- test('pandoc.Div is a function', function ()
- assert.are_equal(type(pandoc.Div), 'function')
- end),
- test('pandoc.Header is a function', function ()
- assert.are_equal(type(pandoc.Header), 'function')
- end),
- test('pandoc.LineBlock is a function', function ()
- assert.are_equal(type(pandoc.LineBlock), 'function')
- end),
- test('pandoc.Null is a function', function ()
- assert.are_equal(type(pandoc.Null), 'function')
- end),
- test('pandoc.OrderedList is a function', function ()
- assert.are_equal(type(pandoc.OrderedList), 'function')
- end),
- test('pandoc.Para is a function', function ()
- assert.are_equal(type(pandoc.Para), 'function')
- end),
- test('pandoc.Plain is a function', function ()
- assert.are_equal(type(pandoc.Plain), 'function')
- end),
- test('pandoc.RawBlock is a function', function ()
- assert.are_equal(type(pandoc.Plain), 'function')
- end),
- test('pandoc.Table is a function', function ()
- assert.are_equal(type(pandoc.Table), 'function')
- end),
- }
- },
- group 'MetaValue elements' {
- test('MetaList elements behave like lists', function ()
- local metalist = pandoc.MetaList{}
- assert.are_equal(type(metalist.insert), 'function')
- assert.are_equal(type(metalist.remove), 'function')
- end),
- test('`tag` is an alias for `t``', function ()
- assert.are_equal((pandoc.MetaList{}).tag, (pandoc.MetaList{}).t)
- assert.are_equal((pandoc.MetaMap{}).tag, (pandoc.MetaMap{}).t)
- assert.are_equal((pandoc.MetaInlines{}).tag, (pandoc.MetaInlines{}).t)
- assert.are_equal((pandoc.MetaBlocks{}).tag, (pandoc.MetaBlocks{}).t)
- end),
- },
- group 'Meta' {
- test('inline list is treated as MetaInlines', function ()
- local meta = pandoc.Pandoc({}, {test = {pandoc.Emph 'check'}}).meta
- assert.are_same(meta.test, {pandoc.Emph{pandoc.Str 'check'}})
- end),
- test('inline element is treated as MetaInlines singleton', function ()
- local meta = pandoc.Pandoc({}, {test = pandoc.Emph 'check'}).meta
- assert.are_same(meta.test, {pandoc.Emph{pandoc.Str 'check'}})
- end),
- test('block list is treated as MetaBlocks', function ()
- local meta = pandoc.Pandoc({}, {test = {pandoc.Plain 'check'}}).meta
- assert.are_same(meta.test, {pandoc.Plain{pandoc.Str 'check'}})
- end),
- test('block element is treated as MetaBlocks singleton', function ()
- local meta = pandoc.Pandoc({}, {test = pandoc.Plain 'check'}).meta
- assert.are_same(meta.test, {pandoc.Plain{pandoc.Str 'check'}})
- end),
- },
- group 'Other types' {
- group 'ReaderOptions' {
- test('returns a userdata value', function ()
- local opts = pandoc.ReaderOptions {}
- assert.are_equal(type(opts), 'userdata')
- end),
- test('can construct from table', function ()
- local opts = pandoc.ReaderOptions {columns = 66}
- assert.are_equal(opts.columns, 66)
- end),
- test('can construct from other ReaderOptions value', function ()
- local orig = pandoc.ReaderOptions{columns = 65}
- local copy = pandoc.ReaderOptions(orig)
- for k, v in pairs(orig) do
- assert.are_same(copy[k], v)
- end
- assert.are_equal(copy.columns, 65)
- 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')
- assert.are_same(cite.id, 'newton')
- assert.are_same(cite.mode, cloned.mode)
- end),
- },
-
- group 'pipe' {
- test('external string processing', function ()
- if os_is_windows() then
- local pipe_result = pandoc.pipe('find', {'hi'}, 'hi')
- assert.are_equal('hi', pipe_result:match '%a+')
- else
- local pipe_result = pandoc.pipe('tr', {'a', 'b'}, 'abc')
- assert.are_equal('bbc', pipe_result:match '%a+')
- end
- end),
- test('failing pipe', function ()
- if os_is_windows() then
- local success, err = pcall(pandoc.pipe, 'find', {'/a'}, 'hi')
- assert.is_falsy(success)
- assert.are_equal('find', err.command)
- assert.is_truthy(err.error_code ~= 0)
- else
- local success, err = pcall(pandoc.pipe, 'false', {}, 'abc')
- assert.is_falsy(success)
- assert.are_equal('false', err.command)
- assert.are_equal(1, err.error_code)
- assert.are_equal('', err.output)
- end
- end)
- },
-
- group 'read' {
- test('Markdown', function ()
- local valid_markdown = '*Hello*, World!\n'
- local expected = pandoc.Pandoc({
- pandoc.Para {
- pandoc.Emph { pandoc.Str 'Hello' },
- pandoc.Str ',',
- pandoc.Space(),
- pandoc.Str 'World!'
- }
- })
- assert.are_same(expected, pandoc.read(valid_markdown))
- end),
- test('unsupported extension', function ()
- assert.error_matches(
- function () pandoc.read('foo', 'gfm+empty_paragraphs') end,
- 'Extension empty_paragraphs not supported for gfm'
- )
- end),
- test('read with other indented code classes', function()
- local indented_code = ' return true'
- local expected = pandoc.Pandoc({
- pandoc.CodeBlock('return true', {class='foo'})
- })
- assert.are_same(
- expected,
- pandoc.read(indented_code, 'markdown', {indented_code_classes={'foo'}})
- )
- end),
- test('can read epub', function ()
- local epub = io.open('lua/module/tiny.epub', 'rb')
- local blocks = pandoc.read(epub:read'a', 'epub').blocks
- assert.are_equal(
- blocks[#blocks],
- pandoc.Para { pandoc.Emph 'EPUB' }
- )
- end),
- test('failing read', function ()
- assert.error_matches(
- function () pandoc.read('foo', 'nosuchreader') end,
- 'Unknown reader: nosuchreader'
- )
- end)
- },
-
- group 'walk_block' {
- test('block walking order', function ()
- local acc = {}
- local nested_nums = pandoc.Div {
- pandoc.Para{pandoc.Str'1'},
- pandoc.Div{
- pandoc.Para{pandoc.Str'2'},
- pandoc.Para{pandoc.Str'3'}
- },
- pandoc.Para{pandoc.Str'4'}
- }
- pandoc.walk_block(
- nested_nums,
- {Para = function (p) table.insert(acc, p.content[1].text) end}
- )
- assert.are_equal('1234', table.concat(acc))
- end)
- },
-
- group 'walk_inline' {
- test('inline walking order', function ()
- local acc = {}
- local nested_nums = pandoc.Span {
- pandoc.Str'1',
- pandoc.Emph {
- pandoc.Str'2',
- pandoc.Str'3'
- },
- pandoc.Str'4'
- }
- pandoc.walk_inline(
- nested_nums,
- {Str = function (s) table.insert(acc, s.text) end}
- )
- assert.are_equal('1234', table.concat(acc))
- end)
- },
-
- group 'Marshal' {
- group 'Inlines' {
- test('Strings are broken into words', function ()
- assert.are_equal(
- pandoc.Emph 'Nice, init?',
- pandoc.Emph{pandoc.Str 'Nice,', pandoc.Space(), pandoc.Str 'init?'}
- )
- end)
- },
- group 'Blocks' {
- test('Strings are broken into words and wrapped in Plain', function ()
- assert.are_equal(
- pandoc.Div{
- pandoc.Plain{pandoc.Str 'Nice,', pandoc.Space(), pandoc.Str 'init?'}
- },
- pandoc.Div{'Nice, init?'}
- )
- end)
- }
- }
-}
diff --git a/test/lua/module/partial.test b/test/lua/module/partial.test
deleted file mode 100644
index e69de29bb..000000000
--- a/test/lua/module/partial.test
+++ /dev/null
diff --git a/test/lua/module/tiny.epub b/test/lua/module/tiny.epub
deleted file mode 100644
index 9e92202b7..000000000
--- a/test/lua/module/tiny.epub
+++ /dev/null
Binary files differ
diff --git a/test/lua/plain-to-para.lua b/test/lua/plain-to-para.lua
deleted file mode 100644
index aa12a97d3..000000000
--- a/test/lua/plain-to-para.lua
+++ /dev/null
@@ -1,6 +0,0 @@
-return {
- { Plain = function (elem)
- return pandoc.Para(elem.content)
- end,
- }
-}
diff --git a/test/lua/require-file.lua b/test/lua/require-file.lua
deleted file mode 100644
index d610e5266..000000000
--- a/test/lua/require-file.lua
+++ /dev/null
@@ -1,2 +0,0 @@
-package.path = package.path .. ';lua/?.lua'
-require 'script-name'
diff --git a/test/lua/script-name.lua b/test/lua/script-name.lua
deleted file mode 100644
index 4b5a223f0..000000000
--- a/test/lua/script-name.lua
+++ /dev/null
@@ -1,3 +0,0 @@
-function Para (_)
- return pandoc.Para{pandoc.Str(PANDOC_SCRIPT_FILE)}
-end
diff --git a/test/lua/single-to-double-quoted.lua b/test/lua/single-to-double-quoted.lua
deleted file mode 100644
index b985b215c..000000000
--- a/test/lua/single-to-double-quoted.lua
+++ /dev/null
@@ -1,10 +0,0 @@
-return {
- {
- Quoted = function (elem)
- if elem.quotetype == "SingleQuote" then
- elem.quotetype = "DoubleQuote"
- end
- return elem
- end,
- }
-}
diff --git a/test/lua/smallcaps-title.lua b/test/lua/smallcaps-title.lua
deleted file mode 100644
index b839ee131..000000000
--- a/test/lua/smallcaps-title.lua
+++ /dev/null
@@ -1,12 +0,0 @@
-return {
- {
- Meta = function(meta)
- -- The call to `MetaInlines` is redundant and used for testing purposes
- -- only. The explicit use of a MetaValue constructor is only useful when
- -- used with an empty table: `MetaInlines{}` is read differently than
- -- `MetaBlocks{}`.
- meta.title = pandoc.MetaInlines{pandoc.SmallCaps(meta.title)}
- return meta
- end
- }
-}
diff --git a/test/lua/smart-constructors.lua b/test/lua/smart-constructors.lua
deleted file mode 100644
index 6e579a12f..000000000
--- a/test/lua/smart-constructors.lua
+++ /dev/null
@@ -1,10 +0,0 @@
--- Test that constructors are "smart" in that they autoconvert
--- types where sensible.
-function Para (_)
- return {
- pandoc.BulletList{pandoc.Para "Hello", pandoc.Para "World"},
- pandoc.DefinitionList{{"foo", pandoc.Para "placeholder"}},
- pandoc.LineBlock{"Moin", "Welt"},
- pandoc.OrderedList{pandoc.Plain{pandoc.Str "one"}, pandoc.Plain "two"}
- }
-end
diff --git a/test/lua/strmacro.lua b/test/lua/strmacro.lua
deleted file mode 100644
index a2711798a..000000000
--- a/test/lua/strmacro.lua
+++ /dev/null
@@ -1,11 +0,0 @@
-return {
- {
- Str = function (elem)
- if elem.text == "{{helloworld}}" then
- return pandoc.Emph {pandoc.Str "Hello, World"}
- else
- return elem
- end
- end,
- }
-}
diff --git a/test/lua/undiv.lua b/test/lua/undiv.lua
deleted file mode 100644
index 1cbb6d30e..000000000
--- a/test/lua/undiv.lua
+++ /dev/null
@@ -1,3 +0,0 @@
-function Div(el)
- return el.content
-end
diff --git a/test/lua/uppercase-header.lua b/test/lua/uppercase-header.lua
deleted file mode 100644
index 8e86911c0..000000000
--- a/test/lua/uppercase-header.lua
+++ /dev/null
@@ -1,9 +0,0 @@
-local text = require 'text'
-
-local function str_to_uppercase (s)
- return pandoc.Str(text.upper(s.text))
-end
-
-function Header (el)
- return pandoc.walk_block(el, {Str = str_to_uppercase})
-end