@@ -47,24 +47,13 @@ arrayTests = testGroup "Array Tests"
4747--------------------------------------------------------------------------------
4848testMakeArray :: TestTree
4949testMakeArray = testGroup " MakeArray Tests"
50- [ caseTests
51- -- TODO: property tests should work for mutable backends too (?)
52- #ifndef MUTABLE_ARRAYS
53- , propertyTests
54- #endif
55- , invalidOperationTests
56- ] where
50+ [ caseTests, propertyTests , invalidOperationTests ] where
5751
5852 -- The case tests for the MakeArray function.
5953 -- Tests that arrays of size 0 and 1 have the proper size and elements.
6054 caseTests :: TestTree
6155 caseTests = testGroup " MakeArray Case Tests"
62- [ testEmptyArray
63- -- TODO: the below should work for mutable backends too (?)
64- #ifndef MUTABLE_ARRAYS
65- , testSizeOneArray
66- #endif
67- ]
56+ [ testEmptyArray, testSizeOneArray ]
6857 where
6958
7059 -- Testing the output of an empty array.
@@ -79,8 +68,11 @@ testMakeArray = testGroup "MakeArray Tests"
7968 QC. forAll QC. arbitrary $ \ (randomElement :: Int ) ->
8069 let customArr = CustomArray. makeArray 1 randomElement
8170 standardArr = makeStandardArray 1 randomElement
82- in CustomArray. size customArr QC. === 1 QC. .&. CustomArray. toList customArr QC. === StandardArray. elems standardArr
83-
71+ in CustomArray. size customArr QC. === 1
72+ -- The mutable backend doesn't initialize array elements, StandardArray(Data.Array) does
73+ #ifndef MUTABLE_ARRAYS
74+ QC. .&. CustomArray. toList customArr QC. === StandardArray. elems standardArr
75+ #endif
8476
8577 -- The property tests for the makeArray function.
8678 -- Tests that random arrays have proper size and elements.
@@ -94,7 +86,11 @@ testMakeArray = testGroup "MakeArray Tests"
9486 QC. forAll ((,) <$> QC. chooseInt (0 , mediumNumber) <*> QC. arbitrary) $ \ (randomSize :: Int , randomElement :: Int ) ->
9587 let customArr = CustomArray. makeArray randomSize randomElement
9688 standardArr = makeStandardArray randomSize randomElement
97- in CustomArray. size customArr QC. === randomSize QC. .&. CustomArray. toList customArr QC. === StandardArray. elems standardArr
89+ in CustomArray. size customArr QC. === randomSize
90+ -- The mutable backend doesn't initialize array elements, StandardArray(Data.Array) does
91+ #ifndef MUTABLE_ARRAYS
92+ QC. .&. CustomArray. toList customArr QC. === StandardArray. elems standardArr
93+ #endif
9894
9995 -- The tests for exception cases of the MakeArray functions.
10096 -- Tests that negative size arrays can't be made.
@@ -260,8 +256,7 @@ testSwap = testGroup "Swap Tests" [ caseTests, performanceTests, propertyTests ]
260256 , testValuesSwapped2
261257 , testValuesSwapped3
262258 , testValuesSwapped4
263- -- TODO: the below should work for mutable backends too
264- #ifndef MUTABLE_ARRAYS
259+ #ifndef PRIM_MUTABLE_ARRAYS
265260 , testSwapSameIndex
266261#endif
267262 ] where
@@ -285,12 +280,14 @@ testSwap = testGroup "Swap Tests" [ caseTests, performanceTests, propertyTests ]
285280 testSwapSameIndex :: TestTree
286281 testSwapSameIndex = testCase " Test Swapping Same Index" $ do
287282 let arr = CustomArray. makeArray 5 (1 :: Int )
288- let swappedArr = CustomOperations. swap arr 2 2
283+ swappedArr = CustomOperations. swap arr 2 2
289284 assertEqual " Array should remain unchanged" 1 (CustomArray. get swappedArr 2 )
290285
291286 -- Test performance for swap.
292287 performanceTests :: TestTree
293- performanceTests = testGroup " Swap Performance Tests" [ testLargeArraySwap ] where
288+ performanceTests = testGroup " Swap Performance Tests" [
289+ testLargeArraySwap
290+ ] where
294291 largeInt = 1000000 * performanceTestMultiplier
295292
296293 -- Test performance of creating and splitting a large.
@@ -304,7 +301,7 @@ testSwap = testGroup "Swap Tests" [ caseTests, performanceTests, propertyTests ]
304301 -- The property tests for the split function.
305302 propertyTests :: TestTree
306303 propertyTests = testGroup " Swap Property Tests" [
307- testSwapCommutative
304+ testSwapCommutative
308305 ] where
309306
310307 -- Generates random arrays to test that swap is commutative.
@@ -326,25 +323,25 @@ testSwap = testGroup "Swap Tests" [ caseTests, performanceTests, propertyTests ]
326323-- TODO: Missing performance and property tests.
327324--------------------------------------------------------------------------------
328325testSplit :: TestTree
329- testSplit = testGroup " Test Split" [ caseTests ] where
326+ testSplit = testGroup " Test Split" [
327+ caseTests
328+ ] where
330329
331330 -- The case tests for the split function.
332331 caseTests :: TestTree
333332 caseTests = testGroup " Split Case Tests" [
334- -- TODO: the below should work for mutable backends too
335- #ifndef MUTABLE_ARRAYS
336333 testSplitMid
337- ,
338- #endif
339- testSplitEmpty
334+ , testSplitEmpty
340335 ] where
341336
342337 -- Testing after splitting an array in the middle the sizes of the left and right are correct.
343338 -- and the contents of the left and right don't change.
344339 -- Hardcoded array size and values.
345340 testSplitMid :: TestTree
346341 testSplitMid = testCase " Test Split Mid" $ do
347- let arr = CustomArray. makeArray 6 (1 :: Int )
342+ -- let arr = CustomArray.makeArray 6 (1 :: Int)
343+ let list = replicate 6 (1 :: Int )
344+ arr = CustomArray. fromList list
348345 let (leftArr, rightArr) = CustomOperations. splitMid arr
349346 assertEqual " Left array size should be 3" 3 (CustomArray. size leftArr)
350347 assertEqual " Right array size should be 3" 3 (CustomArray. size rightArr)
0 commit comments