on master help sign in
Update the Scientific tests in Unicode.Parser
5ba608aAdithya Kumar
test/Streamly/Test/Unicode/Parser.hs+6−16
@@ -25,36 +25,26 @@ scientificExpFP :: Property
25scientificExpFP =
25scientificExpFP =
26 forAll (chooseDouble (-99.99e-12, 1234.4567e+234)) $ \ls ->
26 forAll (chooseDouble (-99.99e-12, 1234.4567e+234)) $ \ls ->
27 case runIdentity $ Stream.parse parser (Stream.fromList (show ls)) of
27 case runIdentity $ Stream.parse parser (Stream.fromList (show ls)) of
28− Right val -> if val == show ls
28+ Right val -> val `H.shouldBe` read (show ls)
29− then property (val == show ls)
29+ Left _ -> error "Parsing failed."
30− else trace
31− ("Expected = " ++ show ls ++ " Got = " ++ val)
32− property (val == show ls)
33− Left _ -> property False
34
30
35 where
31 where
36
32
37− formatter = Scientific.formatScientific Scientific.Exponent Nothing
38 toScientific (c, m) = Scientific.scientific c m
33 toScientific (c, m) = Scientific.scientific c m
39− parser = formatter . toScientific <$> Parser.number
34+ parser = toScientific <$> Parser.number
40
35
41-- Standard decimal notation.
36-- Standard decimal notation.
42scientificFixFP :: Property
37scientificFixFP :: Property
43scientificFixFP =
38scientificFixFP =
44 forAll (chooseDouble (-0.00099, 123445.67998)) $ \ls ->
39 forAll (chooseDouble (-0.00099, 123445.67998)) $ \ls ->
45 case runIdentity $ Stream.parse parser (Stream.fromList (show ls)) of
40 case runIdentity $ Stream.parse parser (Stream.fromList (show ls)) of
46− Right val -> if val == show ls
41+ Right val -> val `H.shouldBe` read (show ls)
47− then property (val == show ls)
42+ Left _ -> error "Parsing failed."
48− else trace
49− ("Expected = " ++ show ls ++ " Got = " ++ val)
50− property (val == show ls)
51− Left _ -> property False
52
43
53 where
44 where
54
45
55− formatter = Scientific.formatScientific Scientific.Fixed Nothing
56 toScientific (c, m) = Scientific.scientific c m
46 toScientific (c, m) = Scientific.scientific c m
57− parser = formatter . toScientific <$> Parser.number
47+ parser = toScientific <$> Parser.number
58
48
59doubleExpFP :: Property
49doubleExpFP :: Property
60doubleExpFP =
50doubleExpFP =