@@ -43,7 +43,7 @@ import Data.Scientific (Scientific)
43import Data.Sequence (Seq)
43import Data.Sequence (Seq)
44import Data.Tagged (Tagged(..))
44import Data.Tagged (Tagged(..))
45import Data.Text (Text)
45import Data.Text (Text)
46−import Data.Time (UTCTime)
46+import Data.Time (UTCTime, fromGregorian)
47import Data.Time.Format (parseTime)
47import Data.Time.Format (parseTime)
48import Data.Time.Locale.Compat (defaultTimeLocale)
48import Data.Time.Locale.Compat (defaultTimeLocale)
49import Data.Word (Word8)
49import Data.Word (Word8)
@@ -331,6 +331,8 @@ jsonDecodingExamples = [
331 , MaybeExample "Word8 3.14" "3.14" (Nothing :: Maybe Word8)
331 , MaybeExample "Word8 3.14" "3.14" (Nothing :: Maybe Word8)
332 , MaybeExample "Word8 -1" "-1" (Nothing :: Maybe Word8)
332 , MaybeExample "Word8 -1" "-1" (Nothing :: Maybe Word8)
333 , MaybeExample "Word8 300" "300" (Nothing :: Maybe Word8)
333 , MaybeExample "Word8 300" "300" (Nothing :: Maybe Word8)
334+ -- Negative zero year, encoding never produces such:
335+ , MaybeExample "Day -0000-02-03" "\"-0000-02-03\"" (Just (fromGregorian 0 2 3))
336jsonExamples :: [Example]
338jsonExamples :: [Example]
@@ -396,6 +398,12 @@ jsonExamples =
396 , Example "Maybe String" "\"foo\"" (pure "foo" :: Maybe String)
398 , Example "Maybe String" "\"foo\"" (pure "foo" :: Maybe String)
397 , Example "Maybe [Identity Char]" "\"xy\"" (pure [pure 'x', pure 'y'] :: Maybe [Identity Char])
399 , Example "Maybe [Identity Char]" "\"xy\"" (pure [pure 'x', pure 'y'] :: Maybe [Identity Char])
401+ , Example "Day; year >= 1000" "\"1999-10-12\"" (fromGregorian 1999 10 12)
402+ , Example "Day; year > 0 && < 1000" "\"0500-03-04\"" (fromGregorian 500 3 4)
403+ , Example "Day; year == 0" "\"0000-02-20\"" (fromGregorian 0 2 20)
404+ , Example "Day; year < 0" "\"-0234-01-01\"" (fromGregorian (-234) 1 1)
405+ , Example "Day; year < -1000" "\"-1234-01-01\"" (fromGregorian (-1234) 1 1)
399 , Example "Product I Maybe Int" "[1,2]" (Pair (pure 1) (pure 2) :: Product I Maybe Int)
407 , Example "Product I Maybe Int" "[1,2]" (Pair (pure 1) (pure 2) :: Product I Maybe Int)
400 , Example "Product I Maybe Int" "[1,null]" (Pair (pure 1) Nothing :: Product I Maybe Int)
408 , Example "Product I Maybe Int" "[1,null]" (Pair (pure 1) Nothing :: Product I Maybe Int)
401 , Example "Product I [] Char" "[\"a\",\"foo\"]" (Pair (pure 'a') "foo" :: Product I [] Char)
409 , Example "Product I [] Char" "[\"a\",\"foo\"]" (Pair (pure 'a') "foo" :: Product I [] Char)