[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

test[S8Struct] set

"should work to set() an Object"
| type b s |
type := S8Struct type: #(#(test1 int) #(test2 int)).
b := NodeBuffer size: type#size * 2.
type #set: b handle at: type#size * 0 with: (#test1 -> 7123 ,(#test2 -> -555)) json.
s := S8Struct @ (type value: b handle).
s @ #test1 = 7123 ifFalse: [ self error: 'Wrong 7123 value' ].
s @ #test2 = -555 ifFalse: [ self error: 'Wrong -555 value' ].
type #set: b handle at: type#size * 1 with: (#test1 -> 1234 ,(#test2 -> -1234)) json.
s := S8Struct @ (type value: (b slice: type#size) handle).
s @ #test1 = 1234 ifFalse: [ self error: 'Wrong 1234 value' ].
s @ #test2 = -1234 ifFalse: [ self error: 'Wrong -1234 value' ].


"should work to set() a S8Struct"
| type b s |
type := S8Struct type: #(#(test1 int) #(test2 int)).
b := NodeBuffer size: type#size * 2.
type #set: b handle at: type#size * 0 with: (type
  value: (#test1 -> 7123 ,(#test2 -> -555)) json).
s := S8Struct @ (type value: b handle).
s @ #test1 = 7123 ifFalse: [ self error: 'Wrong 7123 value' ].
s @ #test2 = -555 ifFalse: [ self error: 'Wrong -555 value' ].
type #set: b handle at: type#size * 1 with: (type
  value: (#test1 -> 1234 ,(#test2 -> -1234)) json).
s := S8Struct @ (type value: (b slice: type#size) handle).
s @ #test1 = 1234 ifFalse: [ self error: 'Wrong 1234 value' ].
s @ #test2 = -1234 ifFalse: [ self error: 'Wrong -1234 value' ].