File: Issue351.hs

package info (click to toggle)
haskell-aeson 2.2.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 9,076 kB
  • sloc: haskell: 13,153; makefile: 11
file content (21 lines) | stat: -rw-r--r-- 773 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{-# LANGUAGE OverloadedStrings #-}
module Regression.Issue351 (issue351) where

import Test.Tasty (TestTree, testGroup)
import Test.Tasty.HUnit (testCase, assertEqual)
import Data.Maybe (fromMaybe)

import qualified Data.ByteString.Lazy as L

import Data.Aeson

-- A regression test for: https://github.com/bos/aeson/issues/351
overlappingRegression :: FromJSON a => L.ByteString -> [a]
overlappingRegression bs = fromMaybe [] $ decode bs

issue351 :: TestTree
issue351 = testGroup "Issue #351" $ map (testCase "-")
  [ assertEqual "Int"  ([1, 2, 3] :: [Int])  $ overlappingRegression "[1, 2, 3]"
  , assertEqual "Char" ("abc"     :: String) $ overlappingRegression "\"abc\""
  , assertEqual "Char" (""        :: String) $ overlappingRegression "[\"a\", \"b\", \"c\"]"
  ]