forked from cormas/cormas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request cormas#745 from olekscode/744-moveTowardsconstrain…
…tOnPath-is-throwing-SubscriptOutOfBounds-exception 744 move towardsconstraint on path is throwing subscript out of bounds exception
- Loading branch information
Showing
7 changed files
with
176 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
repository/Cormas-Tests/CMSpatialEntityElementTest.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
Class { | ||
#name : #CMSpatialEntityElementTest, | ||
#superclass : #TestCase, | ||
#instVars : [ | ||
'model' | ||
], | ||
#category : #'Cormas-Tests-Model' | ||
} | ||
|
||
{ #category : #initialization } | ||
CMSpatialEntityElementTest >> setUp [ | ||
|
||
super setUp. | ||
|
||
model := CMMockModel new | ||
activeInit: #initFixed; | ||
initializeSimulation; | ||
yourself. | ||
] | ||
|
||
{ #category : #tests } | ||
CMSpatialEntityElementTest >> testMoveTowardsConstraintOnPath [ | ||
|
||
| agent destination expectedPathOfIds | | ||
|
||
agent := model theCows anyOne. | ||
destination := model pickCellAt: 3 @ 2. | ||
|
||
expectedPathOfIds := #(5 9 14 11 7) asOrderedCollection. | ||
|
||
expectedPathOfIds do: [ :expectedCellId | | ||
self assert: agent patch id equals: expectedCellId. | ||
agent moveTowards: destination constraintOnPath: [ :cell | cell isAliveCell ] ]. | ||
|
||
self assert: agent patch id equals: destination id. | ||
] | ||
|
||
{ #category : #tests } | ||
CMSpatialEntityElementTest >> testWayToConstrained [ | ||
|
||
| origin destination path pathOfIds expectedPathOfIds | | ||
|
||
origin := model pickCellAt: 1 @ 2. | ||
destination := model pickCellAt: 3 @ 2. | ||
|
||
path := origin wayTo: destination constraint: [ :cell | cell isAliveCell ]. | ||
pathOfIds := path collect: [ :cell | cell id ]. | ||
|
||
expectedPathOfIds := #(5 9 14 11 7) asOrderedCollection. | ||
self assert: pathOfIds equals: expectedPathOfIds. | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters