X Tutup
Skip to content

Commit 9043ed1

Browse files
author
Johan Brichau
authored
Merge pull request SeasideSt#44 from SeasideSt/fix-grdynamicvar
Fixes for GRDynamicVariable in GemStone
2 parents 3f844f3 + b2e8396 commit 9043ed1

File tree

6 files changed

+21
-8
lines changed

6 files changed

+21
-8
lines changed
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
accessing
22
use: anObject during: aBlock
3-
| p oldValue result |
4-
"Proper implementation instead of use 'super value:during:' because that one does not return value, perhaps this should be fixed in DynamicVariable?"
3+
| p hasOldValue oldValue result |
4+
"Implementation cannot send a supercall to value:during: because:
5+
- this method needs to return the value
6+
- the defaultValue may not be invoked here to support throwing errors as defaultValue
7+
- nil may not remain installed as the default value once the block has finished running"
58
p := Processor activeProcess.
9+
hasOldValue := p environment includesKey: self.
610
oldValue := p environmentAt: self.
711
[
812
p environmentAt: self put: anObject.
913
result := aBlock value ]
10-
ensure: [ p environmentAt: self put: oldValue ].
14+
ensure: [
15+
hasOldValue
16+
ifFalse: [ p environment removeKey: self ]
17+
ifTrue: [ p environmentAt: self put: oldValue ] ].
1118
^ result

repository/Grease-GemStone-Core.package/GRDynamicVariable.class/methodProperties.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"class" : {
33
"default" : "JohanBrichau 07/23/2017 09:48",
44
"defaultValue" : "JohanBrichau 07/23/2017 09:47",
5-
"use:during:" : "JohanBrichau 07/23/2017 07:39" },
5+
"use:during:" : "JB 09/08/2017 00:34" },
66
"instance" : {
77
} }

repository/Grease-GemStone-Core.package/monticello.meta/version

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
tests
22
testDefaultValue
3-
self assert: GRTestDynamicVariable value = 'default test value'
3+
self assert: GRTestDynamicVariable value = 'default test value'.
4+
5+
GRTestDynamicVariable
6+
use: 'my value'
7+
during: [ ].
8+
self assert: GRTestDynamicVariable value = 'default test value' description:'The default value is no longer correct'.
9+

repository/Grease-Tests-Core.package/GRDynamicVariableTest.class/methodProperties.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"testWithoutValue" : "MaxLeske 5/18/2017 07:42",
44
"testAnswer" : "MaxLeske 5/18/2017 07:42",
55
"testWithNestedValue" : "MaxLeske 5/18/2017 07:42",
6-
"testDefaultValue" : "JohanBrichau 7/23/2017 16:57",
6+
"testDefaultValue" : "JohanBrichau 9/8/2017 09:53",
77
"testWithValue" : "MaxLeske 5/18/2017 07:42"
88
},
99
"class" : { }

repository/Grease-Tests-Core.package/monticello.meta/version

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
X Tutup