def test_static_event(self): from Merlin.Testing import Flag from Merlin.Testing.Event import ClassWithStaticEvent, TargetClass, TargetStruct for t1 in [ ClassWithStaticEvent, #StructWithStaticEvent ]: x = t1() tc, ts = TargetClass(), TargetStruct() t1.OnAction += TargetClass.s_Double t1.OnAction += TargetStruct.s_Negate t1.OnAction += tc.i_Square Flag.Set(0) self.assertEqual(x.CallInside(30), 900) Flag.Set(111) t1.OnAction += ts.i_Negate Flag.Set(0) self.assertEqual(x.CallInside(31), -31) Flag.Check(121) t1.OnAction -= TargetStruct.s_Negate t1.OnAction -= ts.i_Double # not added before t1.OnAction -= tc.i_Square Flag.Set(0) self.assertEqual(x.CallInside(32), -32) Flag.Set(11) Flag.Set(0) t1.OnAction -= ts.i_Negate self.assertEqual(x.CallInside(33), 66) Flag.Set(1)
def f2(): DerivedClassWithStaticEvent.OnAction -= TargetStruct().s_Double