File: KeyMapInsertWith.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 (14 lines) | stat: -rw-r--r-- 679 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{-# LANGUAGE OverloadedStrings #-}
module UnitTests.KeyMapInsertWith (keyMapInsertWithTests) where

import Test.Tasty (TestTree)
import Test.Tasty.HUnit (testCase, (@?=))

import qualified Data.Aeson.KeyMap as KM

keyMapInsertWithTests :: TestTree
keyMapInsertWithTests = testCase "KeyMap.insertWith" $ do
  KM.insertWith (-)        "a" 2 (KM.fromList [("a", 1)]) @?= KM.fromList [("a",1 :: Int)]
  KM.insertWith (flip (-)) "a" 2 (KM.fromList [("a", 1)]) @?= KM.fromList [("a",-1 :: Int)]
  KM.insertWith (-)        "b" 2 (KM.fromList [("a", 1)]) @?= KM.fromList [("a",1),("b",2 :: Int)]
  KM.insertWith (-)        "b" 2 KM.empty                 @?= KM.fromList [("b",2 :: Int)]