diff options
| author | Albert Krewinkel <[email protected]> | 2023-03-20 13:58:09 +0100 |
|---|---|---|
| committer | Albert Krewinkel <[email protected]> | 2023-03-20 16:06:18 +0100 |
| commit | ed5197f5258fa52de7676980799ddc47fa4f2278 (patch) | |
| tree | 1974f49d075f343527c934089d9fabe940da63d5 /pandoc-lua-engine/test | |
| parent | 5af2d70b0da46e74672a9089c51b9ad5d883d6ef (diff) | |
Lua: load text module as `pandoc.text`.
This only affects the name in the Lua-internal documentation. It is
still possible to load the modules via `require 'text'`, although this
is deprecated.
Diffstat (limited to 'pandoc-lua-engine/test')
| -rw-r--r-- | pandoc-lua-engine/test/Tests/Lua/Module.hs | 2 | ||||
| -rw-r--r-- | pandoc-lua-engine/test/lua/module/pandoc-text.lua | 51 |
2 files changed, 53 insertions, 0 deletions
diff --git a/pandoc-lua-engine/test/Tests/Lua/Module.hs b/pandoc-lua-engine/test/Tests/Lua/Module.hs index 08a4343d7..e3556f2cd 100644 --- a/pandoc-lua-engine/test/Tests/Lua/Module.hs +++ b/pandoc-lua-engine/test/Tests/Lua/Module.hs @@ -35,6 +35,8 @@ tests = ("lua" </> "module" </> "pandoc-structure.lua") , testPandocLua "pandoc.template" ("lua" </> "module" </> "pandoc-template.lua") + , testPandocLua "pandoc.text" + ("lua" </> "module" </> "pandoc-text.lua") , testPandocLua "pandoc.types" ("lua" </> "module" </> "pandoc-types.lua") , testPandocLua "pandoc.utils" diff --git a/pandoc-lua-engine/test/lua/module/pandoc-text.lua b/pandoc-lua-engine/test/lua/module/pandoc-text.lua new file mode 100644 index 000000000..71a06c917 --- /dev/null +++ b/pandoc-lua-engine/test/lua/module/pandoc-text.lua @@ -0,0 +1,51 @@ +-- +-- Tests for the pandoc.text module +-- +local text = require 'pandoc.text' +local tasty = require 'tasty' + +local group = tasty.test_group +local test = tasty.test_case +local assert = tasty.assert + +assert.is_function = function (x) + assert.are_equal(type(x), 'function') +end +-- We rely mostly on the tests in the `hslua-module-text` module. The +-- only thing we need to test is whether `pandoc.text` is available, +-- whether all functions are defined, and whether `require 'text'` works +-- (for backwards compatibility). +return { + group 'module' { + test('is table', function () + assert.are_equal(type(text), 'table') + end), + test('can be required as "text"', function () + assert.are_equal(require 'text', require 'pandoc.text') + end) + }, + + group 'functions' { + test('fromencoding', function () + assert.is_function(text.fromencoding) + end), + test('len', function () + assert.is_function(text.len) + end), + test('lower', function () + assert.is_function(text.lower) + end), + test('reverse', function () + assert.is_function(text.reverse) + end), + test('sub', function () + assert.is_function(text.sub) + end), + test('toencoding', function () + assert.is_function(text.toencoding) + end), + test('upper', function () + assert.is_function(text.upper) + end), + }, +} |
