@@ -114,6 +114,9 @@ tests = testGroup "unit" [
114 , testCase "SingleFieldCon" singleFieldCon
114 , testCase "SingleFieldCon" singleFieldCon
115 , testGroup "Ordering of object keys" keyOrdering
115 , testGroup "Ordering of object keys" keyOrdering
116 , testCase "Ratio with denominator 0" ratioDenominator0
116 , testCase "Ratio with denominator 0" ratioDenominator0
117+ , testCase "Rational parses number" rationalNumber
118+ , testCase "Big rational" bigRationalDecoding
119+ , testCase "Small rational" smallRationalDecoding
117 , testCase "Big scientific exponent" bigScientificExponent
120 , testCase "Big scientific exponent" bigScientificExponent
118 , testCase "Big integer decoding" bigIntegerDecoding
121 , testCase "Big integer decoding" bigIntegerDecoding
119 , testCase "Big natural decading" bigNaturalDecoding
122 , testCase "Big natural decading" bigNaturalDecoding
@@ -620,6 +623,25 @@ ratioDenominator0 =
620 (Left "Error in $: Ratio denominator was 0")
623 (Left "Error in $: Ratio denominator was 0")
621 (eitherDecode "{ \"numerator\": 1, \"denominator\": 0 }" :: Either String Rational)
624 (eitherDecode "{ \"numerator\": 1, \"denominator\": 0 }" :: Either String Rational)
626+rationalNumber :: Assertion
628+ assertEqual "Ratio with denominator 0"
630+ (eitherDecode "1.37" :: Either String Rational)
632+bigRationalDecoding :: Assertion
633+bigRationalDecoding =
634+ assertEqual "Decoding an Integer with a large exponent should fail"
635+ (Left "Error in $: parsing Ratio failed, found a number with exponent 2000, but it must not be greater than 1024 or less than -1024")
636+ ((eitherDecode :: L.ByteString -> Either String Rational) "1e2000")
638+smallRationalDecoding :: Assertion
639+smallRationalDecoding =
640+ assertEqual "Decoding an Integer with a large exponent should fail"
641+ (Left "Error in $: parsing Ratio failed, found a number with exponent -2000, but it must not be greater than 1024 or less than -1024")
642+ ((eitherDecode :: L.ByteString -> Either String Rational) "1e-2000")
623bigScientificExponent :: Assertion
645bigScientificExponent :: Assertion
624bigScientificExponent =
646bigScientificExponent =
625 assertEqual "Encoding an integral scientific with a large exponent should normalize it"
647 assertEqual "Encoding an integral scientific with a large exponent should normalize it"