From 1d8daee7641b5e860eb8abd3c72652b37da6b546 Mon Sep 17 00:00:00 2001 From: Johan Brichau Date: Sat, 9 Apr 2022 15:24:54 +0200 Subject: [PATCH] make thisContext test work for Squeak --- .../GRPlatform.class/instance/version.st | 2 +- .../instance/testThisContext.st | 31 ++++++++++++------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/repository/Grease-Core.package/GRPlatform.class/instance/version.st b/repository/Grease-Core.package/GRPlatform.class/instance/version.st index 571698e7..1649dccd 100644 --- a/repository/Grease-Core.package/GRPlatform.class/instance/version.st +++ b/repository/Grease-Core.package/GRPlatform.class/instance/version.st @@ -2,5 +2,5 @@ version info version "Answer the Grease version" - ^ (GRVersion major: 1 minor: 8 revision: 2) + ^ (GRVersion major: 1 minor: 9 revision: 0) yourself \ No newline at end of file diff --git a/repository/Grease-Tests-Core.package/GRPlatformTest.class/instance/testThisContext.st b/repository/Grease-Tests-Core.package/GRPlatformTest.class/instance/testThisContext.st index 640f1966..d8fecfc7 100644 --- a/repository/Grease-Tests-Core.package/GRPlatformTest.class/instance/testThisContext.st +++ b/repository/Grease-Tests-Core.package/GRPlatformTest.class/instance/testThisContext.st @@ -1,18 +1,27 @@ tests testThisContext - | methodContext block | + | methodContext block ctx | + "This is just a basic test to see if thisContext works" methodContext := self platform thisContext. block := [ | blockContext | - blockContext := self platform thisContext. - self assert: blockContext sender = methodContext. - "The following is a difference between Gemstone and Pharo... " - (Smalltalk includesKey: #GRGemStonePlatform) - ifTrue: [ self assert: blockContext receiver = block ] - ifFalse: [ - self assert: blockContext receiver = self. - self assert: (blockContext tempNamed: 'blockContext') == blockContext ]. - self assert: (blockContext tempNamed: 'methodContext') == methodContext ]. + blockContext := self platform thisContext. + self assert: blockContext sender = methodContext. + "The following is a difference between Gemstone and Pharo... " + (Smalltalk includesKey: #GRGemStonePlatform) + ifTrue: [ self assert: blockContext receiver = block ] + ifFalse: [ + self assert: blockContext receiver = self. + (blockContext respondsTo: #tempNamed:) + ifTrue:[ self assert: (blockContext tempNamed: 'blockContext') == blockContext ] + ifFalse:[ self assert: (blockContext namedTempAt: (blockContext tempNames indexOf: #blockContext)) == blockContext ] ]. + (blockContext respondsTo: #tempNamed:) + ifTrue:[ self assert: (blockContext tempNamed: 'methodContext') == methodContext ] + ifFalse: [ self assert: (blockContext namedTempAt: (blockContext tempNames indexOf: #methodContext)) == methodContext ] ]. + block value. self assert: self returnSender = methodContext. self assert: methodContext receiver = self. - self assert: (self platform thisContext tempNamed: 'block') == block \ No newline at end of file + ctx := self platform thisContext. + (ctx respondsTo: #tempNamed:) + ifTrue:[ self assert: (ctx tempNamed: 'block') == block ] + ifFalse: [ self assert: (ctx namedTempAt: (ctx tempNames indexOf: #block)) == block ] \ No newline at end of file