@@ -11,8 +11,7 @@ import qualified Data.ByteString.Char8 as B8
12import Test.HUnit hiding (Test, path)
12import Test.HUnit hiding (Test, path)
14−import qualified Data.Conduit as C
14+import Data.Conduit (runConduitRes, (.|), ConduitM)
15−import qualified Control.Monad.Trans.Resource as C
16import qualified Data.Conduit.List as CL
15import qualified Data.Conduit.List as CL
18import Control.Monad
17import Control.Monad
@@ -172,7 +171,7 @@ specialStrings =
172 , "foo\nbar\nbaz\n"
171 , "foo\nbar\nbaz\n"
175−counter :: Monad m => (Y.Event -> Bool) -> C.Sink Y.Event m Int
174+counter :: Monad m => (Y.Event -> Bool) -> ConduitM Y.Event o m Int
176counter pred' =
175counter pred' =
177 CL.fold (\cnt e -> (if pred' e then 1 else 0) + cnt) 0
176 CL.fold (\cnt e -> (if pred' e then 1 else 0) + cnt) 0
@@ -181,7 +180,7 @@ caseHelper :: String
182 -> Assertion
181 -> Assertion
183caseHelper yamlString pred' expRes = do
182caseHelper yamlString pred' expRes = do
184− res <- C.runResourceT $ Y.decode (B8.pack yamlString) C.$$ counter pred'
183+ res <- runConduitRes $ Y.decode (B8.pack yamlString) .| counter pred'
185 res @?= expRes
184 res @?= expRes
187caseCountScalarsWithAnchor :: Assertion
186caseCountScalarsWithAnchor :: Assertion
@@ -218,7 +217,7 @@ caseCountAliases =
219caseCountScalars :: Assertion
218caseCountScalars :: Assertion
220caseCountScalars = do
219caseCountScalars = do
221− res <- C.runResourceT $ Y.decode yamlBS C.$$ CL.fold adder accum
220+ res <- runConduitRes $ Y.decode yamlBS .| CL.fold adder accum
222 res @?= (7, 1, 2)
221 res @?= (7, 1, 2)
224 yamlString = "foo:\n baz: [bin1, bin2, bin3]\nbaz: bazval"
223 yamlString = "foo:\n baz: [bin1, bin2, bin3]\nbaz: bazval"
@@ -231,7 +230,7 @@ caseCountScalars = do
232caseLargestString :: Assertion
231caseLargestString :: Assertion
233caseLargestString = do
232caseLargestString = do
234− res <- C.runResourceT $ Y.decodeFile filePath C.$$ CL.fold adder accum
233+ res <- runConduitRes $ Y.decodeFile filePath .| CL.fold adder accum
235 res @?= (length expected, expected)
234 res @?= (length expected, expected)
237 expected = "this one is just a little bit bigger than the others"
236 expected = "this one is just a little bit bigger than the others"
@@ -251,9 +250,9 @@ instance Eq MyEvent where
252caseEncodeDecode :: Assertion
251caseEncodeDecode :: Assertion
253caseEncodeDecode = do
252caseEncodeDecode = do
254− eList <- C.runResourceT $ Y.decode yamlBS C.$$ CL.consume
253+ eList <- runConduitRes $ Y.decode yamlBS .| CL.consume
255− bs <- C.runResourceT $ CL.sourceList eList C.$$ Y.encode
254+ bs <- runConduitRes $ CL.sourceList eList .| Y.encode
256− eList2 <- C.runResourceT $ Y.decode bs C.$$ CL.consume
255+ eList2 <- runConduitRes $ Y.decode bs .| CL.consume
257 map MyEvent eList @=? map MyEvent eList2
256 map MyEvent eList @=? map MyEvent eList2
259 yamlString = "foo: bar\nbaz:\n - bin1\n - bin2\n"
258 yamlString = "foo: bar\nbaz:\n - bin1\n - bin2\n"
@@ -261,17 +260,17 @@ caseEncodeDecode = do
262caseEncodeDecodeFile :: Assertion
261caseEncodeDecodeFile :: Assertion
263caseEncodeDecodeFile = withFile "" $ \tmpPath -> do
262caseEncodeDecodeFile = withFile "" $ \tmpPath -> do
264− eList <- C.runResourceT $ Y.decodeFile filePath C.$$ CL.consume
263+ eList <- runConduitRes $ Y.decodeFile filePath .| CL.consume
265− C.runResourceT $ CL.sourceList eList C.$$ Y.encodeFile tmpPath
264+ runConduitRes $ CL.sourceList eList .| Y.encodeFile tmpPath
266− eList2 <- C.runResourceT $ Y.decodeFile filePath C.$$ CL.consume
265+ eList2 <- runConduitRes $ Y.decodeFile filePath .| CL.consume
267 map MyEvent eList @=? map MyEvent eList2
266 map MyEvent eList @=? map MyEvent eList2
269 filePath = "test/largest-string.yaml"
268 filePath = "test/largest-string.yaml"
271caseInterleave :: Assertion
270caseInterleave :: Assertion
272caseInterleave = withFile "" $ \tmpPath -> withFile "" $ \tmpPath2 -> do
271caseInterleave = withFile "" $ \tmpPath -> withFile "" $ \tmpPath2 -> do
273− () <- C.runResourceT $ Y.decodeFile filePath C.$$ Y.encodeFile tmpPath
272+ () <- runConduitRes $ Y.decodeFile filePath .| Y.encodeFile tmpPath
274− () <- C.runResourceT $ Y.decodeFile tmpPath C.$$ Y.encodeFile tmpPath2
273+ () <- runConduitRes $ Y.decodeFile tmpPath .| Y.encodeFile tmpPath2
275 f1 <- readFile tmpPath
274 f1 <- readFile tmpPath
276 f2 <- readFile tmpPath2
275 f2 <- readFile tmpPath2
277 f1 @=? f2
276 f1 @=? f2
@@ -280,7 +279,7 @@ caseInterleave = withFile "" $ \tmpPath -> withFile "" $ \tmpPath2 -> do
281caseDecodeInvalidDocument :: Assertion
280caseDecodeInvalidDocument :: Assertion
282caseDecodeInvalidDocument = do
281caseDecodeInvalidDocument = do
283− x <- try $ C.runResourceT $ Y.decode yamlBS C.$$ CL.sinkNull
282+ x <- try $ runConduitRes $ Y.decode yamlBS .| CL.sinkNull
284 case x of
283 case x of
285 Left (_ :: SomeException) -> return ()
284 Left (_ :: SomeException) -> return ()
286 Right y -> do
285 Right y -> do