[View] [Edit] [Lock] [References] [Attachments] [History] [Home] [Changes] [Search] [Help]
test[S8ObjC] nsTimer
SwikiCodeRobot @> #testS8ObjCNsTimer |
"nsTimer test"
| cls object count |
count := 0.
cls := (ObjCClass named: #NSObject) extend: #TimerTest.
cls addMethod: #sel: type: 'v@:@' function: [:sel :cmd :timer|
"(timer value: #userInfo) toString = #Info ifFalse: [ self error: 'Wrong timer info' ]."
self print: 'Executing method...'.
count := count + 1.
count = 5 ifTrue: [
timer value: #invalidate.
NodeJS process exit: 0
].
].
cls register.
object := cls newInstanceHandle.
self error: ' Will crash if we continue'.
(ObjCClass named: #NSTimer) handle valueWithArguments: #(
scheduledTimerWithTimeInterval 0.5
target),(Array with: object),#(
selector sel:
userInfo),(Array with: (S8ObjC value: #Info)),#(
repeats 1).
NodeJS process on: #exit do: [
count = 5 ifFalse: [ self print: 'error: wrong count' ]
].
((ObjCClass named: #NSRunLoop) handle value: #mainRunLoop) value: #run.
#ok