aboutsummaryrefslogtreecommitdiff
path: root/test/Tests/Readers/Org/Block/Table.hs
diff options
context:
space:
mode:
Diffstat (limited to 'test/Tests/Readers/Org/Block/Table.hs')
-rw-r--r--test/Tests/Readers/Org/Block/Table.hs56
1 files changed, 36 insertions, 20 deletions
diff --git a/test/Tests/Readers/Org/Block/Table.hs b/test/Tests/Readers/Org/Block/Table.hs
index 4b76f4a58..d35d17979 100644
--- a/test/Tests/Readers/Org/Block/Table.hs
+++ b/test/Tests/Readers/Org/Block/Table.hs
@@ -24,7 +24,18 @@ simpleTable' :: Int
-> [Blocks]
-> [[Blocks]]
-> Blocks
-simpleTable' n = table "" (replicate n (AlignDefault, ColWidthDefault))
+simpleTable' n = simpleTable'' emptyCaption $ replicate n (AlignDefault, ColWidthDefault)
+
+simpleTable'' :: Caption -> [ColSpec] -> [Blocks] -> [[Blocks]] -> Blocks
+simpleTable'' capt spec headers rows
+ = table capt
+ spec
+ (TableHead nullAttr $ toHeaderRow headers)
+ [TableBody nullAttr 0 [] $ map toRow rows]
+ (TableFoot nullAttr [])
+ where
+ toRow = Row nullAttr . map simpleCell
+ toHeaderRow l = if null l then [] else [toRow l]
tests :: [TestTree]
tests =
@@ -121,14 +132,16 @@ tests =
, "| 1 | One | foo |"
, "| 2 | Two | bar |"
] =?>
- table "" (zip
- [AlignCenter, AlignRight, AlignDefault]
- [ColWidthDefault, ColWidthDefault, ColWidthDefault])
- []
- [ [ plain "Numbers", plain "Text", plain "More" ]
- , [ plain "1" , plain "One" , plain "foo" ]
- , [ plain "2" , plain "Two" , plain "bar" ]
- ]
+ simpleTable''
+ emptyCaption
+ (zip
+ [AlignCenter, AlignRight, AlignDefault]
+ [ColWidthDefault, ColWidthDefault, ColWidthDefault])
+ []
+ [ [ plain "Numbers", plain "Text", plain "More" ]
+ , [ plain "1" , plain "One" , plain "foo" ]
+ , [ plain "2" , plain "Two" , plain "bar" ]
+ ]
, "Pipe within text doesn't start a table" =:
"Ceci n'est pas une | pipe " =?>
@@ -145,23 +158,26 @@ tests =
, "| 1 | One | foo |"
, "| 2"
] =?>
- table "" (zip [AlignCenter, AlignRight] [ColWidthDefault, ColWidthDefault])
- [ plain "Numbers", plain "Text" ]
- [ [ plain "1" , plain "One" , plain "foo" ]
- , [ plain "2" ]
- ]
+ simpleTable''
+ emptyCaption
+ (zip [AlignCenter, AlignRight] [ColWidthDefault, ColWidthDefault])
+ [ plain "Numbers", plain "Text" ]
+ [ [ plain "1" , plain "One" , plain "foo" ]
+ , [ plain "2" ]
+ ]
, "Table with caption" =:
T.unlines [ "#+CAPTION: Hitchhiker's Multiplication Table"
, "| x | 6 |"
, "| 9 | 42 |"
] =?>
- table "Hitchhiker's Multiplication Table"
- [(AlignDefault, ColWidthDefault), (AlignDefault, ColWidthDefault)]
- []
- [ [ plain "x", plain "6" ]
- , [ plain "9", plain "42" ]
- ]
+ simpleTable''
+ (simpleCaption $ plain "Hitchhiker's Multiplication Table")
+ [(AlignDefault, ColWidthDefault), (AlignDefault, ColWidthDefault)]
+ []
+ [ [ plain "x", plain "6" ]
+ , [ plain "9", plain "42" ]
+ ]
, "named table" =:
T.unlines [ "#+NAME: x-marks-the-spot"