2010-09-07 | Paul Boddie | file changeset files shortlog | Changed attribute usage tracking to consider branching and separate usage possibilities in a slightly more rigourous way. Attempted to add isinstance support. Added tests of the revised attribute usage support. |
paul@269 | 1 | #!/usr/bin/env python |
paul@269 | 2 | |
paul@269 | 3 | class C: |
paul@269 | 4 | def f(self): |
paul@269 | 5 | return 1 |
paul@269 | 6 | |
paul@269 | 7 | class D: |
paul@269 | 8 | def f(self): |
paul@269 | 9 | return 2 |
paul@269 | 10 | |
paul@269 | 11 | def g(self): |
paul@269 | 12 | return 3 |
paul@269 | 13 | |
paul@275 | 14 | class E: |
paul@275 | 15 | def f(self): |
paul@275 | 16 | return 4 |
paul@275 | 17 | |
paul@275 | 18 | def h(self): |
paul@275 | 19 | return 5 |
paul@275 | 20 | |
paul@279 | 21 | def test_new_conditional(obj, obj2): |
paul@275 | 22 | # obj: |
paul@279 | 23 | # obj2: |
paul@275 | 24 | if obj.f(): # C, D, E (f) |
paul@279 | 25 | obj = obj2 # obj: D (g) |
paul@275 | 26 | obj.g() # D (g) |
paul@275 | 27 | else: |
paul@275 | 28 | obj.h() # E (f, h) |
paul@275 | 29 | # # (g) ^ (f, h) |
paul@275 | 30 | return 5 |
paul@269 | 31 | |
paul@269 | 32 | c = C() |
paul@269 | 33 | d = D() |
paul@275 | 34 | e = E() |
paul@279 | 35 | result1_5 = test_new_conditional(e, d) |
paul@269 | 36 | |
paul@269 | 37 | # vim: tabstop=4 expandtab shiftwidth=4 |