on master help sign in
Fix the takeBetween test
02e884fHarendra Kumar
test/Streamly/Test/Data/Parser.hs+14−14
@@ -175,21 +175,21 @@ takeBetween :: Property
175takeBetween =
175takeBetween =
176 forAll (chooseInt (min_value, max_value)) $ \m ->
176 forAll (chooseInt (min_value, max_value)) $ \m ->
177 forAll (chooseInt (min_value, max_value)) $ \n ->
177 forAll (chooseInt (min_value, max_value)) $ \n ->
178− forAll (listOf (chooseInt (min_value, max_value))) $ \ls ->
178+ forAll (listOf (chooseInt (min_value, max_value))) $ \ls ->
179− let
179+ go m n ls
180− list_length = Prelude.length ls
181− in
182− case S.parse (P.takeBetween m n FL.toList)
183− (S.fromList ls) of
184− Right parsed_list ->
185− if m <= list_length && n >= list_length
186− then
187− let lpl = Prelude.length parsed_list
188− in checkListEqual parsed_list
189− $ Prelude.take lpl ls
190− else property False
191− Left _ -> property (m > n || list_length < m)
192
180
181+ where
182+
183+ go m n ls =
184+ let inputLen = Prelude.length ls
185+ in case S.parse (P.takeBetween m n FL.toList) (S.fromList ls) of
186+ Right xs ->
187+ let parsedLen = Prelude.length xs
188+ in if inputLen >= m && parsedLen >= m && parsedLen <= n
189+ then checkListEqual xs $ Prelude.take parsedLen ls
190+ else property False
191+ Left _ ->
192+ property ((m >= 0 && n >= 0 && m > n) || inputLen < m)
193
193
194takeEQPass :: Property
194takeEQPass :: Property
195takeEQPass =
195takeEQPass =