aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Tests/Lua.hs31
-rw-r--r--test/Tests/Readers/Docx.hs8
-rw-r--r--test/command/3734.md6
-rw-r--r--test/docx/lists_continuing.docxbin0 -> 17717 bytes
-rw-r--r--test/docx/lists_continuing.native7
-rw-r--r--test/docx/lists_restarting.docxbin0 -> 18189 bytes
-rw-r--r--test/docx/lists_restarting.native8
-rw-r--r--test/pipe-tables.native2
8 files changed, 45 insertions, 17 deletions
diff --git a/test/Tests/Lua.hs b/test/Tests/Lua.hs
index eaa7eb405..4f14a834b 100644
--- a/test/Tests/Lua.hs
+++ b/test/Tests/Lua.hs
@@ -10,9 +10,9 @@ import Text.Pandoc.Arbitrary ()
import Text.Pandoc.Builder (bulletList, divWith, doc, doubleQuoted, emph,
header, linebreak, para, plain, rawBlock,
singleQuoted, space, str, strong, (<>))
-import Text.Pandoc.Class (runIOorExplode)
+import Text.Pandoc.Class (runIOorExplode, setUserDataDir)
import Text.Pandoc.Definition (Block, Inline, Meta, Pandoc)
-import Text.Pandoc.Lua (initLuaState, runLuaFilter, luaPackageParams)
+import Text.Pandoc.Lua (runLuaFilter, runPandocLua)
import qualified Foreign.Lua as Lua
@@ -95,8 +95,9 @@ tests = map (localOption (QuickCheckTests 20))
assertFilterConversion :: String -> FilePath -> Pandoc -> Pandoc -> Assertion
assertFilterConversion msg filterPath docIn docExpected = do
- docEither <- runIOorExplode $
- runLuaFilter (Just "../data") ("lua" </> filterPath) [] docIn
+ docEither <- runIOorExplode $ do
+ setUserDataDir (Just "../data")
+ runLuaFilter ("lua" </> filterPath) [] docIn
case docEither of
Left _ -> fail "lua filter failed"
Right docRes -> assertEqual msg docExpected docRes
@@ -105,14 +106,18 @@ roundtripEqual :: (Eq a, Lua.FromLuaStack a, Lua.ToLuaStack a) => a -> IO Bool
roundtripEqual x = (x ==) <$> roundtripped
where
roundtripped :: (Lua.FromLuaStack a, Lua.ToLuaStack a) => IO a
- roundtripped = Lua.runLua $ do
- initLuaState =<< Lua.liftIO (runIOorExplode (luaPackageParams (Just "../data")))
- oldSize <- Lua.gettop
- Lua.push x
- size <- Lua.gettop
- when (size - oldSize /= 1) $
- error ("not exactly one additional element on the stack: " ++ show size)
- res <- Lua.peekEither (-1)
+ roundtripped = runIOorExplode $ do
+ setUserDataDir (Just "../data")
+ res <- runPandocLua $ do
+ oldSize <- Lua.gettop
+ Lua.push x
+ size <- Lua.gettop
+ when (size - oldSize /= 1) $
+ error ("not exactly one additional element on the stack: " ++ show size)
+ res <- Lua.peekEither (-1)
+ case res of
+ Left _ -> error "could not read from stack"
+ Right y -> return y
case res of
- Left _ -> error "could not read from stack"
+ Left e -> error (show e)
Right y -> return y
diff --git a/test/Tests/Readers/Docx.hs b/test/Tests/Readers/Docx.hs
index 421acaa8b..6d91c36ae 100644
--- a/test/Tests/Readers/Docx.hs
+++ b/test/Tests/Readers/Docx.hs
@@ -206,6 +206,14 @@ tests = [ testGroup "inlines"
"docx/lists.docx"
"docx/lists.native"
, testCompare
+ "lists continuing after interruption"
+ "docx/lists_continuing.docx"
+ "docx/lists_continuing.native"
+ , testCompare
+ "lists restarting after interruption"
+ "docx/lists_restarting.docx"
+ "docx/lists_restarting.native"
+ , testCompare
"definition lists"
"docx/definition_list.docx"
"docx/definition_list.native"
diff --git a/test/command/3734.md b/test/command/3734.md
index d7e6f20b1..16803256b 100644
--- a/test/command/3734.md
+++ b/test/command/3734.md
@@ -6,9 +6,9 @@
^D
<table>
<colgroup>
-<col style="width: 15%" />
-<col style="width: 8%" />
-<col style="width: 76%" />
+<col style="width: 14%" />
+<col style="width: 7%" />
+<col style="width: 77%" />
</colgroup>
<thead>
<tr class="header">
diff --git a/test/docx/lists_continuing.docx b/test/docx/lists_continuing.docx
new file mode 100644
index 000000000..e6249260b
--- /dev/null
+++ b/test/docx/lists_continuing.docx
Binary files differ
diff --git a/test/docx/lists_continuing.native b/test/docx/lists_continuing.native
new file mode 100644
index 000000000..24d352ce5
--- /dev/null
+++ b/test/docx/lists_continuing.native
@@ -0,0 +1,7 @@
+[OrderedList (1,Decimal,Period)
+ [[Para [Str "Foo"]]
+ ,[Para [Str "Bar"]]
+ ,[Para [Str "Baz"]]]
+,Para [Str "Interruption."]
+,OrderedList (4,Decimal,Period)
+ [[Para [Str "Bop"]]]]
diff --git a/test/docx/lists_restarting.docx b/test/docx/lists_restarting.docx
new file mode 100644
index 000000000..4acd67fcb
--- /dev/null
+++ b/test/docx/lists_restarting.docx
Binary files differ
diff --git a/test/docx/lists_restarting.native b/test/docx/lists_restarting.native
new file mode 100644
index 000000000..6602f1262
--- /dev/null
+++ b/test/docx/lists_restarting.native
@@ -0,0 +1,8 @@
+[OrderedList (2,Decimal,Period)
+ [[Para [Str "Foo"]]
+ ,[Para [Str "Bar"]]
+ ,[Para [Str "Baz"]]]
+,BlockQuote
+ [Para [Str "Interruption"]]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "Bop."]]]]
diff --git a/test/pipe-tables.native b/test/pipe-tables.native
index 63c2c17bc..ca9858d1f 100644
--- a/test/pipe-tables.native
+++ b/test/pipe-tables.native
@@ -85,7 +85,7 @@
,[[Plain [Str "4"]]
,[Plain [Str "44"]]]]
,Para [Str "Long",Space,Str "pipe",Space,Str "table",Space,Str "with",Space,Str "relative",Space,Str "widths:"]
-,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.125,0.1375,0.5]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.15517241379310345,0.1724137931034483,0.6724137931034483]
[[Plain [Str "Default1"]]
,[Plain [Str "Default2"]]
,[Plain [Str "Default3"]]]