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

test[S8ObjC] instanceof

SwikiCodeRobot @> #testS8ObjCInstanceof

"Obj-C Classes should be instances of Class and ID"
| nsObject object |
nsObject := ObjCClass classNamed: #NSObject.
object := ID  @ nsObject newInstanceHandle.

#( Function Class ID ) do: [:type|
	(nsObject instanceOf: type) ifFalse: [
		self error: 'NSObject IS NOT an instance of ' ,type
	].
].
#( Exception ) do: [:type|
	(nsObject instanceOf: type) ifTrue: [
		self error: 'NSObject IS an instance of ' ,type
	].
].

#( Function ID ) do: [:type|
	(object instanceOf: type) ifFalse: [
		self error: 'Instance IS NOT an instance of ' ,type
	].
].
#( Class Exception ) do: [:type|
	(object instanceOf: type) ifTrue: [
		self error: 'Instance IS an instance of ' ,type
	].
].

self print: #ok