X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
accessing
use: anObject during: aBlock
| p oldValue result |
"Proper implementation instead of use 'super value:during:' because that one does not return value, perhaps this should be fixed in DynamicVariable?"
| p hasOldValue oldValue result |
"Implementation cannot send a supercall to value:during: because:
- this method needs to return the value
- the defaultValue may not be invoked here to support throwing errors as defaultValue
- nil may not remain installed as the default value once the block has finished running"
p := Processor activeProcess.
hasOldValue := p environment includesKey: self.
oldValue := p environmentAt: self.
[
p environmentAt: self put: anObject.
result := aBlock value ]
ensure: [ p environmentAt: self put: oldValue ].
ensure: [
hasOldValue
ifFalse: [ p environment removeKey: self ]
ifTrue: [ p environmentAt: self put: oldValue ] ].
^ result
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"class" : {
"default" : "JohanBrichau 07/23/2017 09:48",
"defaultValue" : "JohanBrichau 07/23/2017 09:47",
"use:during:" : "JohanBrichau 07/23/2017 07:39" },
"use:during:" : "JB 09/08/2017 00:34" },
"instance" : {
} }

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
tests
testDefaultValue
self assert: GRTestDynamicVariable value = 'default test value'
self assert: GRTestDynamicVariable value = 'default test value'.

GRTestDynamicVariable
use: 'my value'
during: [ ].
self assert: GRTestDynamicVariable value = 'default test value' description:'The default value is no longer correct'.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"testWithoutValue" : "MaxLeske 5/18/2017 07:42",
"testAnswer" : "MaxLeske 5/18/2017 07:42",
"testWithNestedValue" : "MaxLeske 5/18/2017 07:42",
"testDefaultValue" : "JohanBrichau 7/23/2017 16:57",
"testDefaultValue" : "JohanBrichau 9/8/2017 09:53",
"testWithValue" : "MaxLeske 5/18/2017 07:42"
},
"class" : { }
Expand Down

Large diffs are not rendered by default.

X Tutup