The Trunk: JSON-ul.68.mcz

[email protected] Wed, 8 Jul 2026 13:54:01 0000
Newsgroups gmane.comp.lang.smalltalk.squeak.general
Message-ID <[email protected]>
Levente Uzonyi uploaded a new version of JSON to project The Trunk:
http://source.squeak.org/trunk/JSON-ul.68.mcz

==================== Summary ====================

Name: JSON-ul.68
Author: ul
Time: 8 July 2026, 1:40:59.428243 pm
UUID: 58c86f0d-cf81-4126-9459-e922710685bb
Ancestors: JSON-ct.67

- fix: JsonObject and OrderedJsonObject returned the receiver instead of the value when the key was absent when #at:ifAbsent:Put: was sent

=============== Diff against JSON-ct.67 ===============

Item was added:
+ ----- Method: JsonObject>>at:ifAbsentPut: (in category 'accessing') -----
+ at: key ifAbsentPut: aBlock 
+ 	"Return the value at the given key. 
+ 	If key is not included in the receiver store the result 
+ 	of evaluating aBlock as new value."
+ 
+ 	^self at: key ifAbsent: [
+ 		| object |
+ 		object := aBlock value.
+ 		self at: key put: object.
+ 		object ]!

Item was added:
+ ----- Method: JsonTests>>testJsonObjectAtIfAbsentPutReturnsTheValue (in category 'tests') -----
+ testJsonObjectAtIfAbsentPutReturnsTheValue
+ 
+ 	{ JsonObject. OrderedJsonObject } do: [ :jsonObjectClass |
+ 		| json |
+ 		json := 	jsonObjectClass new.
+ 		self assert: (json at: #test ifAbsentPut: [ 1 ]) = 1.
+ 		self assert: (json at: #test ifAbsentPut: [ 1 ]) = 1 ]!

Item was added:
+ ----- Method: OrderedJsonObject>>at:ifAbsentPut: (in category 'accessing') -----
+ at: key ifAbsentPut: aBlock 
+ 	"Return the value at the given key. 
+ 	If key is not included in the receiver store the result 
+ 	of evaluating aBlock as new value."
+ 
+ 	^self at: key ifAbsent: [
+ 		| object |
+ 		object := aBlock value.
+ 		self at: key put: object.
+ 		object ]!

Squeak-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]