@@ -13,6 +13,7 @@ import Data.Text (Text)
1313import Data.Text qualified as Text
1414import Data.Typeable (typeRep )
1515import KDL.Arrow qualified as KDL
16+ import KDL.TestUtils.AST (scrubFormat )
1617import KDL.TestUtils.Error (decodeErrorMsg )
1718import KDL.Types (
1819 Entry (.. ),
@@ -38,7 +39,7 @@ apiSpec = do
3839 it " decodes a node" $ do
3940 let config = " foo 1.0"
4041 decoder = KDL. document $ proc () -> do
41- KDL. node " foo" -< ()
42+ scrubFormat <$> KDL. node " foo" -< ()
4243 expected =
4344 Node
4445 { ann = Nothing
@@ -50,48 +51,48 @@ apiSpec = do
5051 , format = Nothing
5152 }
5253 ]
53- , children = Just NodeList {nodes = [] , format = Nothing }
54+ , children = Nothing
5455 , format = Nothing
5556 }
5657 KDL. decodeWith decoder config `shouldBe` Right expected
5758
5859 it " decodes multiple nodes" $ do
5960 let config = " foo; foo"
6061 decoder = KDL. document $ proc () -> do
61- KDL. many $ KDL. node " foo" -< ()
62+ fmap ( map scrubFormat) . KDL. many $ KDL. node " foo" -< ()
6263 expected = [fooNode, fooNode]
6364 fooNode =
6465 Node
6566 { ann = Nothing
6667 , name = Identifier {value = " foo" , format = Nothing }
6768 , entries = []
68- , children = Just NodeList {nodes = [] , format = Nothing }
69+ , children = Nothing
6970 , format = Nothing
7071 }
7172 KDL. decodeWith decoder config `shouldBe` Right expected
7273
7374 it " decodes nodes in any order" $ do
7475 let config = " foo; bar"
7576 decoder = KDL. document $ proc () -> do
76- bar <- KDL. node " bar" -< ()
77- foo <- KDL. node " foo" -< ()
77+ bar <- scrubFormat <$> KDL. node " bar" -< ()
78+ foo <- scrubFormat <$> KDL. node " foo" -< ()
7879 returnA -< (bar, foo)
7980 expected = (node " bar" , node " foo" )
8081 node name =
8182 Node
8283 { ann = Nothing
8384 , name = Identifier {value = name, format = Nothing }
8485 , entries = []
85- , children = Just NodeList {nodes = [] , format = Nothing }
86+ , children = Nothing
8687 , format = Nothing
8788 }
8889 KDL. decodeWith decoder config `shouldBe` Right expected
8990
9091 it " fails when not enough nodes" $ do
9192 let config = " foo"
9293 decoder = KDL. document $ proc () -> do
93- foo1 <- KDL. node @ Node " foo" -< ()
94- foo2 <- KDL. node @ Node " foo" -< ()
94+ foo1 <- scrubFormat <$> KDL. node @ Node " foo" -< ()
95+ foo2 <- scrubFormat <$> KDL. node @ Node " foo" -< ()
9596 returnA -< (foo1, foo2)
9697 KDL. decodeWith decoder config
9798 `shouldSatisfy` decodeErrorMsg
@@ -102,7 +103,7 @@ apiSpec = do
102103 -- Most behaviors tested with `node`
103104 describe " nodeWith" $ do
104105 it " decodes a node" $ do
105- let config = " foo 1.0 { hello \" world\" ; }"
106+ let config = " foo 1.0 { hello world; }"
106107 decodeFoo = proc () -> do
107108 arg <- KDL. arg @ Int -< ()
108109 child <- KDL. children $ KDL. argAt @ Text " hello" -< ()
@@ -164,7 +165,7 @@ apiSpec = do
164165 let config = " foo 1.0; foo 2.0; bar"
165166 decoder = KDL. document $ proc () -> do
166167 _ <- KDL. node @ Node " foo" -< ()
167- KDL. remainingNodes -< ()
168+ fmap ( map scrubFormat) <$> KDL. remainingNodes -< ()
168169 expected =
169170 Map. fromList
170171 [ (" foo" , [fooNode2])
@@ -181,15 +182,15 @@ apiSpec = do
181182 , format = Nothing
182183 }
183184 ]
184- , children = Just NodeList {nodes = [] , format = Nothing }
185+ , children = Nothing
185186 , format = Nothing
186187 }
187188 barNode =
188189 Node
189190 { ann = Nothing
190191 , name = Identifier {value = " bar" , format = Nothing }
191192 , entries = []
192- , children = Just NodeList {nodes = [] , format = Nothing }
193+ , children = Nothing
193194 , format = Nothing
194195 }
195196 KDL. decodeWith decoder config `shouldBe` Right expected
@@ -211,7 +212,7 @@ apiSpec = do
211212 KDL. decodeWith decoder config `shouldBe` Right expected
212213
213214 it " fails when node fails to parse" $ do
214- let config = " foo 1; bar 1; bar \" hello\" "
215+ let config = " foo 1; bar 1; bar hello"
215216 decodeNode = proc () -> do
216217 KDL. arg @ Int -< ()
217218 decoder = KDL. document $ proc () -> do
@@ -262,7 +263,7 @@ apiSpec = do
262263
263264 describe " argAt" $ do
264265 it " gets argument at a node" $ do
265- let config = " foo \" bar\" ; hello \" world\" "
266+ let config = " foo bar; hello world"
266267 decoder = KDL. document $ proc () -> do
267268 hello <- KDL. argAt @ Text " hello" -< ()
268269 foo <- KDL. argAt @ Text " foo" -< ()
@@ -363,7 +364,7 @@ apiSpec = do
363364 KDL. decodeWith decoder config `shouldBe` Right []
364365
365366 it " fails if any arg fails to parse" $ do
366- let config = " foo 1 \" asdf\" "
367+ let config = " foo 1 asdf"
367368 decoder = KDL. document $ proc () -> do
368369 KDL. argsAt @ Int " foo" -< ()
369370 KDL. decodeWith decoder config
@@ -456,7 +457,7 @@ apiSpec = do
456457 ]
457458
458459 it " fails if any child fails to parse" $ do
459- let config = " foo { - 1; - \" asdf\" ; }"
460+ let config = " foo { - 1; - asdf; }"
460461 decoder = KDL. document $ proc () -> do
461462 KDL. dashChildrenAt @ Int " foo" -< ()
462463 KDL. decodeWith decoder config
@@ -550,7 +551,7 @@ apiSpec = do
550551 -- Most behaviors tested with `dashNodesAt`
551552 describe " dashNodesAtWith" $ do
552553 it " gets dash nodes at a node" $ do
553- let config = " foo { - 1 { bar \" hello\" ; }; - 2 { bar \" world\" ; }; }"
554+ let config = " foo { - 1 { bar hello; }; - 2 { bar world; }; }"
554555 decodeChild = proc () -> do
555556 arg <- KDL. arg @ Int -< ()
556557 child <- KDL. children $ KDL. nodeWith " bar" $ KDL. arg @ Text -< ()
@@ -560,7 +561,7 @@ apiSpec = do
560561 KDL. decodeWith decoder config `shouldBe` Right [(1 , " hello" ), (2 , " world" )]
561562
562563 it " fails if any child fails to parse" $ do
563- let config = " foo { - { bar 1; }; - { bar \" test\" ; }; }"
564+ let config = " foo { - { bar 1; }; - { bar test; }; }"
564565 decoder = KDL. document $ proc () -> do
565566 KDL. dashNodesAtWith " foo" $ KDL. children $ KDL. argAt @ Int " bar" -< ()
566567 KDL. decodeWith decoder config
@@ -579,7 +580,7 @@ apiSpec = do
579580
580581 describe " arg" $ do
581582 it " decodes an argument" $ do
582- let config = " foo 1 \" bar\" "
583+ let config = " foo 1 bar"
583584 decoder = proc () -> do
584585 arg1 <- KDL. arg @ Int -< ()
585586 arg2 <- KDL. arg @ Text -< ()
@@ -603,7 +604,7 @@ apiSpec = do
603604 ]
604605
605606 it " fails if argument fails to parse" $ do
606- let config = " foo \" test\" "
607+ let config = " foo test"
607608 decoder = proc () -> do
608609 KDL. arg @ Int -< ()
609610 decodeNode " foo" decoder config
@@ -625,7 +626,7 @@ apiSpec = do
625626 -- Most behaviors tested with `arg`
626627 describe " argWith" $ do
627628 it " decodes an argument" $ do
628- let config = " foo \" bar\" "
629+ let config = " foo bar"
629630 decoder = proc () -> do
630631 KDL. argWith KDL. text -< ()
631632 decodeNode " foo" decoder config `shouldBe` Right " bar"
@@ -668,7 +669,7 @@ apiSpec = do
668669
669670 describe " prop" $ do
670671 it " decodes a prop" $ do
671- let config = " foo test1=1 test2=\" hello\" "
672+ let config = " foo test1=1 test2=hello"
672673 decoder = proc () -> do
673674 prop1 <- KDL. prop @ Text " test2" -< ()
674675 prop2 <- KDL. prop @ Int " test1" -< ()
@@ -854,7 +855,7 @@ apiSpec = do
854855 , format = Nothing
855856 }
856857 ]
857- , children = Just NodeList {nodes = [] , format = Nothing }
858+ , children = Nothing
858859 , format = Nothing
859860 }
860861 decodeNode " foo" decoder config `shouldBe` Right expected
0 commit comments