Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Johanna-G committed Jun 18, 2024
1 parent 40f3db1 commit 19cc216
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/SqueakKara-Core/SKEnvironment.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ SKEnvironment >> initialize [

{
#category : #initialization,
#'squeak_changestamp' : 'JJG 6/18/2024 11:20'
#'squeak_changestamp' : 'JJG 6/18/2024 18:47'
}
SKEnvironment >> initializeWithChallenge1 [

Expand All @@ -96,12 +96,12 @@ SKEnvironment >> initializeWithChallenge1 [
self kara: self grid challenge1.
self workspace: (SKWorkspace newWithKara: self kara).
self executer: (SKExecuter new).
(self executer kara) setRealKara: self kara.
(self executer kara) kara: self kara.
]

{
#category : #initialization,
#'squeak_changestamp' : 'JJG 6/18/2024 11:22'
#'squeak_changestamp' : 'JJG 6/18/2024 18:47'
}
SKEnvironment >> initializeWithKaraAt: aPoint [

Expand All @@ -110,7 +110,7 @@ SKEnvironment >> initializeWithKaraAt: aPoint [
self kara: (SKKara newInGrid: self grid at: aPoint).
self workspace: (SKWorkspace newWithKara: self kara).
self executer: (SKExecuter new).
(self executer kara) setRealKara: self kara.
(self executer kara) kara: self kara.
]

{
Expand Down
9 changes: 0 additions & 9 deletions src/SqueakKara-Core/SKKaraDecorator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,6 @@ SKKaraDecorator >> onCloverleaf [

]

{
#category : #accessing,
#'squeak_changestamp' : 'JJG 6/17/2024 16:34'
}
SKKaraDecorator >> setRealKara: anObject [

kara := anObject
]

{
#category : #'SKKara functions',
#'squeak_changestamp' : 'EB 6/11/2024 10:01'
Expand Down
9 changes: 6 additions & 3 deletions src/SqueakKara-Tests/SKEnvironmentTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ SKEnvironmentTest >> testDetectNoTrunk [

{
#category : #testing,
#'squeak_changestamp' : 'JJG 6/18/2024 18:20'
#'squeak_changestamp' : 'JJG 6/18/2024 19:04'
}
SKEnvironmentTest >> testDetectTrunk [

Expand All @@ -99,6 +99,7 @@ SKEnvironmentTest >> testDetectTrunk [
self environment executer step.
self environment executer step.
self environment executer step.
self environment executer step.
self assert: self environment kara coordinates = (1 @ 2)
]

Expand All @@ -116,20 +117,21 @@ SKEnvironmentTest >> testMove [

{
#category : #testing,
#'squeak_changestamp' : 'JJG 6/18/2024 12:17'
#'squeak_changestamp' : 'JJG 6/18/2024 19:06'
}
SKEnvironmentTest >> testMoveTwice [

self environment workspace userCode: 'kara move. kara move'.
self environment run.
self environment executer step.
self environment executer step.
self environment executer step.
self assert: self environment kara coordinates = (3 @ 1)
]

{
#category : #testing,
#'squeak_changestamp' : 'JJG 6/18/2024 18:13'
#'squeak_changestamp' : 'JJG 6/18/2024 19:07'
}
SKEnvironmentTest >> testTurnLeftMove [

Expand All @@ -138,6 +140,7 @@ SKEnvironmentTest >> testTurnLeftMove [
self environment run.
self environment executer step.
self environment executer step.
self environment executer step.
self assert: self environment kara coordinates = (2 @ 1)
]

Expand Down
141 changes: 141 additions & 0 deletions src/SqueakKara-Tests/SKKaraDecoratorTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
Class {
#name : #SKKaraDecoratorTest,
#superclass : #TestCase,
#instVars : [
'decorator',
'grid',
'kara'
],
#category : #'SqueakKara-Tests'
}

{
#category : #accessing,
#'squeak_changestamp' : 'JJG 6/18/2024 18:52'
}
SKKaraDecoratorTest >> decorator [

^ decorator

]

{
#category : #accessing,
#'squeak_changestamp' : 'JJG 6/18/2024 18:52'
}
SKKaraDecoratorTest >> grid [

^ grid
]

{
#category : #accessing,
#'squeak_changestamp' : 'JJG 6/18/2024 18:54'
}
SKKaraDecoratorTest >> gridSize [

^ 20 @ 20

]

{
#category : #accessing,
#'squeak_changestamp' : 'JJG 6/18/2024 18:52'
}
SKKaraDecoratorTest >> kara [

^ kara
]

{
#category : #setup,
#'squeak_changestamp' : 'JJG 6/18/2024 18:56'
}
SKKaraDecoratorTest >> setUp [

grid := SKGrid newWithExtent: self gridSize.
kara := SKKara newInGrid: self grid at: 1 @ 1.
decorator := SKKaraDecorator new.
self decorator kara: self kara.
self decorator executer: SKExecuter new
]

{
#category : #setup,
#'squeak_changestamp' : 'JJG 6/18/2024 18:51'
}
SKKaraDecoratorTest >> tearDown [

self grid abandon
]

{
#category : #testing,
#'squeak_changestamp' : 'JJG 6/18/2024 18:58'
}
SKKaraDecoratorTest >> testKaraMove [


self decorator move.
self assert: decorator kara coordinates = (2 @ 1)
]

{
#category : #testing,
#'squeak_changestamp' : 'JJG 6/18/2024 19:00'
}
SKKaraDecoratorTest >> testKaraNoTrunkAhead [

self deny: decorator kara trunkAhead
]

{
#category : #testing,
#'squeak_changestamp' : 'JJG 6/18/2024 18:59'
}
SKKaraDecoratorTest >> testKaraNotOnCloverleaf [

self deny: decorator kara onCloverleaf
]

{
#category : #testing,
#'squeak_changestamp' : 'JJG 6/18/2024 18:59'
}
SKKaraDecoratorTest >> testKaraOnCloverleaf [

SKCloverleaf newInGrid: self grid at: 1 @ 1.
self assert: decorator kara onCloverleaf
]

{
#category : #testing,
#'squeak_changestamp' : 'JJG 6/18/2024 19:01'
}
SKKaraDecoratorTest >> testKaraTrunkAhead [

SKTrunk newInGrid: self grid at: 2 @ 1.
self assert: decorator kara trunkAhead
]

{
#category : #testing,
#'squeak_changestamp' : 'JJG 6/18/2024 18:57'
}
SKKaraDecoratorTest >> testKaraTurnLeft [


self decorator turn: 'left'.
self assert: decorator kara viewDirection = SKDirection above
]

{
#category : #testing,
#'squeak_changestamp' : 'JJG 6/18/2024 18:56'
}
SKKaraDecoratorTest >> testKaraTurnRight [


self decorator turn: 'right'.
self assert: decorator kara viewDirection = SKDirection below
]

0 comments on commit 19cc216

Please sign in to comment.