-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDataSpec.hs
More file actions
39 lines (36 loc) · 1.53 KB
/
DataSpec.hs
File metadata and controls
39 lines (36 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module ArrayFire.DataSpec where
import Control.Exception
import Data.Complex
import Data.Word
import Foreign.C.Types
import GHC.Int
import Test.Hspec
import ArrayFire
spec :: Spec
spec =
describe "Data tests" $ do
it "Should create constant Array" $ do
constant @Float [1] 1 `shouldBe` 1
constant @Double [1] 1 `shouldBe` 1
constant @Int16 [1] 1 `shouldBe` 1
constant @Int32 [1] 1 `shouldBe` 1
constant @Int64 [1] 1 `shouldBe` 1
constant @Int [1] 1 `shouldBe` 1
constant @Word16 [1] 1 `shouldBe` 1
constant @Word32 [1] 1 `shouldBe` 1
constant @Word64 [1] 1 `shouldBe` 1
constant @Word [1] 1 `shouldBe` 1
constant @CBool [1] 1 `shouldBe` 1
constant @(Complex Double) [1] (1.0 :+ 1.0)
`shouldBe`
constant @(Complex Double) [1] (1.0 :+ 1.0)
constant @(Complex Float) [1] (1.0 :+ 1.0)
`shouldBe`
constant @(Complex Float) [1] (1.0 :+ 1.0)
it "Should join Arrays along the specified dimension" $ do
join 0 (constant @Int [1, 3] 1) (constant @Int [1, 3] 2) `shouldBe` mkArray @Int [2, 3] [1, 2, 1, 2, 1, 2]
join 1 (constant @Int [1, 2] 1) (constant @Int [1, 2] 2) `shouldBe` mkArray @Int [1, 4] [1, 1, 2, 2]
joinMany 0 [constant @Int [1, 3] 1, constant @Int [1, 3] 2] `shouldBe` mkArray @Int [2, 3] [1, 2, 1, 2, 1, 2]
joinMany 1 [constant @Int [1, 2] 1, constant @Int [1, 1] 2, constant @Int [1, 3] 3] `shouldBe` mkArray @Int [1, 6] [1, 1, 2, 3, 3, 3]