Skip to content

Commit

Permalink
make thisContext test work for Squeak
Browse files Browse the repository at this point in the history
  • Loading branch information
Johan Brichau committed Apr 9, 2022
1 parent 74f54ab commit 1d8daee
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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
ctx := self platform thisContext.
(ctx respondsTo: #tempNamed:)
ifTrue:[ self assert: (ctx tempNamed: 'block') == block ]
ifFalse: [ self assert: (ctx namedTempAt: (ctx tempNames indexOf: #block)) == block ]

0 comments on commit 1d8daee

Please sign in to comment.