def test_one_event(self):
        scheduler = mod.EventScheduler()

        event = TestEvent()
        id = scheduler.addEvent(0.0, Delegate(event, TestEvent.fire), ())
        self.failIf(scheduler.getTime() != 0.0)
        self.failIf(scheduler.getTopTime() != 0.0)
        self.failIf(scheduler.getTopID() != id)

        scheduler.step()
        self.failIf(scheduler.getSize() != 0)
Exemple #2
0
    def test_one_event(self):
        scheduler = mod.EventScheduler()

        event = mod.Event(1.0)
        id = scheduler.add(event)
        self.failIf(scheduler.time != 0.0)
        self.failIf(scheduler.top[1].time != 1.0)
        self.failIf(scheduler.top[0] != id)

        self.assertEqual((id, event), scheduler.pop())
        self.failIf(scheduler.size != 0)
        self.failIf(scheduler.time != 1.0)
Exemple #3
0
    def test_peek_second_event(self):

        scheduler = mod.EventScheduler()

        event1 = mod.Event(1.0)
        event2 = mod.Event(0.5)

        event1_id = scheduler.add(event1)

        id2 = scheduler.add(event2)

        self.assertEqual(2, scheduler.size)

        second = scheduler.second

        self.assertEqual(1.0, second[1].time)
        self.assertEqual(event1_id, second[0])
    def test_peek_second_event(self):

        scheduler = mod.EventScheduler()

        event1 = TestEvent()
        event2 = TestEvent3(scheduler, event1)
        event1.dt = 1.0
        event2.dt = 1.0

        event1.id = scheduler.addEvent(0.0, Delegate(event1, TestEvent.fire),
                                       event1)

        id2 = scheduler.addEvent(0.5, Delegate(event2, TestEvent3.fire),
                                 event2)
        self.assertEqual(2, scheduler.getSize())

        second = scheduler.peekSecondEvent()

        self.assertEqual(0.5, second.getTime())
        self.assertEqual(event2, second.getArg())
Exemple #5
0
 def test_empty_state(self):
     scheduler = mod.EventScheduler()
     self.failIf(scheduler.size != 0)
     self.failIf(scheduler.time != 0.0)
Exemple #6
0
 def test_instantiation(self):
     scheduler = mod.EventScheduler()
     self.failIf(scheduler == None)
 def test_empty_state(self):
     scheduler = mod.EventScheduler()
     self.failIf(scheduler.getSize() != 0)
     self.failIf(scheduler.getTime() != 0.0)