Skip to content

Commit

Permalink
add integration test for RobotIntoWater achievement
Browse files Browse the repository at this point in the history
  • Loading branch information
byorgey committed Sep 10, 2023
1 parent 4d8d533 commit 17da990
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
11 changes: 11 additions & 0 deletions data/scenarios/Testing/Achievements/RobotIntoWater.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
version: 1
name: RobotIntoWater achievement test
description: Drive a robot into the water
objectives:
- id: build
goal:
- Build a robot
condition: |
try {robotNumbered 1; return True} {return False}
- goal:
- Drown it
prerequisite: build
condition: |
try {robotNumbered 1; return False} {return True}
solution: |
build { turn right; move; move; move }
robots:
Expand Down
10 changes: 9 additions & 1 deletion test/integration/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Main where

import Control.Carrier.Lift (runM)
import Control.Carrier.Throw.Either (runThrow)
import Control.Lens (Ixed (ix), at, to, use, view, (&), (.~), (<>~), (^.), (^..), (^?!))
import Control.Lens (Ixed (ix), at, to, use, view, (&), (.~), (<>~), (^.), (^..), (^?!), (^?))
import Control.Monad (forM_, unless, when)
import Control.Monad.State (StateT (runStateT), gets)
import Data.Char (isSpace)
Expand All @@ -28,6 +28,7 @@ import Data.Text.IO qualified as T
import Data.Yaml (ParseException, prettyPrintParseException)
import Swarm.Doc.Gen (EditorType (..))
import Swarm.Doc.Gen qualified as DocGen
import Swarm.Game.Achievement.Definitions (GameplayAchievement(..))
import Swarm.Game.CESK (emptyStore, getTickNumber, initMachine)
import Swarm.Game.Entity (EntityMap, lookupByName)
import Swarm.Game.Failure (SystemFailure)
Expand All @@ -47,6 +48,7 @@ import Swarm.Game.State (
waitingRobots,
winCondition,
winSolution,
gameAchievements,
)
import Swarm.Game.Step (gameTick)
import Swarm.Game.World.Typecheck (WorldMap)
Expand Down Expand Up @@ -244,6 +246,12 @@ testScenarioSolutions rs ui =
[ testSolution Default "Mechanics/active-trapdoor.yaml"
]
]
, testGroup
"Achievements"
[ testSolution' Default "Testing/Achievements/RobotIntoWater" CheckForBadErrors $ \g ->
assertBool "Did not get RobotIntoWater achievement!"
(isJust $ g ^? gameAchievements . at RobotIntoWater)
]
, testGroup
"Regression tests"
[ testSolution Default "Testing/394-build-drill"
Expand Down

0 comments on commit 17da990

Please sign in to comment.