From cc0ceac7d03096fec13518d370ff0a70fc47fd9b Mon Sep 17 00:00:00 2001 From: Adithya Kumar Date: Mon, 11 Sep 2023 22:10:49 +0530 Subject: [PATCH] Update the Scientific tests in Unicode.Parser --- test/Streamly/Test/Unicode/Parser.hs | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/test/Streamly/Test/Unicode/Parser.hs b/test/Streamly/Test/Unicode/Parser.hs index abf5bc406..df4fdbf88 100644 --- a/test/Streamly/Test/Unicode/Parser.hs +++ b/test/Streamly/Test/Unicode/Parser.hs @@ -25,36 +25,26 @@ scientificExpFP :: Property scientificExpFP = forAll (chooseDouble (-99.99e-12, 1234.4567e+234)) $ \ls -> case runIdentity $ Stream.parse parser (Stream.fromList (show ls)) of - Right val -> if val == show ls - then property (val == show ls) - else trace - ("Expected = " ++ show ls ++ " Got = " ++ val) - property (val == show ls) - Left _ -> property False + Right val -> val `H.shouldBe` read (show ls) + Left _ -> error "Parsing failed." where - formatter = Scientific.formatScientific Scientific.Exponent Nothing toScientific (c, m) = Scientific.scientific c m - parser = formatter . toScientific <$> Parser.number + parser = toScientific <$> Parser.number -- Standard decimal notation. scientificFixFP :: Property scientificFixFP = forAll (chooseDouble (-0.00099, 123445.67998)) $ \ls -> case runIdentity $ Stream.parse parser (Stream.fromList (show ls)) of - Right val -> if val == show ls - then property (val == show ls) - else trace - ("Expected = " ++ show ls ++ " Got = " ++ val) - property (val == show ls) - Left _ -> property False + Right val -> val `H.shouldBe` read (show ls) + Left _ -> error "Parsing failed." where - formatter = Scientific.formatScientific Scientific.Fixed Nothing toScientific (c, m) = Scientific.scientific c m - parser = formatter . toScientific <$> Parser.number + parser = toScientific <$> Parser.number doubleExpFP :: Property doubleExpFP =