mirror of
https://github.com/composewell/streamly.git
synced 2024-09-11 11:37:22 +03:00
Update the Scientific tests in Unicode.Parser
This commit is contained in:
parent
c2d7a1fbf1
commit
cc0ceac7d0
@ -25,36 +25,26 @@ scientificExpFP :: Property
|
|||||||
scientificExpFP =
|
scientificExpFP =
|
||||||
forAll (chooseDouble (-99.99e-12, 1234.4567e+234)) $ \ls ->
|
forAll (chooseDouble (-99.99e-12, 1234.4567e+234)) $ \ls ->
|
||||||
case runIdentity $ Stream.parse parser (Stream.fromList (show ls)) of
|
case runIdentity $ Stream.parse parser (Stream.fromList (show ls)) of
|
||||||
Right val -> if val == show ls
|
Right val -> val `H.shouldBe` read (show ls)
|
||||||
then property (val == show ls)
|
Left _ -> error "Parsing failed."
|
||||||
else trace
|
|
||||||
("Expected = " ++ show ls ++ " Got = " ++ val)
|
|
||||||
property (val == show ls)
|
|
||||||
Left _ -> property False
|
|
||||||
|
|
||||||
where
|
where
|
||||||
|
|
||||||
formatter = Scientific.formatScientific Scientific.Exponent Nothing
|
|
||||||
toScientific (c, m) = Scientific.scientific c m
|
toScientific (c, m) = Scientific.scientific c m
|
||||||
parser = formatter . toScientific <$> Parser.number
|
parser = toScientific <$> Parser.number
|
||||||
|
|
||||||
-- Standard decimal notation.
|
-- Standard decimal notation.
|
||||||
scientificFixFP :: Property
|
scientificFixFP :: Property
|
||||||
scientificFixFP =
|
scientificFixFP =
|
||||||
forAll (chooseDouble (-0.00099, 123445.67998)) $ \ls ->
|
forAll (chooseDouble (-0.00099, 123445.67998)) $ \ls ->
|
||||||
case runIdentity $ Stream.parse parser (Stream.fromList (show ls)) of
|
case runIdentity $ Stream.parse parser (Stream.fromList (show ls)) of
|
||||||
Right val -> if val == show ls
|
Right val -> val `H.shouldBe` read (show ls)
|
||||||
then property (val == show ls)
|
Left _ -> error "Parsing failed."
|
||||||
else trace
|
|
||||||
("Expected = " ++ show ls ++ " Got = " ++ val)
|
|
||||||
property (val == show ls)
|
|
||||||
Left _ -> property False
|
|
||||||
|
|
||||||
where
|
where
|
||||||
|
|
||||||
formatter = Scientific.formatScientific Scientific.Fixed Nothing
|
|
||||||
toScientific (c, m) = Scientific.scientific c m
|
toScientific (c, m) = Scientific.scientific c m
|
||||||
parser = formatter . toScientific <$> Parser.number
|
parser = toScientific <$> Parser.number
|
||||||
|
|
||||||
doubleExpFP :: Property
|
doubleExpFP :: Property
|
||||||
doubleExpFP =
|
doubleExpFP =
|
||||||
|
Loading…
Reference in New Issue
Block a user