From 19cc2162c5b84a4cbf9507bddcdc956520fe896f Mon Sep 17 00:00:00 2001 From: Johanna Gasse Date: Tue, 18 Jun 2024 19:08:52 +0200 Subject: [PATCH] more tests --- src/SqueakKara-Core/SKEnvironment.class.st | 8 +- src/SqueakKara-Core/SKKaraDecorator.class.st | 9 -- .../SKEnvironmentTest.class.st | 9 +- .../SKKaraDecoratorTest.class.st | 141 ++++++++++++++++++ 4 files changed, 151 insertions(+), 16 deletions(-) create mode 100644 src/SqueakKara-Tests/SKKaraDecoratorTest.class.st diff --git a/src/SqueakKara-Core/SKEnvironment.class.st b/src/SqueakKara-Core/SKEnvironment.class.st index 840a7cf..30981d1 100644 --- a/src/SqueakKara-Core/SKEnvironment.class.st +++ b/src/SqueakKara-Core/SKEnvironment.class.st @@ -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 [ @@ -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 [ @@ -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. ] { diff --git a/src/SqueakKara-Core/SKKaraDecorator.class.st b/src/SqueakKara-Core/SKKaraDecorator.class.st index 1ceecee..9774a71 100644 --- a/src/SqueakKara-Core/SKKaraDecorator.class.st +++ b/src/SqueakKara-Core/SKKaraDecorator.class.st @@ -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' diff --git a/src/SqueakKara-Tests/SKEnvironmentTest.class.st b/src/SqueakKara-Tests/SKEnvironmentTest.class.st index 260cd1c..6ed11dd 100644 --- a/src/SqueakKara-Tests/SKEnvironmentTest.class.st +++ b/src/SqueakKara-Tests/SKEnvironmentTest.class.st @@ -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 [ @@ -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) ] @@ -116,7 +117,7 @@ SKEnvironmentTest >> testMove [ { #category : #testing, - #'squeak_changestamp' : 'JJG 6/18/2024 12:17' + #'squeak_changestamp' : 'JJG 6/18/2024 19:06' } SKEnvironmentTest >> testMoveTwice [ @@ -124,12 +125,13 @@ SKEnvironmentTest >> testMoveTwice [ 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 [ @@ -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) ] diff --git a/src/SqueakKara-Tests/SKKaraDecoratorTest.class.st b/src/SqueakKara-Tests/SKKaraDecoratorTest.class.st new file mode 100644 index 0000000..2004639 --- /dev/null +++ b/src/SqueakKara-Tests/SKKaraDecoratorTest.class.st @@ -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 +]