[View] [Edit] [Lock] [References] [Attachments] [History] [Home] [Changes] [Search] [Help]
broken-test[S8ObjC] cast-buffer
SwikiCodeRobot @> #testS8ObjCCastBuffer |
"Buffer -> NSData casting"
| pool data nsdata bytes |
self print: #starting. Smalltalk gc.
pool := (ObjCClass named: #NSAutoreleasePool in: #Foundation) newInstanceHandle.
data := NodeBuffer string: 'hello world'.
nsdata := S8ObjC current handle value: data handle.
bytes := NodeBuffer @ (nsdata value: #bytes).
self print: #allocated.
data length = (nsdata value: #length) ifFalse: [ self error: 'Wrong length' ].
data toString = (bytes reinterpret: data length) toString ifFalse: [ self error: 'Wrong bytes' ].
bytes hexAddress = data hexAddress ifFalse: [ self error: 'Wrong hexAddress' ].
Smalltalk gc.
self print: #done