@@ -11,7 +11,7 @@
1111
1212Unit and integration tests for pandoc's Lua subsystem.
1313-}
14−module Tests.Lua ( tests ) where
14+module Tests.Lua ( runLuaTest, tests ) where
1515
1616import Prelude
1717import Control.Monad (when)
@@ -128,29 +128,13 @@ tests = map (localOption (QuickCheckTests 20))
128128 (doc $ divWith ("", [], kv_before) (para "nil"))
129129 (doc $ divWith ("", [], kv_after) (para "nil"))
130130
131− , testCase "Test module pandoc.utils" $
132− assertFilterConversion "pandoc.utils doesn't work as expected."
133− "test-pandoc-utils.lua"
134− (doc $ para "doesn't matter")
135− (doc $ mconcat [ plain (str "blocks_to_inlines: OK")
136− , plain (str "hierarchicalize: OK")
137− , plain (str "normalize_date: OK")
138− , plain (str "pipe: OK")
139− , plain (str "failing pipe: OK")
140− , plain (str "read: OK")
141− , plain (str "failing read: OK")
142− , plain (str "sha1: OK")
143− , plain (str "stringify: OK")
144− , plain (str "to_roman_numeral: OK")
145− ])
146−
147131 , testCase "Script filename is set" $
148132 assertFilterConversion "unexpected script name"
149133 "script-name.lua"
150134 (doc $ para "ignored")
151135 (doc $ para (str $ "lua" </> "script-name.lua"))
152136
153− , testCase "Pandoc version is set" . runLua' $ do
137+ , testCase "Pandoc version is set" . runLuaTest $ do
154138 Lua.getglobal' "table.concat"
155139 Lua.getglobal "PANDOC_VERSION"
156140 Lua.push ("." :: String) -- separator
@@ -158,13 +142,13 @@ tests = map (localOption (QuickCheckTests 20))
158142 Lua.liftIO . assertEqual "pandoc version is wrong" pandocVersion
159143 =<< Lua.peek Lua.stackTop
160144
161− , testCase "Pandoc types version is set" . runLua' $ do
145+ , testCase "Pandoc types version is set" . runLuaTest $ do
162146 let versionNums = versionBranch pandocTypesVersion
163147 Lua.getglobal "PANDOC_API_VERSION"
164148 Lua.liftIO . assertEqual "pandoc-types version is wrong" versionNums
165149 =<< Lua.peek Lua.stackTop
166150
167− , testCase "Allow singleton inline in constructors" . runLua' $ do
151+ , testCase "Allow singleton inline in constructors" . runLuaTest $ do
168152 Lua.liftIO . assertEqual "Not the exptected Emph" (Emph [Str "test"])
169153 =<< Lua.callFunc "pandoc.Emph" (Str "test")
170154 Lua.liftIO . assertEqual "Unexpected element" (Para [Str "test"])
@@ -178,19 +162,19 @@ tests = map (localOption (QuickCheckTests 20))
178162 Lua.peek Lua.stackTop
179163 )
180164
181− , testCase "Elements with Attr have `attr` accessor" . runLua' $ do
165+ , testCase "Elements with Attr have `attr` accessor" . runLuaTest $ do
182166 Lua.push (Div ("hi", ["moin"], [])
183167 [Para [Str "ignored"]])
184168 Lua.getfield Lua.stackTop "attr"
185169 Lua.liftIO . assertEqual "no accessor" (("hi", ["moin"], []) :: Attr)
186170 =<< Lua.peek Lua.stackTop
187171
188− , testCase "module `pandoc.system` is present" . runLua' $ do
172+ , testCase "module `pandoc.system` is present" . runLuaTest $ do
189173 Lua.getglobal' "pandoc.system"
190174 ty <- Lua.ltype Lua.stackTop
191175 Lua.liftIO $ assertEqual "module should be a table" Lua.TypeTable ty
192176
193− , testCase "informative error messages" . runLua' $ do
177+ , testCase "informative error messages" . runLuaTest $ do
194178 Lua.pushboolean True
195179 err <- Lua.peekEither Lua.stackTop
196180 case (err :: Either String Pandoc) of
@@ -212,7 +196,7 @@ roundtripEqual :: (Eq a, Lua.Peekable a, Lua.Pushable a) => a -> IO Bool
212196roundtripEqual x = (x ==) <$> roundtripped
213197 where
214198 roundtripped :: (Lua.Peekable a, Lua.Pushable a) => IO a
215− roundtripped = runLua' $ do
199+ roundtripped = runLuaTest $ do
216200 oldSize <- Lua.gettop
217201 Lua.push x
218202 size <- Lua.gettop
@@ -223,8 +207,8 @@ roundtripEqual x = (x ==) <$> roundtripped
223207 Left e -> error (show e)
224208 Right y -> return y
225209
226−runLua' :: Lua.Lua a -> IO a
227−runLua' op = runIOorExplode $ do
210+runLuaTest :: Lua.Lua a -> IO a
211+runLuaTest op = runIOorExplode $ do
228212 setUserDataDir (Just "../data")
229213 res <- runLua op
230214 case res of