summaryrefslogtreecommitdiff
path: root/test/Tests/Lua.hs
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2018-01-13 22:29:16 +0100
committerAlbert Krewinkel <albert@zeitkraut.de>2018-01-13 22:32:22 +0100
commite0cb0dab1821e93e50e8b8006ef569bdeee9a248 (patch)
treeabce36fe6e36f622730234f66ad7df253735f5b9 /test/Tests/Lua.hs
parente5e69e68c90b1afefa901df689aeee1924737741 (diff)
data/pandoc.lua: accept single block as singleton list
Every constructor which accepts a list of blocks now also accepts a single block element for convenience. Furthermore, strings are accepted as shorthand for `{pandoc.Str "text"}` in constructors.
Diffstat (limited to 'test/Tests/Lua.hs')
-rw-r--r--test/Tests/Lua.hs18
1 files changed, 14 insertions, 4 deletions
diff --git a/test/Tests/Lua.hs b/test/Tests/Lua.hs
index c7652a200..d728cb9d0 100644
--- a/test/Tests/Lua.hs
+++ b/test/Tests/Lua.hs
@@ -12,8 +12,8 @@ import Text.Pandoc.Builder (bulletList, divWith, doc, doubleQuoted, emph,
header, linebreak, para, plain, rawBlock,
singleQuoted, space, str, strong, (<>))
import Text.Pandoc.Class (runIOorExplode, setUserDataDir)
-import Text.Pandoc.Definition (Block, Inline (Emph, Str), Meta, Pandoc,
- pandocTypesVersion)
+import Text.Pandoc.Definition (Block (BlockQuote, Para), Inline (Emph, Str),
+ Meta, Pandoc, pandocTypesVersion)
import Text.Pandoc.Lua (runLuaFilter, runPandocLua)
import Text.Pandoc.Options (def)
import Text.Pandoc.Shared (pandocVersion)
@@ -126,8 +126,18 @@ tests = map (localOption (QuickCheckTests 20))
=<< Lua.peek Lua.stackTop
, testCase "Allow singleton inline in constructors" . runPandocLua' $ do
- res <- Lua.callFunc "pandoc.Emph" (Str "test")
- Lua.liftIO $ assertEqual "Not the exptected Emph" (Emph [Str "test"]) res
+ Lua.liftIO . assertEqual "Not the exptected Emph" (Emph [Str "test"])
+ =<< Lua.callFunc "pandoc.Emph" (Str "test")
+ Lua.liftIO . assertEqual "Unexpected element" (Para [Str "test"])
+ =<< Lua.callFunc "pandoc.Para" ("test" :: String)
+ Lua.liftIO . assertEqual "Unexptected element"
+ (BlockQuote [Para [Str "foo"]]) =<< (
+ do
+ Lua.getglobal' "pandoc.BlockQuote"
+ Lua.push (Para [Str "foo"])
+ _ <- Lua.call 1 1
+ Lua.peek Lua.stackTop
+ )
, testCase "informative error messages" . runPandocLua' $ do
Lua.pushboolean True