boundingboxes 0.2.2 → 0.2.3
raw patch · 3 files changed
+7/−60 lines, 3 filesdep −QuickCheckdep −boundingboxesdep −lineardep ~basedep ~lens
Dependencies removed: QuickCheck, boundingboxes, linear, random, test-framework, test-framework-quickcheck2, test-framework-th
Dependency ranges changed: base, lens
Files
- Data/BoundingBox.hs +2/−2
- boundingboxes.cabal +5/−20
- tests/properties.hs +0/−38
Data/BoundingBox.hs view
@@ -63,10 +63,10 @@ f (Box p q) = (liftA2 (-) q p, (+) <$> liftA2 (*) (fmap (1-) k) p <*> liftA2 (*) k q) g (s, v) = Box ((-) <$> v <*> liftA2 (*) k s) ((+) <$> v <*> liftA2 (*) (fmap (1-) k) s) --- | The accessor for the position on the given reference. Usually the reference point +-- | The accessor for the position on the given reference. Usually the reference point position :: (Applicative f, Num a) => f a -> Lens' (Box f a) (f a) position ref = sizePos ref . _2 -- | The accessor for the size. A given reference point will be a center of resizing. size :: (Applicative f, Num a) => f a -> Lens' (Box f a) (f a) -size ref = sizePos ref . _1+size ref = sizePos ref . _1
boundingboxes.cabal view
@@ -1,7 +1,7 @@ name: boundingboxes -version: 0.2.2 +version: 0.2.3 synopsis: A generic boundingbox for an arbitrary vector --- description: +-- description: homepage: https://github.com/fumieval/boundingboxes license: BSD3 license-file: LICENSE @@ -10,28 +10,13 @@ copyright: Copyright (c) 2014 Fumiaki Kinoshita category: Data build-type: Simple --- extra-source-files: +-- extra-source-files: cabal-version: >=1.10 library exposed-modules: Data.BoundingBox - -- other-modules: + -- other-modules: other-extensions: DeriveFunctor, DeriveFoldable, DeriveTraversable, DeriveDataTypeable, Rank2Types build-depends: base == 4.*, lens >= 3.8 && < 5 - -- hs-source-dirs: - default-language: Haskell2010 - -test-suite properties - type: exitcode-stdio-1.0 + -- hs-source-dirs: default-language: Haskell2010 - build-depends: base - , linear - , lens - , QuickCheck >=2.4 - , test-framework-th >= 0.2 - , test-framework - , test-framework-quickcheck2 >= 0.2 - , random - , boundingboxes - main-is: properties.hs - hs-source-dirs: tests
− tests/properties.hs
@@ -1,38 +0,0 @@-{-# LANGUAGE TemplateHaskell, ViewPatterns, FlexibleInstances #-} -import Data.BoundingBox -import Test.QuickCheck -import Test.Framework.Providers.QuickCheck2 -import Test.Framework.TH -import Control.Lens -import Linear -import Control.Applicative -import System.Random - -instance (Num a, Random a) => Arbitrary (Box V2 a) where - arbitrary = sized $ \n -> let k = fromIntegral n in do - x0 <- choose (-k, 0) - y0 <- choose (-k, 0) - x1 <- choose (0, k) - y1 <- choose (0, k) - return (Box (V2 x0 y0) (V2 x1 y1)) - -newtype Reference = Reference { getReference :: V2 Float } deriving Show - -instance Arbitrary Reference where - arbitrary = fmap Reference $ V2 <$> oneof [pure 0, pure 0.5, pure 1] <*> oneof [pure 0, pure 0.5, pure 1] - -instance Arbitrary a => Arbitrary (V2 a) where - arbitrary = V2 <$> arbitrary <*> arbitrary - -prop_resize bb (getReference -> ref) sz = nearZero $ bb ^. position ref - bb' ^. position ref where - bb' = bb & size ref .~ getPositive sz :: Box V2 Float - -prop_rearrange (getReference -> ref) bb pos = norm (bb ^. size 0 - bb' ^. size 0) < 10e-4 where - bb' = bb & position ref .~ pos :: Box V2 Float - -prop_construct (getReference -> ref) pos (getPositive -> sz) = norm (bb ^. size 0 - sz) < 10e-4 - .&&. norm (bb ^. position ref - pos) < 10e-4 where - - bb = sizePos ref # (sz, pos) :: Box V2 Float - -main = $(defaultMainGenerator)