diff --git a/src/SqueakKara-Core/SKEnvironment.class.st b/src/SqueakKara-Core/SKEnvironment.class.st index 7001b11..840a7cf 100644 --- a/src/SqueakKara-Core/SKEnvironment.class.st +++ b/src/SqueakKara-Core/SKEnvironment.class.st @@ -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. ] diff --git a/src/SqueakKara-Core/SKWorkspace.class.st b/src/SqueakKara-Core/SKWorkspace.class.st index 803a262..3a01189 100644 --- a/src/SqueakKara-Core/SKWorkspace.class.st +++ b/src/SqueakKara-Core/SKWorkspace.class.st @@ -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 ] { diff --git a/src/SqueakKara-Tests/SKEnvironmentTest.class.st b/src/SqueakKara-Tests/SKEnvironmentTest.class.st index c50f65f..260cd1c 100644 --- a/src/SqueakKara-Tests/SKEnvironmentTest.class.st +++ b/src/SqueakKara-Tests/SKEnvironmentTest.class.st @@ -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 ] diff --git a/src/SqueakKara-Tests/SKKaraTest.class.st b/src/SqueakKara-Tests/SKKaraTest.class.st index 47a6aec..ae3705d 100644 --- a/src/SqueakKara-Tests/SKKaraTest.class.st +++ b/src/SqueakKara-Tests/SKKaraTest.class.st @@ -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 [ @@ -54,13 +54,13 @@ 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 [ @@ -68,29 +68,113 @@ SKKaraTest >> testAbsolutePositionAfterMoveWithDefaultDirection [ 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 + ] { @@ -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 ]