Skip to content

Commit

Permalink
Add robot ownership to integration test suite (#1451)
Browse files Browse the repository at this point in the history
- followup to #1431
- remove the warning seen in #1449
  • Loading branch information
xsebek authored Aug 23, 2023
1 parent 9eeaf71 commit 8ed5b92
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
3 changes: 2 additions & 1 deletion data/scenarios/Testing/00-ORDER.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@
144-subworlds
1355-combustion.yaml
1379-single-world-portal-reorientation.yaml
1399-backup-command.yaml
1399-backup-command.yaml
1430-built-robot-ownership.yaml
24 changes: 22 additions & 2 deletions data/scenarios/Testing/1430-built-robot-ownership.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,20 @@ robots:
display:
char: Ω
attr: robot
inventory:
- [5, logger]
- [5, compass]
- [5, solar panel]
- [5, treads]
- [5, grabber]
devices:
- logger
- 3D printer
- dictionary
- grabber
- hearing aid
- name: sysbot
dir: [0, 1]
dir: [-1, 0]
system: true
display:
char: j
Expand All @@ -28,7 +38,17 @@ robots:
- [1, treads]
- [1, string]
program: |
build {move; move; x <- as parent {whoami}; log x}
build {move; say (format parent)}
solution: |
listen; build {move; say (format parent)}
objectives:
- goal:
- Check that system robots build system robots and normal robots do not.
- This check is performed in integration tests.
condition: |
r2 <- robotNumbered 2;
r3 <- robotNumbered 3;
return true
known: []
world:
palette:
Expand Down
11 changes: 9 additions & 2 deletions 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), 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 @@ -31,7 +31,7 @@ import Swarm.Doc.Gen qualified as DocGen
import Swarm.Game.CESK (emptyStore, getTickNumber, initMachine)
import Swarm.Game.Entity (EntityMap, lookupByName)
import Swarm.Game.Failure (SystemFailure)
import Swarm.Game.Robot (LogEntry, defReqs, equippedDevices, leText, machine, robotContext, robotLog, waitingUntil)
import Swarm.Game.Robot (LogEntry, defReqs, equippedDevices, leText, machine, robotContext, robotLog, systemRobot, waitingUntil)
import Swarm.Game.Scenario (Scenario)
import Swarm.Game.State (
GameState,
Expand Down Expand Up @@ -305,6 +305,13 @@ testScenarioSolutions rs ui =
, testSolution Default "Testing/1320-world-DSL/override"
]
]
, testSolution' Default "Testing/1430-built-robot-ownership" CheckForBadErrors $ \g -> do
let r2 = g ^. robotMap . at 2
let r3 = g ^. robotMap . at 3
assertBool "The second built robot should be a system robot like it's parent." $
maybe False (view systemRobot) r2
assertBool "The third built robot should be a normal robot like base." $
maybe False (not . view systemRobot) r3
]
where
-- expectFailIf :: Bool -> String -> TestTree -> TestTree
Expand Down

0 comments on commit 8ed5b92

Please sign in to comment.