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@377 | 1 | #!/usr/bin/env python |
paul@377 | 2 | |
paul@377 | 3 | class C: |
paul@377 | 4 | def f(self): |
paul@377 | 5 | return 0 |
paul@377 | 6 | |
paul@377 | 7 | class D: |
paul@377 | 8 | def f(self): |
paul@377 | 9 | return 2 |
paul@377 | 10 | |
paul@377 | 11 | def g(self): |
paul@377 | 12 | return 3 |
paul@377 | 13 | |
paul@377 | 14 | def test_conditional(obj): |
paul@377 | 15 | # obj: C, D (f) |
paul@377 | 16 | if obj.f(): # C, D (f) |
paul@377 | 17 | return obj.g() # D (f, g) |
paul@377 | 18 | else: |
paul@377 | 19 | return obj.f() # C (f) |
paul@377 | 20 | # # (f, g) ^ (f) |
paul@377 | 21 | |
paul@377 | 22 | c = C() |
paul@377 | 23 | d = D() |
paul@377 | 24 | result1_0 = test_conditional(c) |
paul@377 | 25 | |
paul@377 | 26 | # vim: tabstop=4 expandtab shiftwidth=4 |