File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
module ArrayFire.ArithSpec where
33

44
import ArrayFire hiding (acos)
5-
import Prelude hiding (sqrt, div, and, or, not, isNaN)
5+
import Prelude hiding (abs, sqrt, div, and, or, not, isNaN)
66
import Test.Hspec
77
import Foreign.C
88

@@ -27,10 +27,12 @@ spec =
2727
matrix @Int (2,2) [[1,1],[1,1]] + matrix @Int (2,2) [[1,1],[1,1]]
2828
`shouldBe`
2929
matrix @Int (2,2) [[2,2],[2,2]]
30+
-- Exact comparisons of Double don't make sense here, so we just check that the result is
31+
-- accurate up to some epsilon.
3032
it "Should take cubed root" $ do
31-
3 `shouldBe` cbrt @Double 27
33+
allTrueAll ((abs (3 - cbrt @Double 27)) `lt` 1.0e-14) `shouldBe` (1, 0)
3234
it "Should take square root" $ do
33-
2 `shouldBe` sqrt @Double 4
35+
allTrueAll ((abs (2 - sqrt @Double 4)) `lt` 1.0e-14) `shouldBe` (1, 0)
3436

3537
it "Should lte Array" $ do
3638
2 `le` (3 :: Array Double) `shouldBe` 1
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ spec =
3030
A.getSizeOf (Proxy @(Complex Float)) `shouldBe` 8
3131
A.getSizeOf (Proxy @(Complex Double)) `shouldBe` 16
3232
it "Should get version" $ do
33-
x <- A.getVersion
34-
x `shouldBe` (3,8,2)
33+
(major, minor, ) <- A.getVersion
34+
major `shouldBe` 3
35+
minor `shouldBe` 8
36+
`shouldSatisfy` (>= 0)
3537
it "Should get revision" $ do
3638
x <- A.getRevision
3739
x `shouldSatisfy` (not . null)

0 commit comments

Comments
 (0)