Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alpmestan committed Dec 20, 2022
1 parent ea5fbd8 commit 40f66f0
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 10 deletions.
9 changes: 7 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,10 @@ packages:

tests: true

allow-newer: vector-fftw:base
constraints: entropy < 0.4.1.9, haxl >= 2.4
allow-newer: vector-fftw:base, haskell-names:aeson, haskell-names:bytestring, haxl:bytestring, haxl:time
constraints: entropy < 0.4.1.9, haxl >= 2.4

source-repository-package
type: git
location: https://github.com/exi/vector-fftw.git
tag: 6d09555b94c8e0363e0243a2802153b5749f8d2d
7 changes: 6 additions & 1 deletion ci-sdist.cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,10 @@ package thrift-server
flags: +tests_use_ipv4
package thrift-cpp-channel
flags: +tests_use_ipv4
allow-newer: vector-fftw:base
allow-newer: vector-fftw:base, haskell-names:aeson, haskell-names:bytestring, haxl:bytestring, haxl:time
constraints: entropy < 0.4.1.9, haxl >= 2.4

source-repository-package
type: git
location: https://github.com/exi/vector-fftw.git
tag: 6d09555b94c8e0363e0243a2802153b5749f8d2d
7 changes: 6 additions & 1 deletion ci.cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,10 @@ package thrift-server
package thrift-cpp-channel
flags: +tests_use_ipv4

allow-newer: vector-fftw:base
allow-newer: vector-fftw:base, haskell-names:aeson, haskell-names:bytestring, haxl:bytestring, haxl:time
constraints: entropy < 0.4.1.9, haxl >= 2.4

source-repository-package
type: git
location: https://github.com/exi/vector-fftw.git
tag: 6d09555b94c8e0363e0243a2802153b5749f8d2d
3 changes: 2 additions & 1 deletion common/util/Util/ToExp.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import Language.Haskell.Exts hiding (intE)
import Util.Text

#if MIN_VERSION_aeson(2,0,0)
import Data.Aeson.KeyMap (Key, KeyMap)
import Data.Aeson.Key (Key)
import Data.Aeson.KeyMap (KeyMap)
import qualified Data.Aeson.Key as Key
import qualified Data.Aeson.KeyMap as KeyMap
#endif
Expand Down
21 changes: 16 additions & 5 deletions common/util/tests/HsStructTest.hs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
-- Copyright (c) Facebook, Inc. and its affiliates.

{-# LANGUAGE CPP #-}
module HsStructTest (main) where

import Test.HUnit
import TestRunner

import Control.Exception
#if MIN_VERSION_aeson(2,0,0)
import Data.Aeson.KeyMap (KeyMap)
import qualified Data.Aeson.KeyMap as KeyMap
#endif
import qualified Data.Aeson as Aeson
import Data.ByteString (ByteString, useAsCStringLen)
import Data.ByteString.Unsafe (unsafeUseAsCStringLen)
Expand Down Expand Up @@ -407,7 +411,11 @@ pairTest = TestLabel "Pair" $
foreign import ccall unsafe "getPair"
getPair :: IO (Ptr a)

#if MIN_VERSION_aeson(2,0,0)
type Nested = KeyMap (IntMap [Maybe Text])
#else
type Nested = HashMap Text (IntMap [Maybe Text])
#endif
type HsNested = HsObject (HsIntMap (HsList (HsMaybe HsText)))

nestedTest :: Test
Expand All @@ -416,8 +424,13 @@ nestedTest = TestLabel "nested" $
actual :: Nested <- coerce $ bracket createNested destroyNested peek
assertEqual "Nested" expected actual
where
#if MIN_VERSION_aeson(2,0,0)
mapFromList = KeyMap.fromList
#else
mapFromList = HashMap.fromList
#endif
expected =
HashMap.fromList
mapFromList
[ ("zero", IntMap.empty)
, ("one", IntMap.singleton 1 [])
, ("two", IntMap.singleton 2 [Nothing])
Expand Down Expand Up @@ -454,9 +467,7 @@ jsonRoundTrip = TestLabel "json" $
[Aeson.Null, Aeson.Bool True, Aeson.String "VectorVector"]
)
roundTrip
( Aeson.Object $
HashMap.fromList
[("foo", Aeson.Bool True), ("bar", Aeson.Bool False)]
( Aeson.object [ "foo" Aeson..= True, "bar" Aeson..= False ]
)
where
roundTrip j = withCxxObject (HsJSON j) $ \p -> do
Expand Down

0 comments on commit 40f66f0

Please sign in to comment.