aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert+github@zeitkraut.de>2017-04-14 11:57:30 +0200
committerGitHub <noreply@github.com>2017-04-14 11:57:30 +0200
commit932e395e535e10e7fdbfadd5617b7427a2141343 (patch)
tree54a2fdea10ea81694357d1f6a7884431490b287b /test
parent624ccbd45e24b1862e32252b3a03af7ee652bd16 (diff)
parent07f41a5515c0d753c8b3fa074132ba219db8360c (diff)
downloadpandoc-932e395e535e10e7fdbfadd5617b7427a2141343.tar.gz
Merge pull request #3569 from tarleb/lua-destructured-filter-functions
Destructuring lua filter functions
Diffstat (limited to 'test')
-rw-r--r--test/Tests/Lua.hs8
-rw-r--r--test/lua/markdown-reader.lua3
-rw-r--r--test/lua/plain-to-para.lua4
-rw-r--r--test/lua/strmacro.lua9
4 files changed, 14 insertions, 10 deletions
diff --git a/test/Tests/Lua.hs b/test/Tests/Lua.hs
index 64c35b298..4196ff4b7 100644
--- a/test/Tests/Lua.hs
+++ b/test/Tests/Lua.hs
@@ -64,10 +64,14 @@ roundtripEqual x = (x ==) <$> roundtripped
roundtripped :: (Lua.StackValue a) => IO a
roundtripped = do
lua <- Lua.newstate
+ Lua.openlibs lua
+ pushPandocModule lua
+ Lua.setglobal lua "pandoc"
+ oldSize <- Lua.gettop lua
Lua.push lua x
size <- Lua.gettop lua
- when (size /= 1) $
- error ("not exactly one element on the stack: " ++ show size)
+ when ((size - oldSize) /= 1) $
+ error ("not exactly one additional element on the stack: " ++ show size)
res <- Lua.peek lua (-1)
retval <- case res of
Nothing -> error "could not read from stack"
diff --git a/test/lua/markdown-reader.lua b/test/lua/markdown-reader.lua
index 6356113ec..a72af5546 100644
--- a/test/lua/markdown-reader.lua
+++ b/test/lua/markdown-reader.lua
@@ -1,7 +1,6 @@
return {
{
- RawBlock = function (blk)
- local format, content = unpack(blk.c)
+ RawBlock = function (format, content)
if format == "markdown" then
return pandoc.reader.markdown.read_block(content)
else
diff --git a/test/lua/plain-to-para.lua b/test/lua/plain-to-para.lua
index 747257411..a11edbbe2 100644
--- a/test/lua/plain-to-para.lua
+++ b/test/lua/plain-to-para.lua
@@ -1,6 +1,6 @@
return {
- { Plain = function (blk)
- return pandoc.Para(blk.c)
+ { Plain = function (content)
+ return pandoc.Para(content)
end,
}
}
diff --git a/test/lua/strmacro.lua b/test/lua/strmacro.lua
index 1b28801be..40756a476 100644
--- a/test/lua/strmacro.lua
+++ b/test/lua/strmacro.lua
@@ -1,10 +1,11 @@
return {
- { Str = function (inline)
- if inline.c == "{{helloworld}}" then
+ {
+ Str = function (str)
+ if str == "{{helloworld}}" then
return pandoc.Emph {pandoc.Str "Hello, World"}
else
- return inline
+ return pandoc.Str(str)
end
- end,
+ end,
}
}