diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Tests/Lua.hs | 6 | ||||
-rw-r--r-- | test/lua/metatable-catch-all.lua | 20 |
2 files changed, 26 insertions, 0 deletions
diff --git a/test/Tests/Lua.hs b/test/Tests/Lua.hs index 895b93775..06f100048 100644 --- a/test/Tests/Lua.hs +++ b/test/Tests/Lua.hs @@ -64,6 +64,12 @@ tests = map (localOption (QuickCheckTests 20)) "single-to-double-quoted.lua" (doc . para . singleQuoted $ str "simple") (doc . para . doubleQuoted $ str "simple") + + , testCase "Count inlines via metatable catch-all" $ + assertFilterConversion "filtering with metatable catch-all failed" + "metatable-catch-all.lua" + (doc . para $ "four words, three spaces") + (doc . para $ str "7") ] assertFilterConversion :: String -> FilePath -> Pandoc -> Pandoc -> Assertion diff --git a/test/lua/metatable-catch-all.lua b/test/lua/metatable-catch-all.lua new file mode 100644 index 000000000..05df16bbf --- /dev/null +++ b/test/lua/metatable-catch-all.lua @@ -0,0 +1,20 @@ +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} + ) +} |