2010-09-13 | Paul Boddie | file changeset files shortlog | Added a special class for abandoned branch users dictionaries, preventing any usage being recorded after a branch is abandoned. Moved any else clauses for "for" and "while" loops into the loop branch during inspection, thus combining loop usage with the termination clause of each loop. Added various tests and notes. |
paul@385 | 1 | #!/usr/bin/env python |
paul@385 | 2 | |
paul@385 | 3 | class C: |
paul@385 | 4 | def e(self): |
paul@385 | 5 | return 2 |
paul@385 | 6 | |
paul@385 | 7 | def f(self): |
paul@385 | 8 | return 1 |
paul@385 | 9 | |
paul@385 | 10 | class D: |
paul@385 | 11 | def e(self): |
paul@385 | 12 | return 6 |
paul@385 | 13 | |
paul@385 | 14 | def f(self): |
paul@385 | 15 | return 0 # stops the test loop |
paul@385 | 16 | |
paul@385 | 17 | def g(self): |
paul@385 | 18 | return 3 |
paul@385 | 19 | |
paul@385 | 20 | class E: |
paul@385 | 21 | def f(self): |
paul@385 | 22 | return 4 |
paul@385 | 23 | |
paul@385 | 24 | def h(self): # unused |
paul@385 | 25 | return 5 |
paul@385 | 26 | |
paul@385 | 27 | def test_loop(obj, obj2): |
paul@385 | 28 | while obj.f(): |
paul@385 | 29 | obj = obj2 |
paul@385 | 30 | obj.g() |
paul@385 | 31 | else: |
paul@385 | 32 | obj.e() |
paul@385 | 33 | return obj.f() |
paul@385 | 34 | |
paul@385 | 35 | c = C() |
paul@385 | 36 | d = D() |
paul@385 | 37 | e = E() |
paul@385 | 38 | result1_0 = test_loop(c, d) |
paul@385 | 39 | |
paul@385 | 40 | # vim: tabstop=4 expandtab shiftwidth=4 |