2 # Copyright (C) 2007-2010, Parrot Foundation.
7 t/pmc/scheduler.t - Concurrency Scheduler
11 % prove t/pmc/scheduler.t
15 Tests the concurrency scheduler PMC.
21 .include 'test_more.pir'
24 create_and_set_attributes()
25 create_concurrent_scheduler_with_init()
26 add_event_and_handler_to_scheduler()
29 .sub create_and_set_attributes
30 $P0 = new ['Scheduler']
37 if null $P2 goto no_task
38 $P3 = getattribute $P2, 'status'
40 is($S0, "created", "got task")
44 ok(0,"no task to retrieve")
48 ok(1, "didn't explode")
51 .sub create_concurrent_scheduler_with_init
60 $P0 = new ['Scheduler'], data
67 if null $P2 goto no_task
68 $P3 = getattribute $P2, 'status'
70 is($S0, "created", "status is ok")
74 ok(0, 'no task to retrieve')
79 push_eh bad_initializer
80 $P0 = new ['Scheduler'], id
83 ok(0, "No exception on invalid initializer? Uh oh!")
87 ok(1, "Caught exception on bad initializer")
91 .sub add_event_and_handler_to_scheduler
92 .local pmc handler, handler_init, handler_sub
93 .local pmc event, event_init
94 handler_init = new ['Hash']
95 handler_init['type'] = 'myevent'
96 handler_sub = get_global 'my_event_handler'
97 handler_init['code'] = handler_sub
98 handler = new ['EventHandler'], handler_init
102 event_init = new ['Hash']
103 event_init['type'] = 'event'
104 event_init['subtype'] = 'myevent'
105 event = new ['Task'], event_init
111 .sub my_event_handler
113 .param pmc handledtask
114 ok(1, "called event handler")
121 # vim: expandtab shiftwidth=4 ft=pir: