mirror of
https://github.com/Haskell-Things/ImplicitCAD.git
synced 2024-09-17 16:08:01 +03:00
Fix whitespace.
It appears ormolu-disable only *almost* disables it, but i'd say the changes it still makes are straight-forward enough that we can just run with them.
This commit is contained in:
parent
2d1b95d1eb
commit
7a86654b5c
@ -196,7 +196,6 @@ writePNG2
|
||||
-> IO ()
|
||||
writePNG2 = Export.writePNG
|
||||
|
||||
|
||||
-- | Export a PNG of the 'SymbolicObj3'. The projection is with a front-facing
|
||||
-- camera, so the coordinate system is @(left to right, front to back, down to
|
||||
-- up)@.
|
||||
|
@ -248,7 +248,6 @@ instance (Show obj, Show vec) => Show (SharedObj obj vec) where
|
||||
EmbedBoxedObj _ -> showCon "implicit" @| Blackhole
|
||||
WithRounding r obj -> showCon "withRounding" @| r @| obj
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | A type whose show instance is a hole @_@. Used for giving 'Show' instances
|
||||
-- to data types which contain functions or other unshowable things.
|
||||
@ -257,7 +256,6 @@ data Blackhole = Blackhole
|
||||
instance Show Blackhole where
|
||||
show _ = "_"
|
||||
|
||||
|
||||
newtype ObjectContext = ObjectContext
|
||||
{ objectRounding :: ℝ
|
||||
} deriving (Eq, Ord, Show)
|
||||
@ -267,7 +265,6 @@ defaultObjectContext = ObjectContext
|
||||
{ objectRounding = 0
|
||||
}
|
||||
|
||||
|
||||
-- | A symbolic 2D object format.
|
||||
-- We want to have symbolic objects so that we can
|
||||
-- accelerate rendering & give ideal meshes for simple
|
||||
@ -294,13 +291,10 @@ instance Show SymbolicObj2 where
|
||||
Rotate2 v obj -> showCon "rotate" @| v @| obj
|
||||
Shared2 obj -> flip showsPrec obj
|
||||
|
||||
|
||||
|
||||
-- | Semigroup under 'Graphic.Implicit.Primitives.union'.
|
||||
instance Semigroup SymbolicObj2 where
|
||||
a <> b = Shared2 (UnionR 0 [a, b])
|
||||
|
||||
|
||||
-- | Monoid under 'Graphic.Implicit.Primitives.union'.
|
||||
instance Monoid SymbolicObj2 where
|
||||
mempty = Shared2 Empty
|
||||
@ -353,7 +347,6 @@ instance Show SymbolicObj3 where
|
||||
showCon "extrudeOnEdgeOf" @| s @| s1
|
||||
Shared3 s -> flip showsPrec s
|
||||
|
||||
|
||||
infixl 2 @||
|
||||
------------------------------------------------------------------------------
|
||||
-- | ImplicitCAD uses the pattern @Either a (b -> c)@ for many of its
|
||||
@ -366,7 +359,6 @@ showF @|| x = showApp showF $ case x of
|
||||
Left a -> showCon "Left" @| a
|
||||
Right _ -> showCon "Right" @| Blackhole
|
||||
|
||||
|
||||
-- | Semigroup under 'Graphic.Implicit.Primitives.union'.
|
||||
instance Semigroup SymbolicObj3 where
|
||||
a <> b = Shared3 (UnionR 0 [a, b])
|
||||
|
@ -173,4 +173,3 @@ traceRay ray@(Ray cameraP cameraV) step box (Scene obj objColor lights defaultCo
|
||||
)
|
||||
Nothing -> defaultColor
|
||||
|
||||
|
||||
|
@ -31,7 +31,6 @@ import Linear (V2(V2))
|
||||
To allow data sharing, lots of values we
|
||||
could calculate are instead arguments.
|
||||
|
||||
|
||||
positions obj values
|
||||
--------- ----------
|
||||
|
||||
@ -39,7 +38,6 @@ import Linear (V2(V2))
|
||||
: : => : :
|
||||
(x1,y1) .. (x2,y1) x1y1 .. x2y2
|
||||
|
||||
|
||||
mid points
|
||||
----------
|
||||
|
||||
|
@ -24,7 +24,6 @@ tesselateLoop _ _ [] = []
|
||||
|
||||
tesselateLoop _ _ [[a,b],[_,c],[_,_]] = [Tris $ TriangleMesh [Triangle (a,b,c)]]
|
||||
|
||||
|
||||
{-
|
||||
#____# #____#
|
||||
| | | |
|
||||
@ -93,7 +92,6 @@ tesselateLoop res obj pathSides = pure $ Tris $ TriangleMesh $
|
||||
then early_tris <> [Triangle (a,b,mid') | (a,b) <- zip path (tail path <> [head path]) ]
|
||||
else early_tris <> [Triangle (a,b,mid) | (a,b) <- zip path (tail path <> [head path]) ]
|
||||
|
||||
|
||||
shrinkLoop :: ℕ -> [ℝ3] -> ℝ -> Obj3 -> ([Triangle], [ℝ3])
|
||||
|
||||
shrinkLoop _ path@[a,b,c] res obj =
|
||||
|
@ -55,7 +55,6 @@ call = callToken ("[", "]")
|
||||
callNaked :: Builder -> [Builder] -> [Reader a Builder] -> Reader a Builder
|
||||
callNaked = callToken ("", "")
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Class which allows us to build the contained objects in 'buildShared'.
|
||||
class Build obj where
|
||||
@ -67,7 +66,6 @@ instance Build SymbolicObj2 where
|
||||
instance Build SymbolicObj3 where
|
||||
build = buildS3
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Unpack a dimensionality-polymorphic vector into multiple arguments.
|
||||
vectAsArgs :: VectorStuff vec => vec -> [Builder]
|
||||
@ -78,7 +76,6 @@ vectAsArgs = fmap bf . elements
|
||||
bvect :: VectorStuff vec => vec -> Builder
|
||||
bvect v = "[" <> fold (intersperse "," $ vectAsArgs v) <> "]"
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Build the common combinators.
|
||||
buildShared :: forall obj vec. (Build obj, VectorStuff vec) => SharedObj obj vec -> Reader ℝ Builder
|
||||
@ -121,7 +118,6 @@ buildShared(Shell _ _) = error "cannot provide roundness when exporting openscad
|
||||
buildShared(EmbedBoxedObj _) = error "cannot provide roundness when exporting openscad; unsupported in target format."
|
||||
buildShared (WithRounding _ _) = error "cannot provide roundness when exporting openscad; unsupported in target format."
|
||||
|
||||
|
||||
-- | First, the 3D objects.
|
||||
buildS3 :: SymbolicObj3 -> Reader ℝ Builder
|
||||
|
||||
@ -144,7 +140,6 @@ buildS3 (Rotate3 q obj) =
|
||||
|
||||
buildS3 (Extrude obj h) = callNaked "linear_extrude" ["height = " <> bf h] [buildS2 obj]
|
||||
|
||||
|
||||
-- FIXME: handle scale, center.
|
||||
buildS3 (ExtrudeM twist scale (Left translate) obj (Left height)) |isScaleID scale && translate == V2 0 0 = do
|
||||
res <- ask
|
||||
|
@ -4,7 +4,6 @@
|
||||
-- Copyright 2014 2015 2016, Julia Longtin (julial@turinglace.com)
|
||||
-- Released under the GNU AGPLV3+, see LICENSE
|
||||
|
||||
|
||||
-- Allow us to use string literals for Text
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
@ -140,7 +139,6 @@ matchCAT = P.reservedOp lexer "++" >> pure "++"
|
||||
matchEXP :: GenParser Char st Char
|
||||
matchEXP = P.reservedOp lexer "^" >> pure '^'
|
||||
|
||||
|
||||
-- | match something between two ends.
|
||||
surroundedBy :: Char -> GenParser Char st a -> Char -> GenParser Char st a
|
||||
surroundedBy leftTok middle rightTok = between (matchTok leftTok) (matchTok rightTok) middle
|
||||
|
@ -49,7 +49,6 @@ parseProgram = parse program where
|
||||
program :: GenParser Char st [StatementI]
|
||||
program = removeNoOps <$> (whiteSpace *> many (computation A1) <* eof)
|
||||
|
||||
|
||||
-- | A computable block of code in our openscad-like programming language.
|
||||
computation :: CompIdx -> GenParser Char st StatementI
|
||||
computation A1 =
|
||||
|
@ -228,7 +228,6 @@ cylinder = moduleWithoutSuite "cylinder" $ \_ _ -> do
|
||||
`doc` "top diameter; overrides d"
|
||||
pure (diameter/2, diameter1/2, diameter2/2)
|
||||
|
||||
|
||||
h :: Either ℝ ℝ2 <- argument "h"
|
||||
`defaultTo` Left 1
|
||||
`doc` "height of cylinder"
|
||||
@ -486,7 +485,6 @@ rotateExtrude = moduleWithSuite "rotate_extrude" $ \_ children -> do
|
||||
. rotateExtrudeDegrees totalRot translateArg rotateArg
|
||||
) children
|
||||
|
||||
|
||||
-- | Like 'Prim.rotateExtrude', but operates in degrees instead of radians.
|
||||
-- This is a shim for scad, which expects this function to operate in degrees.
|
||||
rotateExtrudeDegrees
|
||||
|
@ -134,7 +134,6 @@ pack (dx, dy) sep objs = packSome sortedObjs (dx, dy)
|
||||
tmap2 (presObj:) $ packSome otherBoxedObjs box
|
||||
packSome [] _ = ([], [])
|
||||
|
||||
|
||||
-- | Reflect a vector across a hyperplane defined by its normal vector.
|
||||
--
|
||||
-- From https://en.wikipedia.org/wiki/Reflection_(mathematics)#Reflection_through_a_hyperplane_in_n_dimensions
|
||||
|
@ -22,7 +22,6 @@ import Graphics.Implicit.ObjectUtil.GetBoxShared (emptyBox, corners, outsetBox,
|
||||
-- To construct vectors of ℝs.
|
||||
import Linear (V2(V2))
|
||||
|
||||
|
||||
-- Get a Box2 around the given object.
|
||||
getBox2 :: SymbolicObj2 -> Box2
|
||||
-- Primitives
|
||||
@ -36,7 +35,6 @@ getBox2 (Rotate2 θ symbObj) =
|
||||
in pointsBox $ fmap rotate $ corners $ getBox2 symbObj
|
||||
getBox2 (Shared2 obj) = getBoxShared obj
|
||||
|
||||
|
||||
-- | Define a Box2 around the given object, and the space it occupies while rotating about the center point.
|
||||
-- Note: No implementations for Square, Translate2, or Scale2 as they would be identical to the fallthrough.
|
||||
getBox2R :: SymbolicObj2 -> ℝ -> Box2
|
||||
|
@ -146,7 +146,6 @@ getBox3 (RotateExtrude rot (Right f) rotate symbObj) =
|
||||
in
|
||||
(V3 (-r) (-r) $ y1 + ymin', V3 r r $ y2 + ymax')
|
||||
|
||||
|
||||
unpack :: V2 a -> (a, a)
|
||||
unpack (V2 a b) = (a, b)
|
||||
|
||||
|
@ -20,7 +20,6 @@ import Linear (Metric, V2(V2), V3(V3))
|
||||
import Data.Foldable (Foldable(toList))
|
||||
import Control.Applicative (Applicative(liftA2))
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Ad-hoc methods we need to share code between 2D and 3D. With the exception
|
||||
-- of 'corners', these are actually all standard methods of other classes,
|
||||
@ -38,7 +37,6 @@ class VectorStuff vec where
|
||||
-- | Given a bounding box, produce the points at each corner.
|
||||
corners :: (vec, vec) -> [vec]
|
||||
|
||||
|
||||
instance VectorStuff ℝ2 where
|
||||
uniformV = pure
|
||||
corners (p1@(V2 x1 y1), p2@(V2 x2 y2)) =
|
||||
@ -73,7 +71,6 @@ instance VectorStuff ℝ3 where
|
||||
{-# INLINABLE elements #-}
|
||||
{-# INLINABLE corners #-}
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Compute the intersection of dimensionality-polymorphic bounding boxes.
|
||||
intersectBoxes
|
||||
@ -95,7 +92,6 @@ biapp
|
||||
biapp f g (a1, b1) (a2, b2) = (f a1 a2, g b1 b2)
|
||||
{-# INLINABLE biapp #-}
|
||||
|
||||
|
||||
-- | An empty box.
|
||||
emptyBox :: (Applicative f, Num a) => (f a, f a)
|
||||
emptyBox = (pure 0, pure 0)
|
||||
@ -111,7 +107,6 @@ pointsBox :: (Applicative f, Num a, VectorStuff (f a)) => [f a] -> (f a, f a)
|
||||
pointsBox [] = emptyBox
|
||||
pointsBox (a : as) = (foldr (pointwise min) a as, foldr (pointwise max) a as)
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Compute the intersection of dimensionality-polymorphic bounding boxes.
|
||||
unionBoxes :: (VectorStuff (f a), Applicative f, Eq (f a), Num a, Num (f a)) => ℝ -> [(f a, f a)] -> (f a, f a)
|
||||
|
@ -20,8 +20,6 @@ import Data.List (nub)
|
||||
import Graphics.Implicit.ObjectUtil.GetImplicitShared (getImplicitShared)
|
||||
import Linear (V2(V2))
|
||||
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Filter out equal consecutive elements in the list. This function will
|
||||
-- additionally trim the last element of the list if it's equal to the first.
|
||||
@ -31,7 +29,6 @@ scanUniqueCircular
|
||||
. filter (uncurry (/=))
|
||||
. circularPairs
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Given @[a, b, c, ... n]@, return the pairs @[(a, b), (b, c), ... (n, a)]@.
|
||||
circularPairs :: [a] -> [(a,a)]
|
||||
|
@ -24,7 +24,6 @@ import Graphics.Implicit.ObjectUtil.GetBoxShared (VectorStuff(elements, uniformV
|
||||
|
||||
import Linear (Metric(dot))
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Normalize a dimensionality-polymorphic vector.
|
||||
normalize
|
||||
@ -36,7 +35,6 @@ normalize v =
|
||||
let all1s = uniformV @(f ℝ) 1
|
||||
in abs (product (elements v)) ** (1 / (all1s `dot` all1s))
|
||||
|
||||
|
||||
-- Get a function that describes the surface of the object.
|
||||
getImplicitShared
|
||||
:: forall obj f
|
||||
|
@ -117,7 +117,6 @@ cube
|
||||
cube False size = Cube size
|
||||
cube True size = translate (fmap (negate . (/ 2)) size) $ Cube size
|
||||
|
||||
|
||||
-- | A conical frustum --- ie. a cylinder with different radii at either end.
|
||||
cylinder2 ::
|
||||
ℝ -- ^ Radius of the cylinder
|
||||
@ -206,7 +205,6 @@ pattern Shared v <- (preview _Shared -> Just v)
|
||||
where
|
||||
Shared v = _Shared # v
|
||||
|
||||
|
||||
-- | Translate an object by a vector of appropriate dimension.
|
||||
translate
|
||||
:: Object obj vec
|
||||
@ -333,7 +331,6 @@ implicit
|
||||
-> obj -- ^ Resulting object
|
||||
implicit a b = Shared $ EmbedBoxedObj (a, b)
|
||||
|
||||
|
||||
instance Object SymbolicObj2 ℝ2 where
|
||||
_Shared = prism' Shared2 $ \case
|
||||
Shared2 x -> Just x
|
||||
@ -348,7 +345,6 @@ instance Object SymbolicObj3 ℝ3 where
|
||||
getBox = getBox3
|
||||
getImplicit' = getImplicit3
|
||||
|
||||
|
||||
union :: Object obj vec => [obj] -> obj
|
||||
union = unionR 0
|
||||
|
||||
@ -379,7 +375,6 @@ extrudeM
|
||||
-> SymbolicObj3
|
||||
extrudeM = ExtrudeM
|
||||
|
||||
|
||||
rotateExtrude
|
||||
:: ℝ -- ^ Angle to sweep to (in rad)
|
||||
-> Either ℝ2 (ℝ -> ℝ2) -- ^ translate
|
||||
|
@ -237,4 +237,3 @@ executeAndExport content callback maybeFormat =
|
||||
([], [] , _) -> callbackF False False 1 $ scadMessages <> "\n" <> "Nothing to render."
|
||||
_ -> callbackF False False 1 $ scadMessages <> "\n" <> "ERROR: File contains a mixture of 2D and 3D objects, what do you want to render?"
|
||||
|
||||
|
||||
|
@ -19,7 +19,6 @@ import Graphics.Implicit.Definitions (ℝ)
|
||||
-- Expressions, symbols, and values in the OpenScad language.
|
||||
import Graphics.Implicit.ExtOpenScad.Definitions (OVal(ONum))
|
||||
|
||||
|
||||
import Graphics.Implicit.ExtOpenScad.Eval.Constant (runExpr)
|
||||
|
||||
import Test.Hspec (Expectation, shouldBe)
|
||||
|
@ -106,7 +106,6 @@ spec = describe "golden tests" $ do
|
||||
])
|
||||
]
|
||||
|
||||
|
||||
-- These tests were generated by the Arbitrary instance
|
||||
golden "arbitrary1" 1 $
|
||||
cylinder 16.76324 21.02933
|
||||
|
@ -11,7 +11,6 @@ import System.Directory (getTemporaryDirectory, doesFileExist)
|
||||
import System.IO (hClose, openTempFile)
|
||||
import Test.Hspec (it, shouldBe, SpecWith)
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Construct a golden test for rendering the given 'SymbolicObj3' at the
|
||||
-- specified resolution. On the first run of this test, it will render the
|
||||
@ -42,7 +41,6 @@ golden name resolution sym = it (name <> " (golden)") $ do
|
||||
then pure ()
|
||||
else False `shouldBe` True
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Get a temporary filepath with the desired extension. On unix systems, this
|
||||
-- is a file under @/tmp@. Useful for tests that need to write files.
|
||||
|
@ -82,7 +82,6 @@ instance Arbitrary SymbolicObj2 where
|
||||
, pure emptySpace
|
||||
]
|
||||
|
||||
|
||||
-- TODO(sandy): Also generate all of the extrusion variants.
|
||||
instance Arbitrary SymbolicObj3 where
|
||||
shrink = genericShrink
|
||||
@ -132,7 +131,6 @@ instance CoArbitrary ℝ2 where
|
||||
instance CoArbitrary ℝ3 where
|
||||
coarbitrary (V3 a b c) = coarbitrary (a, b, c)
|
||||
|
||||
|
||||
instance Arbitrary ExtrudeMScale where
|
||||
shrink = genericShrink
|
||||
arbitrary = oneof
|
||||
@ -141,7 +139,6 @@ instance Arbitrary ExtrudeMScale where
|
||||
, Fn <$> arbitrary
|
||||
]
|
||||
|
||||
|
||||
instance Arbitrary (Quaternion ℝ) where
|
||||
arbitrary = do
|
||||
q <- arbitrary
|
||||
@ -150,21 +147,18 @@ instance Arbitrary (Quaternion ℝ) where
|
||||
then discard
|
||||
else pure $ axisAngle v q
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Two 'SymbolicObj2's are the same if their 'getImplicit' functions agree at
|
||||
-- all points (up to an error term of 'epsilon')
|
||||
instance Observe (ℝ2, ()) Insidedness SymbolicObj2 where
|
||||
observe p = insidedness . observe p . getImplicit
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Two 'SymbolicObj3's are the same if their 'getImplicit' functions agree at
|
||||
-- all points (up to an error term of 'epsilon')
|
||||
instance Observe (ℝ3, ()) Insidedness SymbolicObj3 where
|
||||
observe p = insidedness . observe p . getImplicit
|
||||
|
||||
|
||||
-- | Generate a small list of 'Arbitrary' elements, splitting the current
|
||||
-- complexity budget between all of them.
|
||||
decayedList :: Arbitrary a => Gen [a]
|
||||
|
@ -4,7 +4,6 @@ module Graphics.Implicit.Test.Utils where
|
||||
import Prelude (drop, (<*>), (<$>), take, length, pure)
|
||||
import Test.QuickCheck ( choose, Gen )
|
||||
|
||||
|
||||
randomGroups :: [a] -> Gen [[a]]
|
||||
randomGroups [] = pure []
|
||||
randomGroups as = do
|
||||
|
@ -42,7 +42,6 @@ import Graphics.Implicit (extrude)
|
||||
import Graphics.Implicit (cylinder2)
|
||||
import Graphics.Implicit (mirror)
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Tests showing equivalencies between algebraic formulations of symbolic
|
||||
-- objects, in both 2d and 3d. Equality is observational, based on random
|
||||
@ -68,7 +67,6 @@ spec = do
|
||||
rotation3dSpec
|
||||
misc3dSpec
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- All the constraints we need in scope to parameterize tests by both 2d and
|
||||
-- 3d symbolic objects.
|
||||
@ -84,7 +82,6 @@ type TestInfrastructure obj vec test outcome =
|
||||
, Arbitrary vec
|
||||
)
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Tests proving that symbolic objects form a monoid.
|
||||
monoidSpec
|
||||
@ -101,7 +98,6 @@ monoidSpec = describe "monoid laws" $ do
|
||||
prop "(a <> b) <> c = a <> (b <> c)" $ \a b (c :: obj) ->
|
||||
(a <> b) <> c =~= a <> (b <> c)
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Tests showing that 'translate' is a no-op for both 'emptySpace' and
|
||||
-- 'fullSpace'. Additionally, that 'scale' is a no-op on 'emptySpace' (but not
|
||||
@ -125,7 +121,6 @@ idempotenceSpec = describe "idempotence" $ do
|
||||
withRounding r . withRounding r'
|
||||
=~= withRounding @obj r'
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Proofs of the invertability of operations.
|
||||
inverseSpec
|
||||
@ -149,7 +144,6 @@ inverseSpec = describe "inverses" $ do
|
||||
-- -- scale @obj xyz . scale (invert xyz)
|
||||
-- -- =~= id
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Proofs that 'fullSpace' is an annhilative element with respect to union.
|
||||
annihilationSpec
|
||||
@ -164,7 +158,6 @@ annihilationSpec = describe "annihilation" $ do
|
||||
obj <> fullSpace
|
||||
=~= fullSpace @obj
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Misc proofs regarding 2d rotation.
|
||||
rotation2dSpec :: Spec
|
||||
@ -189,7 +182,6 @@ rotation2dSpec = describe "2d rotation" $ do
|
||||
rotate rads emptySpace
|
||||
=~= emptySpace
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Misc proofs regarding 3d rotation.
|
||||
rotation3dSpec :: Spec
|
||||
@ -227,7 +219,6 @@ rotation3dSpec = describe "3d rotation" $ do
|
||||
rotate3 xyz emptySpace
|
||||
=~= emptySpace
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Misc tests that make sense only in 3d
|
||||
misc3dSpec :: Spec
|
||||
@ -239,7 +230,6 @@ misc3dSpec = describe "misc 3d tests" $ do
|
||||
prop "cylinder with negative height is a flipped cylinder with positive height" $ \r1 r2 h ->
|
||||
cylinder2 r1 r2 h =~= mirror (V3 0 0 1) (cylinder2 r1 r2 (-h))
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Misc identity proofs that should hold for all symbolic objects.
|
||||
identitySpec
|
||||
@ -270,7 +260,6 @@ identitySpec = describe "identity" $ do
|
||||
prop "union [a] = a" $ \obj ->
|
||||
union @obj [obj] =~= obj
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Functions proving symbolic objects form homomorphisms with respect to
|
||||
-- translate and scale.
|
||||
@ -299,7 +288,6 @@ homomorphismSpec = describe "homomorphism" $ do
|
||||
withRounding @obj r_obj . intersectR r_combo
|
||||
=~= intersectR r_combo . fmap (withRounding r_obj)
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Like 'prop', but for tests that are currently expected to fail.
|
||||
failingProp :: Testable prop => String -> prop -> SpecWith ()
|
||||
|
@ -6,7 +6,7 @@ module PropertySpec
|
||||
import Test.Hspec (Spec)
|
||||
import PropertySpec.Exec (additionSpec, subtractionSpec, multiplicationSpec, divisionSpec)
|
||||
|
||||
propSpec :: Spec
|
||||
propSpec :: Spec
|
||||
propSpec = do
|
||||
additionSpec
|
||||
subtractionSpec
|
||||
|
@ -34,7 +34,7 @@ instance Show Op where
|
||||
show Mul = "*"
|
||||
show Div = "/"
|
||||
|
||||
opName :: Op -> String
|
||||
opName :: Op -> String
|
||||
opName Add = "addition"
|
||||
opName Sub = "subttraction"
|
||||
opName Mul = "multiplication"
|
||||
|
@ -22,7 +22,6 @@ import Graphics.Implicit.Test.Instances ()
|
||||
import Control.Monad (join)
|
||||
import Control.Lens (Ixed(ix), (&), (.~) )
|
||||
|
||||
|
||||
spec :: Spec
|
||||
spec = do
|
||||
describe "getLoops" $ do
|
||||
@ -75,8 +74,6 @@ spec = do
|
||||
-- 'fail', but let's make sure they have the same number of segments too.
|
||||
length loop `shouldBe` length loop'
|
||||
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Show that the given loop exists somewhere in the discovered loops.
|
||||
-- Correctly deals with the case where the two loops start at different places.
|
||||
@ -84,7 +81,6 @@ proveLoop :: (Show a, Eq a) => [a] -> [[a]] -> Expectation
|
||||
proveLoop v loops =
|
||||
join (replicate 2 v) `shouldContain` unloop loops
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Generate a loop and random segments that should produce it. The defining
|
||||
-- equation of this generator is tested by "getLoops > loops a loop".
|
||||
@ -100,7 +96,6 @@ genLoop start = do
|
||||
shuffled_segs <- shuffle segs
|
||||
pure (v, shuffled_segs)
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Like 'genLoop', but produces several loops, tagged with an index number.
|
||||
-- For best results, you should call @shuffle . join@ on the resulting segments
|
||||
@ -118,21 +113,18 @@ genManyLoops start n = do
|
||||
-- and tag it with the index
|
||||
pure (fmap (idx,) v, fmap (fmap (idx,)) segs)
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Given a list of lists, insert elements into the 'head' and 'last' of each
|
||||
-- sub-list so that the 'last' of one list is the 'head' of the next.
|
||||
loopify :: [[a]] -> [[a]]
|
||||
loopify as = zipWith (\a -> mappend a . take 1) as $ drop 1 $ join $ repeat as
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Remove sequential elements in a list. Additionally, this function removes
|
||||
-- the 'head' of the list, because conceptully it is also the 'last'.
|
||||
unloop :: Eq a => [[a]] -> [a]
|
||||
unloop = drop 1 . fmap head . group . join
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Insert an element into the middle (not 'head' or 'last') of a list.
|
||||
insertMiddle :: [a] -> a -> Gen [a]
|
||||
@ -143,7 +135,6 @@ insertMiddle as a = do
|
||||
i <- choose (1, n - 1)
|
||||
pure $ insertAt i a as
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Helper function to insert an element into a list at a given position.
|
||||
--
|
||||
|
Loading…
Reference in New Issue
Block a user