Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add robot ownership to integration test suite #1451

Merged
merged 5 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.yaml" CheckForBadErrors $ \g -> do
xsebek marked this conversation as resolved.
Show resolved Hide resolved
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
Loading