Skip to content

Commit d6bf887

Browse files
committed
Merge pull request #33 from cartazio/master
fix long standing fusion bug in enumFromTo_double and improve baseline testing tooling
2 parents 5a6541a + c92992c commit d6bf887

File tree

5 files changed

+63
-15
lines changed

5 files changed

+63
-15
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ before_install:
2222

2323
install:
2424
- travis_retry cabal update
25-
- cabal install --only-dependencies
25+
- cabal install --enable-tests --only-dependencies
2626

2727
script:
28-
- cabal configure -v2
28+
- cabal configure -v2 --enable-tests
2929
- cabal build
3030
- cabal sdist
3131
- export SRC_TGZ=$(cabal info . | awk '{print $2 ".tar.gz";exit}') ;

Data/Vector/Fusion/Bundle/Monadic.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ enumFromTo_char x y = x `seq` y `seq` fromStream (Stream step xn) (Exact n)
943943

944944
enumFromTo_double :: (Monad m, Ord a, RealFrac a) => a -> a -> Bundle m v a
945945
{-# INLINE_FUSED enumFromTo_double #-}
946-
enumFromTo_double n m = n `seq` m `seq` fromStream (Stream step n) (Max (len n m))
946+
enumFromTo_double n m = n `seq` m `seq` fromStream (Stream step n) (Max (len n lim))
947947
where
948948
lim = m + 1/2 -- important to float out
949949

tests/Tests/Move.hs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module Tests.Move (tests) where
22

33
import Test.QuickCheck
44
import Test.Framework.Providers.QuickCheck2
5+
import Test.QuickCheck.Property (Property(..))
56

67
import Utilities ()
78

@@ -14,18 +15,18 @@ import qualified Data.Vector.Storable as S
1415
import qualified Data.Vector.Unboxed as U
1516

1617
basicMove :: G.Vector v a => v a -> Int -> Int -> Int -> v a
17-
basicMove v dstOff srcOff len
18+
basicMove v dstOff srcOff len
1819
| len > 0 = G.modify (\ mv -> G.copy (M.slice dstOff len mv) (G.slice srcOff len v)) v
1920
| otherwise = v
2021

2122
testMove :: (G.Vector v a, Show (v a), Eq (v a)) => v a -> Property
22-
testMove v = G.length v > 0 ==> (do
23+
testMove v = G.length v > 0 ==> (MkProperty $ do
2324
dstOff <- choose (0, G.length v - 1)
2425
srcOff <- choose (0, G.length v - 1)
2526
len <- choose (1, G.length v - max dstOff srcOff)
26-
let expected = basicMove v dstOff srcOff len
27-
let actual = G.modify (\ mv -> M.move (M.slice dstOff len mv) (M.slice srcOff len mv)) v
28-
printTestCase ("Move: " ++ show (v, dstOff, srcOff, len)) (expected == actual))
27+
expected <- return $ basicMove v dstOff srcOff len
28+
actual <- return $ G.modify (\ mv -> M.move (M.slice dstOff len mv) (M.slice srcOff len mv)) v
29+
unProperty $ counterexample ("Move: " ++ show (v, dstOff, srcOff, len)) (expected == actual))
2930

3031
tests =
3132
[testProperty "Data.Vector.Mutable (Move)" (testMove :: V.Vector Int -> Property),

tests/Tests/Vector.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Tests.Vector (tests) where
22

33
import Boilerplater
4-
import Utilities
4+
import Utilities as Util
55

66
import qualified Data.Vector.Generic as V
77
import qualified Data.Vector
@@ -118,7 +118,7 @@ testPolymorphicFunctions _ = $(testProperties [
118118
'prop_concat,
119119

120120
-- Restricting memory usage
121-
'prop_force,
121+
'prop_force,
122122

123123

124124
-- Bulk updates (FIXME)
@@ -213,7 +213,7 @@ testPolymorphicFunctions _ = $(testProperties [
213213
prop_concat :: P ([v a] -> v a) = V.concat `eq` concat
214214
prop_force :: P (v a -> v a) = V.force `eq` id
215215
prop_generate :: P (Int -> (Int -> a) -> v a)
216-
= (\n _ -> n < 1000) ===> V.generate `eq` generate
216+
= (\n _ -> n < 1000) ===> V.generate `eq` Util.generate
217217
prop_iterateN :: P (Int -> (a -> a) -> a -> v a)
218218
= (\n _ _ -> n < 1000) ===> V.iterateN `eq` (\n f -> take n . iterate f)
219219

@@ -357,7 +357,7 @@ testPolymorphicFunctions _ = $(testProperties [
357357
V.scanl1 `eq` scanl1
358358
prop_scanl1' :: P ((a -> a -> a) -> v a -> v a) = notNull2 ===>
359359
V.scanl1' `eq` scanl1
360-
360+
361361
prop_prescanr :: P ((a -> a -> a) -> a -> v a -> v a)
362362
= V.prescanr `eq` prescanr
363363
prop_prescanr' :: P ((a -> a -> a) -> a -> v a -> v a)
@@ -395,7 +395,7 @@ testPolymorphicFunctions _ = $(testProperties [
395395
--prop_mapAccumL = eq3
396396
-- (V.mapAccumL :: (X -> W -> (X,W)) -> X -> B -> (X, B))
397397
-- ( mapAccumL :: (X -> W -> (X,W)) -> X -> [W] -> (X, [W]))
398-
--
398+
--
399399
--prop_mapAccumR = eq3
400400
-- (V.mapAccumR :: (X -> W -> (X,W)) -> X -> B -> (X, B))
401401
-- ( mapAccumR :: (X -> W -> (X,W)) -> X -> [W] -> (X, [W]))
@@ -529,7 +529,7 @@ testNestedVectorFunctions _ = $(testProperties [])
529529
where
530530
-- Prelude
531531
--prop_concat = (V.concat :: [v a] -> v a) `eq1` concat
532-
532+
533533
-- Data.List
534534
--prop_transpose = V.transpose `eq1` (transpose :: [v a] -> [v a])
535535
--prop_group = V.group `eq1` (group :: v a -> [v a])

vector.cabal

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ Build-Type: Simple
3939

4040
Extra-Source-Files:
4141
README.md
42-
tests/vector-tests.cabal
4342
tests/LICENSE
4443
tests/Setup.hs
4544
tests/Main.hs
@@ -157,3 +156,51 @@ Library
157156
source-repository head
158157
type: git
159158
location: https://github.com/haskell/vector.git
159+
160+
161+
162+
test-suite vector-tests-O0
163+
Default-Language: Haskell2010
164+
type: exitcode-stdio-1.0
165+
Main-Is: Main.hs
166+
hs-source-dirs: tests
167+
Build-Depends: base >= 4 && < 5, template-haskell, vector,
168+
random,
169+
QuickCheck >= 2.7 && < 2.8 , test-framework, test-framework-quickcheck2,
170+
transformers >= 0.2.0.0
171+
172+
default-extensions: CPP,
173+
ScopedTypeVariables,
174+
PatternGuards,
175+
MultiParamTypeClasses,
176+
FlexibleContexts,
177+
Rank2Types,
178+
TypeSynonymInstances,
179+
TypeFamilies,
180+
TemplateHaskell
181+
182+
Ghc-Options: -O0
183+
Ghc-Options: -Wall -fno-warn-orphans -fno-warn-missing-signatures
184+
185+
test-suite vector-tests-O2
186+
Default-Language: Haskell2010
187+
type: exitcode-stdio-1.0
188+
Main-Is: Main.hs
189+
hs-source-dirs: tests
190+
Build-Depends: base >= 4 && < 5, template-haskell, vector,
191+
random,
192+
QuickCheck >= 2.7, test-framework, test-framework-quickcheck2,
193+
transformers >= 0.2.0.0
194+
195+
default-extensions: CPP,
196+
ScopedTypeVariables,
197+
PatternGuards,
198+
MultiParamTypeClasses,
199+
FlexibleContexts,
200+
Rank2Types,
201+
TypeSynonymInstances,
202+
TypeFamilies,
203+
TemplateHaskell
204+
205+
Ghc-Options: -O2
206+
Ghc-Options: -Wall -fno-warn-orphans -fno-warn-missing-signatures

0 commit comments

Comments
 (0)