[View] [Edit] [Lock] [References] [Attachments] [History] [Home] [Changes] [Search] [Help]
test[S8ObjC] cast-bool
SwikiCodeRobot @> #testS8ObjCCastBool |
"get a little closer"
| pool nsNumber nsString |
pool := (ObjCClass named: #NSAutoreleasePool in: #Foundation) newInstanceHandle.
nsNumber := (ObjCClass named: #NSNumber) handle.
nsString := (ObjCClass named: #NSString) handle.
(nsNumber value: #numberWithBool value: false) toString = $0 ifFalse: [ self error: 'Wrong value 0' ].
(nsNumber value: #numberWithBool value: true) toString = $1 ifFalse: [ self error: 'Wrong value 1' ].
((S8ObjC current handle value: $Y) value: #boolValue) = true ifFalse: [ self error: 'Must be true' ].
((S8ObjC current handle value: $N) value: #boolValue) = false ifFalse: [ self error: 'Must be false' ].
((nsString value: #stringWithString value: (S8ObjC current handle value: $N))
value: #boolValue) = false ifFalse: [ self error: 'Must be boolValue false' ].
((nsString value: #stringWithString value: (S8ObjC current handle value: $Y))
value: #boolValue) = true ifFalse: [ self error: 'Must be boolValue true' ].
Smalltalk gc.
self print: #done