1 #!/usr/bin/env python 2 3 """ 4 This test illustrates the need for usage to be propagated forward to the 5 assignment within the loop. 6 """ 7 8 class C: 9 def e(self): # unused 10 return 1 11 12 def f(self): 13 return 1 14 15 class D: 16 def f(self): 17 return 2 18 19 def g(self): 20 return 3 21 22 def h(self): 23 return 4 24 25 class E: 26 def e(self): 27 return 4 28 29 def f(self): 30 return 0 # stops the test loop 31 32 def g(self): 33 return 5 34 35 def h(self): 36 return 6 37 38 def test_loop(obj, obj2): 39 # obj: f, g (from loop); f, h (outside loop) 40 while obj.f(): 41 # obj: g (in loop) 42 obj.g() 43 obj = obj2 # obj: e, f, h 44 obj.e() 45 # (test invoked again) 46 return obj.h() 47 48 c = C() 49 d = D() 50 e = E() 51 result_6 = test_loop(d, e) 52 53 # vim: tabstop=4 expandtab shiftwidth=4