j 0.1.2.0 → 0.2.0.0
raw patch · 4 files changed
+23/−10 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Language.J: JIntArr :: !Array F sh CInt -> JData sh
+ Language.J: JIntArr :: !Array F sh CLLong -> JData sh
Files
- CHANGELOG.md +5/−0
- j.cabal +1/−1
- src/Language/J.hs +2/−2
- test/Spec.hs +15/−7
CHANGELOG.md view
@@ -1,5 +1,10 @@ # j +## 0.2.0.0++ * Fix bug in integer arrays passed to J+ * `JIntArr` now takes an array of `CLLong`+ ## 0.1.2.0 * Add `jload` to load profile
j.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.18 name: j-version: 0.1.2.0+version: 0.2.0.0 license: BSD3 license-file: LICENSE copyright: Copyright: (c) 2020 Vanessa McHale
src/Language/J.hs view
@@ -270,7 +270,7 @@ let mult = case ty' of JBool -> sizeOf (undefined :: CChar) JChar -> sizeOf (undefined :: CChar)- JInteger -> sizeOf (undefined :: CInt)+ JInteger -> sizeOf (undefined :: CLLong) JDouble -> sizeOf (undefined :: CDouble) let resBytes = mult * intRank res <- mallocForeignPtrBytes resBytes@@ -283,7 +283,7 @@ data JAtom = JAtom !JType ![CLLong] !(ForeignPtr CChar) -- | J data backed by repa array-data JData sh = JIntArr !(R.Array RF.F sh CInt)+data JData sh = JIntArr !(R.Array RF.F sh CLLong) | JDoubleArr !(R.Array RF.F sh CDouble) | JBoolArr !(R.Array RF.F sh CChar) | JString !BS.ByteString
test/Spec.hs view
@@ -6,7 +6,7 @@ import Control.Applicative ((<$>)) import qualified Data.Array.Repa as R import qualified Data.ByteString as BS-import Foreign.C.Types (CDouble, CInt)+import Foreign.C.Types (CDouble, CLLong) import Language.J import Test.Tasty import Test.Tasty.HUnit@@ -34,6 +34,7 @@ , testCase "Writes strings to J values" (stringRoundtrip jenv) -- , testCase "Uses J for something Haskell would have a hard time with" (fill jenv) , testCase "Loads a library" (loadNoFail jenv)+ , testCase "Sends an integer array" (printRes jenv) ] loadNoFail :: JEnv -> Assertion@@ -42,10 +43,10 @@ jLoad jenv (linuxProfile "9.01") #else #ifdef darwin_HOST_OS- jLoad jenv (macProfile "8.07")+ jLoad jenv (macProfile [8,0,7]) #else #ifdef mingw32_HOST_OS- jLoad jenv (macProfile "9.01")+ jLoad jenv (windowsProfile [9,0,1]) #endif #endif #endif@@ -54,11 +55,18 @@ assertBool "Doesn't fail" $ not ("error: " `BS.isInfixOf` res) +printRes :: JEnv -> Assertion+printRes jenv = do+ setJData jenv "plot_data" $ JIntArr $ R.copyS $ R.map (fromIntegral :: Int -> CLLong) $ R.fromListUnboxed (R.ix1 3) [1,10,2]+ bsDispatch jenv "plot_data"+ res <- bsOut jenv+ res @?= "1 10 2\n"+ fill :: JEnv -> Assertion fill jenv = do- bsDispatch jenv "random_res =: ? 70 70 $ 1e10"+ bsDispatch jenv "random_res =: ? 50 50 $ 1e10" res <- getJData jenv "random_res"- extrExtent res @?= [70, 70]+ extrExtent res @?= [50, 50] where extrExtent :: JData R.DIM2 -> [Int] extrExtent (JIntArr res) = R.listOfShape $ R.extent res @@ -81,7 +89,7 @@ jSetA :: JEnv -> Assertion jSetA jenv = do let hsArr = R.fromListUnboxed (R.ix1 3) [1,3,6]- setJData jenv "b" (JIntArr $ R.copyS $ R.map (fromIntegral :: Int -> CInt) hsArr)+ setJData jenv "b" (JIntArr $ R.copyS $ R.map (fromIntegral :: Int -> CLLong) hsArr) res <- getJData jenv "b" intList res @?= [1,3,6] @@ -107,7 +115,7 @@ doubleScalar :: JData R.Z -> [CDouble] doubleScalar (JDoubleArr arr) = R.toList arr -intList :: JData R.DIM1 -> [CInt]+intList :: JData R.DIM1 -> [CLLong] intList (JIntArr arr) = R.toList arr jType :: JEnv -> Assertion