aboutsummaryrefslogtreecommitdiff
path: root/test/lua
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2017-12-23 13:35:27 +0100
committerAlbert Krewinkel <albert@zeitkraut.de>2017-12-23 13:43:22 +0100
commit2c66a42ab81d40e771eda0f054c62f22ad45f3d0 (patch)
treede174a57e5cfc34dd85a1ae5304c302f1da1dbff /test/lua
parent35f0567a8fe840ca65f8474d0293942c76a1220f (diff)
downloadpandoc-2c66a42ab81d40e771eda0f054c62f22ad45f3d0.tar.gz
Lua modules: add function pandoc.utils.normalize_date
The function parses a date and converts it (if possible) to "YYYY-MM-DD" format.
Diffstat (limited to 'test/lua')
-rw-r--r--test/lua/test-pandoc-utils.lua10
1 files changed, 9 insertions, 1 deletions
diff --git a/test/lua/test-pandoc-utils.lua b/test/lua/test-pandoc-utils.lua
index 0a7aedbfd..b79f033f8 100644
--- a/test/lua/test-pandoc-utils.lua
+++ b/test/lua/test-pandoc-utils.lua
@@ -72,6 +72,13 @@ function test_to_roman_numeral ()
and not pcall(utils.to_roman_numeral, 'not a number')
end
+-- normalize_date
+------------------------------------------------------------------------
+function test_normalize_date ()
+ return utils.normalize_date("12/31/2017") == '2017-12-31'
+ and utils.normalize_date("pandoc") == nil
+end
+
-- Return result
------------------------------------------------------------------------
function run(fn)
@@ -80,11 +87,12 @@ end
function Para (el)
return {
- pandoc.Plain{pandoc.Str("sha1: " .. run(test_sha1))},
+ pandoc.Plain{pandoc.Str("normalize_date: " .. run(test_normalize_date))},
pandoc.Plain{pandoc.Str("pipe: " .. run(test_pipe))},
pandoc.Plain{pandoc.Str("failing pipe: " .. run(test_failing_pipe))},
pandoc.Plain{pandoc.Str("read: " .. run(test_read))},
pandoc.Plain{pandoc.Str("failing read: " .. run(test_failing_read))},
+ pandoc.Plain{pandoc.Str("sha1: " .. run(test_sha1))},
pandoc.Plain{pandoc.Str("stringify: " .. run(test_stringify))},
pandoc.Plain{pandoc.Str("to_roman_numeral: " .. run(test_to_roman_numeral))},
}