From d278083947ee22948added3b850b9ffe4c7868a1 Mon Sep 17 00:00:00 2001 From: justin Date: Sun, 29 Mar 2026 15:50:58 +0100 Subject: [PATCH] Check whether tests compile in ghcid --- .ghci | 1 + .ghcid | 2 +- .gitignore | 1 + src/Dodge/Creature/HandPos.hs | 68 ++++++++++++++----------------- src/Dodge/Data/Creature/Stance.hs | 2 +- src/Dodge/Door.hs | 1 + src/Dodge/Item/HeldOffset.hs | 7 ++-- src/Dodge/Room/Tutorial.hs | 3 ++ src/Geometry/Vector.hs | 6 ++- tags | 58 +++++++++++++------------- test/Spec.hs | 30 +++++++++----- 11 files changed, 95 insertions(+), 84 deletions(-) diff --git a/.ghci b/.ghci index eb6321351..3cf952e8b 100644 --- a/.ghci +++ b/.ghci @@ -1 +1,2 @@ :set prompt ">" +:load test/Spec.hs diff --git a/.ghcid b/.ghcid index b30768864..e1cd328dd 100644 --- a/.ghcid +++ b/.ghcid @@ -1 +1 @@ ---command "stack ghci --main-is loop:exe:dodge" +--command "stack ghci --test --main-is loop:test:loop-test --ghci-options=-fobject-code" diff --git a/.gitignore b/.gitignore index dcad9c6fc..1114558ac 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ log/* generated/* tags ghcidOutput +.ghcid.bak diff --git a/src/Dodge/Creature/HandPos.hs b/src/Dodge/Creature/HandPos.hs index 561534177..47194da4f 100644 --- a/src/Dodge/Creature/HandPos.hs +++ b/src/Dodge/Creature/HandPos.hs @@ -1,4 +1,5 @@ {-# LANGUAGE LambdaCase #-} + module Dodge.Creature.HandPos ( equipSitePQ, translatePointToLeftHand, @@ -13,16 +14,16 @@ module Dodge.Creature.HandPos ( rightHandPQ, ) where -import Dodge.Data.Equipment.Misc -import qualified Quaternion as Q import Control.Lens import Dodge.Creature.Test import Dodge.Data.Creature +import Dodge.Data.Equipment.Misc import Geometry +import qualified Quaternion as Q import ShapePicture translateToES :: Creature -> EquipSite -> Point3 -> Point3 -translateToES cr es p = fst (equipSitePQ es cr `Q.comp` (p,Q.qID)) +translateToES cr es p = fst (equipSitePQ es cr `Q.comp` (p, Q.qID)) equipSitePQ :: EquipSite -> Creature -> Point3Q equipSitePQ = \case @@ -31,24 +32,26 @@ equipSitePQ = \case OnHead -> headPQ OnChest -> chestPQ OnBack -> backPQ - OnLeftLeg -> leftLegPQ - OnRightLeg -> rightLegPQ + OnLeftLeg -> legPQ LeftForward + OnRightLeg -> legPQ RightForward translatePointToRightHand :: Creature -> Point3 -> Point3 -translatePointToRightHand cr p = fst (rightHandPQ cr `Q.comp` (p,Q.qID)) +translatePointToRightHand cr p = fst (rightHandPQ cr `Q.comp` (p, Q.qID)) handWalkingPos :: FootForward -> Float -> Creature -> Point3 handWalkingPos b off cr = case cr ^. crStance . carriage of - Walking sa ff -> + Walking sa ff -> let slen = cr ^. crStance . strideLength - f i | ff == b = 8 * (slen - i) / slen + f i + | ff == b = 8 * (slen - i) / slen | otherwise = 8 * i / slen - in V3 (f sa) off 12 + in V3 (f sa) off 12 Falling sa ff -> let slen = cr ^. crStance . strideLength - f i | ff == b = 8 * (slen - i) / slen + f i + | ff == b = 8 * (slen - i) / slen | otherwise = 8 * i / slen - in V3 (f sa) off 20 + in V3 (f sa) off 20 Floating -> V3 0 off 12 Flying -> V3 0 off 12 Boosting _ -> V3 0 off 12 @@ -56,7 +59,7 @@ handWalkingPos b off cr = case cr ^. crStance . carriage of rightHandPQ :: Creature -> Point3Q rightHandPQ cr | oneH cr = (V3 11 (-3) 20, Q.qID) - | twists cr = (V3 0 5 20, Q.qz (-1)) `Q.comp` (V3 4 (-10) 0,Q.qID) + | twists cr = (V3 0 5 20, Q.qz (-1)) `Q.comp` (V3 4 (-10) 0, Q.qID) | twoFlat cr = (V3 4 (-8) 12, Q.qID) | otherwise = (handWalkingPos LeftForward (-8) cr, Q.qID) @@ -74,7 +77,7 @@ leftHandPQ cr | otherwise = (handWalkingPos RightForward 8 cr, Q.qID) translatePointToLeftHand :: Creature -> Point3 -> Point3 -translatePointToLeftHand cr p = fst (leftHandPQ cr `Q.comp` (p,Q.qID)) +translatePointToLeftHand cr p = fst (leftHandPQ cr `Q.comp` (p, Q.qID)) translateToLeftHand :: Creature -> SPic -> SPic translateToLeftHand = overPosSP . translatePointToLeftHand @@ -82,27 +85,19 @@ translateToLeftHand = overPosSP . translatePointToLeftHand leftWristPQ :: Creature -> Point3Q leftWristPQ cr = leftHandPQ cr `Q.comp` (V3 0 4 (-4), Q.qID) -leftLegPQ :: Creature -> Point3Q -leftLegPQ cr = Q.comp (0,Q.qz (_crMvDir cr - _crDir cr)) - (V3 x off 0,Q.qID) - where - x = case cr ^? crStance . carriage of - Just (Walking sa LeftForward) -> f sa - Just (Walking sa RightForward) -> - f sa - Just (Falling sa LeftForward) -> f sa - Just (Falling sa RightForward) -> - f sa - _ -> 0 - off = 5 - sLen = _strideLength $ _crStance cr - f i = 8 * (sLen - i) / sLen - - translateToLeftLeg :: Creature -> SPic -> SPic -translateToLeftLeg cr = overPosSP (\p -> fst (leftLegPQ cr `Q.comp` (p,Q.qID))) +translateToLeftLeg cr = overPosSP (\p -> fst (legPQ LeftForward cr `Q.comp` (p, Q.qID))) -rightLegPQ :: Creature -> Point3Q -rightLegPQ cr = Q.comp (0,Q.qz (_crMvDir cr - _crDir cr)) - (V3 x off 0,Q.qID) +legPQ :: FootForward -> Creature -> Point3Q +legPQ ff = case ff of + LeftForward -> legPQ' id + RightForward -> legPQ' negate + +legPQ' :: (Float -> Float) -> Creature -> Point3Q +legPQ' g cr = + Q.comp + (0, Q.qz (_crMvDir cr - _crDir cr)) + (V3 x (g off) 0, Q.qID) where x = case cr ^? crStance . carriage of Just (Walking sa LeftForward) -> -f sa @@ -112,10 +107,10 @@ rightLegPQ cr = Q.comp (0,Q.qz (_crMvDir cr - _crDir cr)) _ -> 0 off = -5 sLen = _strideLength $ _crStance cr - f i = 8 * (sLen - i) / sLen + f i = g 8 * (sLen - i) / sLen translateToRightLeg :: Creature -> SPic -> SPic -translateToRightLeg cr = overPosSP (\p -> fst (rightLegPQ cr `Q.comp` (p,Q.qID))) +translateToRightLeg cr = overPosSP (\p -> fst (legPQ RightForward cr `Q.comp` (p, Q.qID))) headPQ :: Creature -> Point3Q headPQ cr @@ -123,11 +118,8 @@ headPQ cr | oneH cr = (V3 0 0 20, Q.qz 0.5) `Q.comp` (V3 2.5 0 0, Q.qz (-0.5)) | otherwise = (V3 2.5 0 20, Q.qID) ---translatePointToHead :: IM.IntMap Item -> Creature -> Point3 -> Point3 ---translatePointToHead m cr p = fst (headPQ cr `Q.comp` (p,Q.qID)) - chestPQ :: Creature -> Point3Q -chestPQ cr = backPQ cr `Q.comp` (0,Q.qz pi) +chestPQ cr = backPQ cr `Q.comp` (0, Q.qz pi) backPQ :: Creature -> Point3Q backPQ cr diff --git a/src/Dodge/Data/Creature/Stance.hs b/src/Dodge/Data/Creature/Stance.hs index 03c3d8d20..d1bb643be 100644 --- a/src/Dodge/Data/Creature/Stance.hs +++ b/src/Dodge/Data/Creature/Stance.hs @@ -20,7 +20,7 @@ data Stance = Stance deriving (Eq, Ord, Show, Read) --Generic, Flat) data Carriage - = Walking {_strideAmount :: Float, _currentFoot :: FootForward} + = Walking {_strideAmount :: Float, _footForward :: FootForward} | Floating | Flying | Boosting Point2 diff --git a/src/Dodge/Door.hs b/src/Dodge/Door.hs index 09a9f4e38..06785eb98 100644 --- a/src/Dodge/Door.hs +++ b/src/Dodge/Door.hs @@ -28,6 +28,7 @@ updateDoor dr w = case dr ^. drUpdate of , foldl' (doDoorMount (doDoorLerp dr (dr ^. drLerp))) w (dr ^. drMounts) ) +-- could filter these HERE rather than later? doDoorMount :: Point2A -> World -> MountedObject -> World doDoorMount pa w = \case MountedLight p r c -> diff --git a/src/Dodge/Item/HeldOffset.hs b/src/Dodge/Item/HeldOffset.hs index d21cecb06..7f7d3e44c 100644 --- a/src/Dodge/Item/HeldOffset.hs +++ b/src/Dodge/Item/HeldOffset.hs @@ -7,6 +7,7 @@ module Dodge.Item.HeldOffset ( handHandleOrient, ) where +import Linear import Dodge.Creature.HandPos import Dodge.Data.AimStance import Dodge.Data.ComposedItem @@ -26,9 +27,7 @@ turretItemOffset it tu mc = . transToHandle it transToHandle :: Item -> Point3 -> Point3 -transToHandle itm = (-.-.- V3 x y 0) - where - V2 x y = handlePos itm +transToHandle itm = (-.-.- (0 & _xy .~ handlePos itm)) handleOrient :: LocationDT CItem -> Point3Q handleOrient loc = case loc ^. locDT . dtValue . _1 . itType of @@ -68,6 +67,8 @@ strideRot :: Creature -> Float strideRot cr = case cr ^? crStance . carriage of Just (Walking x LeftForward) -> f x Just (Walking x RightForward) -> - f x + Just (Falling x LeftForward) -> f x + Just (Falling x RightForward) -> - f x _ -> 0 where f i = 0.1 * (sLen - i) / sLen diff --git a/src/Dodge/Room/Tutorial.hs b/src/Dodge/Room/Tutorial.hs index dbceac674..588c4a415 100644 --- a/src/Dodge/Room/Tutorial.hs +++ b/src/Dodge/Room/Tutorial.hs @@ -55,6 +55,9 @@ tutAnoTree = do foldMTRS [ tToBTree "TutStartRez" . return . cleatOnward <$> tutRezBox , corDoor + , lasRunYinYang + , corDoor + , corDoor , tToBTree "slowCrush" . return . cleatOnward <$> pushCaverns , corDoor , chasmSpitTerminal diff --git a/src/Geometry/Vector.hs b/src/Geometry/Vector.hs index 7fd288a14..a0415b9bb 100644 --- a/src/Geometry/Vector.hs +++ b/src/Geometry/Vector.hs @@ -59,9 +59,11 @@ angleVV :: Point2 -> Point2 -> Float {-# INLINE angleVV #-} angleVV a b | a == b = 0 + | norm a == 0 = 0 + | norm b == 0 = 0 | otherwise = - let ma = magV a - mb = magV b + let ma = norm a + mb = norm b d = a `dotV` b in acos $ d / (ma * mb) diff --git a/tags b/tags index 6e1d36636..e1f1b0d95 100644 --- a/tags +++ b/tags @@ -2669,7 +2669,7 @@ axisInt src/Geometry/Intersect.hs 246;" f azure src/Color.hs 49;" f bQuadToF src/Geometry/Bezier.hs 37;" f bQuadToLine src/Geometry/Bezier.hs 30;" f -backPQ src/Dodge/Creature/HandPos.hs 126;" f +backPQ src/Dodge/Creature/HandPos.hs 132;" f backgroundSpaceS src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 729;" f backpackCombinations src/Dodge/Combine/Combinations.hs 27;" f backpackShape src/Dodge/Item/Draw/SPic.hs 188;" f @@ -2834,7 +2834,7 @@ checkWallLeft src/Dodge/LevelGen/StaticWalls/Deprecated.hs 29;" f checkWallRight src/Dodge/LevelGen/StaticWalls.hs 54;" f checkWallRight src/Dodge/LevelGen/StaticWalls/Deprecated.hs 59;" f chemFuelPouch src/Dodge/Item/Ammo.hs 81;" f -chestPQ src/Dodge/Creature/HandPos.hs 123;" f +chestPQ src/Dodge/Creature/HandPos.hs 129;" f chooseCursorBorders src/Dodge/Render/List.hs 141;" f chooseEquipPosition src/Dodge/Inventory/RBList.hs 41;" f chooseFootSound src/Dodge/Creature/State/WalkCycle.hs 35;" f @@ -3491,7 +3491,7 @@ equipInfo src/Dodge/Item/Info.hs 140;" f equipItemSPic src/Dodge/Item/Draw/SPic.hs 159;" f equipPosition src/Dodge/Item/Draw.hs 38;" f equipSiteInfo src/Dodge/Item/Info.hs 253;" f -equipSitePQ src/Dodge/Creature/HandPos.hs 28;" f +equipSitePQ src/Dodge/Creature/HandPos.hs 27;" f equipType src/Dodge/Data/EquipType.hs 10;" f equipmentDesignation src/Dodge/Inventory/RBList.hs 52;" f equipmentStrValue src/Dodge/Creature/Statistics.hs 56;" f @@ -3712,17 +3712,17 @@ halfHeight src/Dodge/Base/Window.hs 49;" f halfWidth src/Dodge/Base/Window.hs 49;" f haltSound src/Dodge/SoundLogic.hs 38;" f hammerCheck src/Dodge/HeldUse.hs 67;" f -handHandleOrient src/Dodge/Item/HeldOffset.hs 58;" f -handOrient src/Dodge/Item/HeldOffset.hs 40;" f -handWalkingPos src/Dodge/Creature/HandPos.hs 41;" f +handHandleOrient src/Dodge/Item/HeldOffset.hs 57;" f +handOrient src/Dodge/Item/HeldOffset.hs 39;" f +handWalkingPos src/Dodge/Creature/HandPos.hs 40;" f handleEvent src/Dodge/Event.hs 27;" f handleHotkeys src/Dodge/Creature/YourControl.hs 46;" f handleKeyboardEvent src/Dodge/Event/Input.hs 23;" f handleMouseButtonEvent src/Dodge/Event/Input.hs 59;" f handleMouseMotionEvent src/Dodge/Event/Input.hs 47;" f handleMouseWheelEvent src/Dodge/Event/Input.hs 54;" f -handleOrient src/Dodge/Item/HeldOffset.hs 33;" f -handlePos src/Dodge/Item/HeldOffset.hs 79;" f +handleOrient src/Dodge/Item/HeldOffset.hs 32;" f +handlePos src/Dodge/Item/HeldOffset.hs 78;" f handleResizeEvent src/Dodge/Event.hs 53;" f handleTextInput src/Dodge/Event/Input.hs 19;" f handleWindowMoveEvent src/Dodge/Event.hs 44;" f @@ -3737,7 +3737,7 @@ head src/DoubleStack.hs 14;" f headLamp src/Dodge/Item/Equipment.hs 68;" f headLampShape src/Dodge/Item/Draw/SPic.hs 423;" f headMap src/Dodge/DoubleTree.hs 118;" f -headPQ src/Dodge/Creature/HandPos.hs 114;" f +headPQ src/Dodge/Creature/HandPos.hs 120;" f healS src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 627;" f healthAnalyserByDoor src/Dodge/Room/LasTurret.hs 108;" f healthTest src/Dodge/Room/LasTurret.hs 130;" f @@ -3746,7 +3746,7 @@ heldAimStance src/Dodge/Item/AimStance.hs 27;" f heldAimZoom src/Dodge/Update/Camera.hs 158;" f heldEffect src/Dodge/HeldUse.hs 64;" f heldEffectMuzzles src/Dodge/HeldUse.hs 135;" f -heldHandlePos src/Dodge/Item/HeldOffset.hs 85;" f +heldHandlePos src/Dodge/Item/HeldOffset.hs 84;" f heldInfo src/Dodge/Item/Info.hs 92;" f heldItemAmmoSlots src/Dodge/Item/AmmoSlots.hs 20;" f heldItemBulkiness src/Dodge/Creature/YourControl.hs 194;" f @@ -4000,12 +4000,12 @@ leaveResetQuitTerminal src/Dodge/WorldEffect.hs 163;" f led src/Dodge/Item/Held/Utility.hs 23;" f left src/DoubleStack.hs 16;" f leftChildList src/Dodge/Item/Grammar.hs 193;" f -leftHandPQ src/Dodge/Creature/HandPos.hs 63;" f +leftHandPQ src/Dodge/Creature/HandPos.hs 69;" f leftIsParentCombine src/Dodge/Item/Grammar.hs 170;" f -leftLegPQ src/Dodge/Creature/HandPos.hs 79;" f +leftLegPQ src/Dodge/Creature/HandPos.hs 85;" f leftPad src/Padding.hs 15;" f leftRightCombine src/Dodge/Item/Grammar.hs 205;" f -leftWristPQ src/Dodge/Creature/HandPos.hs 76;" f +leftWristPQ src/Dodge/Creature/HandPos.hs 82;" f legsSPic src/Dodge/Item/Draw/SPic.hs 448;" f lerpP2A src/Dodge/ShiftPoint.hs 14;" f liShape src/Dodge/Placement/Instance/LightSource.hs 85;" f @@ -4050,7 +4050,7 @@ locDTLeftmost src/Dodge/DoubleTree.hs 148;" f locDTRightmost src/Dodge/DoubleTree.hs 151;" f locGoHelp src/Dodge/DoubleTree.hs 166;" f locMuzzles src/Dodge/HeldUse.hs 149;" f -locOrient src/Dodge/Item/HeldOffset.hs 53;" f +locOrient src/Dodge/Item/HeldOffset.hs 52;" f locToTop src/Dodge/DoubleTree.hs 145;" f locUp' src/Dodge/DoubleTree.hs 132;" f lockInv src/Dodge/Inventory/Lock.hs 9;" f @@ -4724,12 +4724,12 @@ rhombus src/Polyhedra.hs 69;" f rifle src/Dodge/Item/Held/Cane.hs 19;" f right src/DoubleStack.hs 16;" f rightChildList src/Dodge/Item/Grammar.hs 199;" f -rightHandPQ src/Dodge/Creature/HandPos.hs 50;" f +rightHandPQ src/Dodge/Creature/HandPos.hs 56;" f rightIsParentCombine src/Dodge/Item/Grammar.hs 181;" f -rightLegPQ src/Dodge/Creature/HandPos.hs 97;" f +rightLegPQ src/Dodge/Creature/HandPos.hs 103;" f rightPad src/Padding.hs 19;" f rightPadNoSquash src/Padding.hs 23;" f -rightWristPQ src/Dodge/Creature/HandPos.hs 60;" f +rightWristPQ src/Dodge/Creature/HandPos.hs 66;" f rlPosDir src/Dodge/RoomLink.hs 112;" f rlauncherPic src/Dodge/Item/Draw/SPic.hs 399;" f rmInLinks src/Dodge/RoomLink.hs 153;" f @@ -4968,7 +4968,7 @@ shootingRange src/Dodge/Room/Room.hs 356;" f shortPoint2 src/Dodge/ShortShow.hs 4;" f shortShow src/ShortShow.hs 7;" f shotgunS src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 527;" f -shoulderHeight src/Dodge/Item/HeldOffset.hs 64;" f +shoulderHeight src/Dodge/Item/HeldOffset.hs 63;" f showAttachItem src/Dodge/Item/Display.hs 92;" f showEquipItem src/Dodge/Item/Display.hs 108;" f showInt src/Dodge/Item/Info.hs 75;" f @@ -5136,7 +5136,7 @@ strFromEquipment src/Dodge/Creature/Statistics.hs 53;" f strFromHeldItem src/Dodge/Creature/Statistics.hs 67;" f strengthFactor src/Dodge/Creature/Impulse/Movement.hs 51;" f strictify src/MaybeHelp.hs 35;" f -strideRot src/Dodge/Item/HeldOffset.hs 67;" f +strideRot src/Dodge/Item/HeldOffset.hs 66;" f stringToList src/Picture/Base.hs 308;" f stringToListGrad src/Picture/Text.hs 12;" f stripZ src/Geometry/Vector3D.hs 97;" f @@ -5293,14 +5293,14 @@ tractorPullPos src/Dodge/TractorBeam/Update.hs 33;" f tractorSPic src/Dodge/TractorBeam/Draw.hs 10;" f tranRot src/Picture/Base.hs 116;" f transMat src/MatrixHelper.hs 87;" f -transToHandle src/Dodge/Item/HeldOffset.hs 28;" f +transToHandle src/Dodge/Item/HeldOffset.hs 29;" f translate src/Picture/Base.hs 108;" f translate3 src/Picture/Base.hs 112;" f translateFloatingCamera src/Dodge/Update/Camera.hs 50;" f translateFloatingCameraKeys src/Dodge/Update/Camera.hs 68;" f translateH src/Picture/Base.hs 104;" f -translatePointToLeftHand src/Dodge/Creature/HandPos.hs 70;" f -translatePointToRightHand src/Dodge/Creature/HandPos.hs 38;" f +translatePointToLeftHand src/Dodge/Creature/HandPos.hs 76;" f +translatePointToRightHand src/Dodge/Creature/HandPos.hs 37;" f translateSH src/Shape.hs 242;" f translateSHxy src/Shape.hs 246;" f translateSHz src/Shape.hs 250;" f @@ -5308,11 +5308,11 @@ translateSP src/ShapePicture.hs 53;" f translateSPxy src/ShapePicture.hs 45;" f translateSPz src/ShapePicture.hs 49;" f translateScreenPos src/Dodge/ScreenPos.hs 12;" f -translateToES src/Dodge/Creature/HandPos.hs 25;" f -translateToLeftHand src/Dodge/Creature/HandPos.hs 73;" f -translateToLeftLeg src/Dodge/Creature/HandPos.hs 94;" f -translateToRightHand src/Dodge/Creature/HandPos.hs 57;" f -translateToRightLeg src/Dodge/Creature/HandPos.hs 111;" f +translateToES src/Dodge/Creature/HandPos.hs 24;" f +translateToLeftHand src/Dodge/Creature/HandPos.hs 79;" f +translateToLeftLeg src/Dodge/Creature/HandPos.hs 100;" f +translateToRightHand src/Dodge/Creature/HandPos.hs 63;" f +translateToRightLeg src/Dodge/Creature/HandPos.hs 117;" f translateXY src/Polyhedra.hs 23;" f trapTBH src/Geometry/Polygon.hs 22;" f trapezionBWHW src/Geometry/Polygon.hs 34;" f @@ -5349,7 +5349,7 @@ trySynthBullet src/Dodge/Creature/State.hs 167;" f tryThrust src/Dodge/Projectile/Update.hs 126;" f tryUseParent src/Dodge/Creature/State.hs 145;" f turnTo src/Dodge/Movement/Turn.hs 8;" f -turretItemOffset src/Dodge/Item/HeldOffset.hs 22;" f +turretItemOffset src/Dodge/Item/HeldOffset.hs 23;" f tutAnoTree src/Dodge/Room/Tutorial.hs 53;" f tutDrop src/Dodge/Room/Tutorial.hs 99;" f tutHub src/Dodge/Room/Tutorial.hs 412;" f @@ -5362,7 +5362,7 @@ twinSlowDoorChasers src/Dodge/Room/LongDoor.hs 80;" f twinSlowDoorRoom src/Dodge/Room/LongDoor.hs 36;" f twists src/Dodge/Creature/Test.hs 103;" f twoFlat src/Dodge/Creature/Test.hs 100;" f -twoFlatHRot src/Dodge/Item/HeldOffset.hs 76;" f +twoFlatHRot src/Dodge/Item/HeldOffset.hs 75;" f twoHandTwistAmount src/Dodge/Creature/YourControl.hs 166;" f twoRoomPoss src/Dodge/PlacementSpot.hs 148;" f twoStep1S src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 519;" f diff --git a/test/Spec.hs b/test/Spec.hs index 83a3025f8..15600d329 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -2,23 +2,27 @@ import Test.Tasty import qualified Test.Tasty.QuickCheck as QC import Test.Tasty.HUnit -import Dodge.Room.CheckConsistency +--import Dodge.Room.CheckConsistency --import Geometry -import Dodge.LevelGen.StaticWalls +--import Dodge.LevelGen.StaticWalls import Geometry import Data.Maybe main :: IO () main = defaultMain $ testGroup "Tests" - [testGroup "Geometry tests" geometryTests] + [testGroup "Geometry tests" geometryTests + ,testGroup "angleVV" angleVVTests + ] +geometryTests :: [TestTree] geometryTests = [ testGroup "(HUnit)" geometryUnitTests , testGroup "(QuickCheck)" geometryQuickCheckTests ] +geometryUnitTests :: [TestTree] geometryUnitTests = [ testCase "intersectSegSegTest cross intersect" $ intersectSegSegTest (V2 1 0) (V2 1 2) (V2 0 1) (V2 2 1) @@ -30,28 +34,29 @@ geometryUnitTests = intersectSegSegTest (V2 1 0) (V2 1 2) (V2 0 0) (V2 0 2) @?= False , testCase "circOnSeg endpoint1" $ - circOnSeg (V2 0 0) (V2 10 10) (V2 (-1) (-1)) 2 + circOnSeg (V2 (-1) (-1)) 2 (V2 0 0) (V2 10 10) @?= True , testCase "circOnSeg endpoint2" $ - circOnSeg (V2 0 0) (V2 10 10) (V2 11 10) 2 + circOnSeg (V2 11 10) 2 (V2 0 0) (V2 10 10) @?= True , testCase "circOnSeg mid" $ - circOnSeg (V2 0 0) (V2 10 10) (V2 5 5) 2 + circOnSeg (V2 5 5) 2 (V2 0 0) (V2 10 10) @?= True , testCase "circOnSeg mid" $ - circOnSeg (V2 0 0) (V2 10 10) (V2 5 4) 2 + circOnSeg (V2 5 4) 2 (V2 0 0) (V2 10 10) @?= True , testCase "circOnSeg miss endpoint1" $ - circOnSeg (V2 0 0) (V2 10 10) (V2 (-1) (-1)) 1 + circOnSeg (V2 (-1) (-1)) 1 (V2 0 0) (V2 10 10) @?= False , testCase "circOnSeg miss endpoint2" $ - circOnSeg (V2 0 0) (V2 10 10) (V2 11 10) 0.9 + circOnSeg (V2 11 10) 0.9 (V2 0 0) (V2 10 10) @?= False , testCase "circOnSeg miss mid" $ - circOnSeg (V2 0 0) (V2 10 10) (V2 7 3) 0.9 + circOnSeg (V2 7 3) 0.9 (V2 0 0) (V2 10 10) @?= False ] +geometryQuickCheckTests :: [TestTree] geometryQuickCheckTests = [ QC.testProperty "intersectSegSeg--intersectSegSegTest" $ \(x1,y1,x2,y2,x3,y3,x4,y4) -> @@ -59,6 +64,11 @@ geometryQuickCheckTests = == intersectSegSegTest (V2 x1 y1) (V2 x2 y2) (V2 x3 y3) (V2 x4 y4) ] +angleVVTests :: [TestTree] +angleVVTests = [QC.testProperty "random vectors give positive result" $ + \(x,y,a,b) -> 0 <= angleVV (V2 x y) (V2 a b) + ] + --nextPair :: Eq a => (a,a) -> [(a,a)] -> [(a,a)] --nextPair (_,y) = filter (\(x,_) -> x == y) --