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

test[S8Ref] reinterpret

"should return a new Buffer instance at the same address"
| buf small reinterpreted  | Smalltalk gc.
buf := NodeBuffer string: 'hello world'.
small := buf slice: 0 end: 0.
small size = 0 ifFalse: [ ^self error: 'Invalid small size' ].
buf address = small address ifFalse: [ ^self error: 'invalid address' ].
reinterpreted := small reinterpret: buf size.
buf address = reinterpreted address ifFalse: [ ^self error: 'invalid reinterpreted  address ',buf address,' vs. ',reinterpreted address ].
buf size = reinterpreted size ifFalse: [ ^self error: 'invalid reinterpreted  size' ].
buf handle toString = reinterpreted handle toString ifFalse: [ ^self error: 'invalid reinterpreted  contents' ].


"should return a new Buffer instance starting at the offset address"
| buf offset small reinterpreted  | Smalltalk gc.
buf := NodeBuffer string: 'hello world'.
offset := 3.
small := buf slice: offset end: buf length.
buf size - offset = small size ifFalse: [ ^self error: 'Invalid small size' ].
buf address + offset = small address ifFalse: [ ^self error: 'invalid address' ].
reinterpreted := small reinterpret: small size offset: offset.
small address = reinterpreted address ifFalse: [ ^self error: 'invalid reinterpreted  address ',small address,' vs. ',reinterpreted address ].
small size = reinterpreted size ifFalse: [ ^self error: 'invalid reinterpreted  size' ].
small handle toString = reinterpreted handle toString ifFalse: [ ^self error: 'invalid reinterpreted  contents' ].