Skip to content

Commit

Permalink
refactored some things (close on workspace now works)
Browse files Browse the repository at this point in the history
  • Loading branch information
Johanna-G committed Jun 18, 2024
1 parent 5cb3dda commit 40f3db1
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 31 deletions.
6 changes: 3 additions & 3 deletions src/SqueakKara-Core/SKEnvironment.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ SKEnvironment class >> newWithKaraAt: aPoint [

{
#category : #commands,
#'squeak_changestamp' : 'KD 6/12/2024 13:28'
#'squeak_changestamp' : 'JJG 6/18/2024 18:43'
}
SKEnvironment >> close [

"self workspace close.
self grid abandon."
self workspace close.
self grid abandon.


]
Expand Down
4 changes: 2 additions & 2 deletions src/SqueakKara-Core/SKWorkspace.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ SKWorkspace class >> newWithKara: aKara [

{
#category : #commands,
#'squeak_changestamp' : 'JJG 6/18/2024 18:06'
#'squeak_changestamp' : 'JJG 6/18/2024 18:43'
}
SKWorkspace >> close [

"self abandon."
self changed: #close
]

{
Expand Down
5 changes: 2 additions & 3 deletions src/SqueakKara-Tests/SKEnvironmentTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ SKEnvironmentTest >> setUp [

{
#category : #setup,
#'squeak_changestamp' : 'JJG 6/18/2024 18:01'
#'squeak_changestamp' : 'JJG 6/18/2024 18:44'
}
SKEnvironmentTest >> tearDown [

self environment grid abandon.
"self environment workspace owner delete"
self environment close

]

Expand Down
143 changes: 120 additions & 23 deletions src/SqueakKara-Tests/SKKaraTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ SKKaraTest >> tearDown [

{
#category : #testing,
#'squeak_changestamp' : 'jt 6/11/2024 11:28'
#'squeak_changestamp' : 'JJG 6/18/2024 18:41'
}
SKKaraTest >> testAbsolutePositionAfterMoveWithChangedDirection [

Expand All @@ -54,43 +54,127 @@ SKKaraTest >> testAbsolutePositionAfterMoveWithChangedDirection [
kara := SKKara newInGrid: self grid.
kara viewDirection: 0 @ 1.
kara move.
self assert: kara position = (self grid position + (0 @ self grid pixelPerBlock)).
self assert: kara position = (self grid position + (0 @ self grid pixelPerBlock))

]

{
#category : #testing,
#'squeak_changestamp' : 'jt 6/11/2024 11:27'
#'squeak_changestamp' : 'JJG 6/18/2024 18:41'
}
SKKaraTest >> testAbsolutePositionAfterMoveWithDefaultDirection [

| kara |

kara := SKKara newInGrid: self grid.
kara move.
self assert: kara position = (self grid position + (self grid pixelPerBlock @ 0)).
self assert: kara position = (self grid position + (self grid pixelPerBlock @ 0))

]

{
#category : #testing,
#'squeak_changestamp' : 'jt 6/11/2024 12:47'
#'squeak_changestamp' : 'JJG 6/18/2024 18:40'
}
SKKaraTest >> testKaraTurn [
SKKaraTest >> testKaraStartTurnLeftRight [

| kara |

kara := SKKara newInGrid: self grid.
kara turn: SKDirection right.
kara turn: SKDirection left.
self assert: kara viewDirection = SKDirection right


]

{
#category : #testing,
#'squeak_changestamp' : 'JJG 6/18/2024 18:40'
}
SKKaraTest >> testKaraStartViewDirection [

| kara |

kara := SKKara newInGrid: self grid.
self assert: kara viewDirection = SKDirection right


]

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

| kara |

kara := SKKara newInGrid: self grid.
kara turn: 'left'.
self assert: kara viewDirection = SKDirection above.
self assert: kara viewDirection = SKDirection above


]

{
#category : #testing,
#'squeak_changestamp' : 'JJG 6/18/2024 18:40'
}
SKKaraTest >> testKaraTurnLeftTwice [

| kara |

kara := SKKara newInGrid: self grid.
kara turn: 'left'.
self assert: kara viewDirection = SKDirection left.
kara turn: 'left'.
self assert: kara viewDirection = SKDirection left

]

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

| kara |

kara := SKKara newInGrid: self grid.
kara turn: 'right'.
self assert: kara viewDirection = SKDirection above.
self assert: kara viewDirection = SKDirection below

]

{
#category : #testing,
#'squeak_changestamp' : 'JJG 6/18/2024 18:40'
}
SKKaraTest >> testKaraTurnRightThrice [

| kara |

kara := SKKara newInGrid: self grid.
kara turn: 'right'.
self assert: kara viewDirection = SKDirection right.
kara turn: 'right'.
self assert: kara viewDirection = SKDirection below
kara turn: 'right'.
self assert: kara viewDirection = SKDirection above

]

{
#category : #testing,
#'squeak_changestamp' : 'JJG 6/18/2024 18:40'
}
SKKaraTest >> testKaraTurnRightTwice [

| kara |

kara := SKKara newInGrid: self grid.
kara turn: 'right'.
kara turn: 'right'.
self assert: kara viewDirection = SKDirection left

]

{
Expand All @@ -110,43 +194,56 @@ SKKaraTest >> testMoveWhenTrunkAhead [

{
#category : #testing,
#'squeak_changestamp' : 'jt 6/11/2024 13:58'
#'squeak_changestamp' : 'JJG 6/18/2024 18:40'
}
SKKaraTest >> testNoTrunkAhead [

| kara |

kara := SKKara newInGrid: self grid.
self deny: kara trunkAhead

]

{
#category : #testing,
#'squeak_changestamp' : 'JJG 6/18/2024 18:40'
}
SKKaraTest >> testNotOnCloverleaf [

| kara cloverleaf |
| kara |

kara := SKKara newInGrid: self grid.
cloverleaf := SKCloverleaf newInGrid: self grid at: 2 @ 1.
self assert: false = kara onCloverleaf.
SKCloverleaf newInGrid: self grid at: 2 @ 1.
self deny: kara onCloverleaf

]

{
#category : #testing,
#'squeak_changestamp' : 'jt 6/11/2024 11:57'
#'squeak_changestamp' : 'JJG 6/18/2024 18:40'
}
SKKaraTest >> testOnCloverleaf [

| kara cloverleaf |
| kara |

kara := SKKara newInGrid: self grid.
cloverleaf := SKCloverleaf newInGrid: self grid.
self assert: true = kara onCloverleaf.
SKCloverleaf newInGrid: self grid.
self assert: kara onCloverleaf

]

{
#category : #testing,
#'squeak_changestamp' : 'jt 6/11/2024 13:23'
#'squeak_changestamp' : 'JJG 6/18/2024 18:39'
}
SKKaraTest >> testTrunkAhead [

| kara trunk |
| kara |

kara := SKKara newInGrid: self grid.
trunk := SKTrunk newInGrid: self grid at: 2 @ 1.
self assert: true = kara trunkAhead.
SKTrunk newInGrid: self grid at: 2 @ 1.
self assert: kara trunkAhead

]

Expand Down

0 comments on commit 40f3db1

Please sign in to comment.