1 #!/usr/bin/env python 2 3 class C: 4 def f(self): 5 return 1 6 7 class D: 8 def f(self): 9 return 2 10 11 def g(self): 12 return 3 13 14 class E: 15 def f(self): 16 return 4 17 18 def h(self): 19 return 5 20 21 def test_new(obj, obj2): 22 # obj: C, D, E (f) 23 # obj2: 24 if obj.f(): # C, D, E (f) 25 obj = obj2 # obj: D (g) 26 obj.g() # D (g) 27 # else: 28 # ... # obj: C, D, E (f) 29 # # (g) ^ (f) 30 return obj.f() # C, D, E (f) 31 32 def test_neither(obj, obj2): 33 # obj: 34 # obj2: 35 if 0: 36 obj.g() # D (g) 37 else: 38 obj.f() # C, D, E (f) 39 # # (g) ^ (f) 40 return 4 41 42 def test_new_conditional(obj, obj2): 43 # obj: 44 # obj2: 45 if obj.f(): # C, D, E (f) 46 obj = obj2 # obj: D (g) 47 obj.g() # D (g) 48 else: 49 obj.h() # E (f, h) 50 # # (g) ^ (f, h) 51 return 5 52 53 c = C() 54 d = D() 55 e = E() 56 result2_2 = test_new(c, d) 57 result1_4 = test_neither(c, d) 58 result1_5 = test_new_conditional(e, d) 59 60 # vim: tabstop=4 expandtab shiftwidth=4