1- module GraphBLAS.FSharp.Tests.Backend.Vector.ContainNonZero
1+ module GraphBLAS.FSharp.Tests.Backend.Common.Exists
22
33open Expecto
44open Expecto.Logging
5+ open GraphBLAS.FSharp .Backend .Common
56open GraphBLAS.FSharp .Tests
67open GraphBLAS.FSharp .Tests .Utils
78open Context
@@ -37,6 +38,12 @@ let correctnessGenericTest<'a when 'a: struct and 'a: equality> isZero containsN
3738 $" The results should be the same, vector : {vector}"
3839 |> Expect.equal result ( Array.exists ( not << isZero) array)
3940
41+ let predicate < 'a when 'a : struct > =
42+ <@ fun ( item : 'a option ) ->
43+ match item with
44+ Some _ -> true
45+ | _ -> false @>
46+
4047let testFixtures =
4148 let config = defaultConfig
4249
@@ -46,49 +53,49 @@ let testFixtures =
4653 sprintf " Correctness on %s , %A " datatype Dense
4754
4855 [ let containsNonZeroInt =
49- DenseVector.containsNonZero context wgSize
56+ ClArray.exists context wgSize predicate
5057
5158 correctnessGenericTest< int> ((=) 0 ) containsNonZeroInt
5259 |> testPropertyWithConfig config ( getCorrectnessTestName " int" )
5360
5461 let containsNonZeroByte =
55- DenseVector.containsNonZero context wgSize
62+ ClArray.exists context wgSize predicate
5663
5764 correctnessGenericTest< byte> ((=) 0 uy) containsNonZeroByte
5865 |> testPropertyWithConfig config ( getCorrectnessTestName " byte" )
5966
6067 let containsNonZeroFloat =
61- DenseVector.containsNonZero context wgSize
68+ ClArray.exists context wgSize predicate
6269
6370 correctnessGenericTest< float> ((=) 0.0 ) containsNonZeroFloat
6471 |> testPropertyWithConfig config ( getCorrectnessTestName " float" )
6572
6673 let containsNonZeroBool =
67- DenseVector.containsNonZero context wgSize
74+ ClArray.exists context wgSize predicate
6875
6976 correctnessGenericTest< bool> ((=) false ) containsNonZeroBool
7077 |> testPropertyWithConfig config ( getCorrectnessTestName " bool" )
7178
7279 let containsNonZeroInt =
73- DenseVector.containsNonZero context wgSize
80+ ClArray.exists context wgSize predicate
7481
7582 correctnessGenericTest< int> ((=) 0 ) containsNonZeroInt ( Array.create 1000 0 )
7683 |> testPropertyWithConfig config ( getCorrectnessTestName " int zeros" )
7784
7885 let containsNonZeroByte =
79- DenseVector.containsNonZero context wgSize
86+ ClArray.exists context wgSize predicate
8087
8188 correctnessGenericTest< byte> ((=) 0 uy) containsNonZeroByte ( Array.create 1000 0 uy)
8289 |> testPropertyWithConfig config ( getCorrectnessTestName " byte zeros" )
8390
8491 let containsNonZeroFloat =
85- DenseVector.containsNonZero context wgSize
92+ ClArray.exists context wgSize predicate
8693
8794 correctnessGenericTest< float> ((=) 0.0 ) containsNonZeroFloat ( Array.create 1000 0.0 )
8895 |> testPropertyWithConfig config ( getCorrectnessTestName " float zeros" )
8996
9097 let containsNonZeroBool =
91- DenseVector.containsNonZero context wgSize
98+ ClArray.exists context wgSize predicate
9299
93100 correctnessGenericTest< bool> ((=) false ) containsNonZeroBool ( Array.create 1000 false )
94101 |> testPropertyWithConfig config ( getCorrectnessTestName " bool zeros" ) ]
0 commit comments