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@307 | 1 | #!/usr/bin/env python |
paul@307 | 2 | |
paul@307 | 3 | """ |
paul@307 | 4 | This test attempts to cause the recording of the usage of 'C' in the function |
paul@307 | 5 | 'f', alongside the expectation that 'D' might be used instead. A guard |
paul@307 | 6 | stipulating constraints for all of 'f' cannot therefore be generated. Meanwhile, |
paul@307 | 7 | the method 'E.h' should be eliminated. |
paul@307 | 8 | """ |
paul@307 | 9 | |
paul@307 | 10 | class C: |
paul@307 | 11 | def f(self): |
paul@307 | 12 | return 1 |
paul@307 | 13 | |
paul@307 | 14 | class D: |
paul@307 | 15 | def g(self): |
paul@307 | 16 | return 2 |
paul@307 | 17 | |
paul@307 | 18 | class E: |
paul@307 | 19 | def h(self): # unused |
paul@307 | 20 | return 3 |
paul@307 | 21 | |
paul@307 | 22 | def f(c): |
paul@307 | 23 | if 1: |
paul@307 | 24 | if 1: |
paul@307 | 25 | x = c.f() |
paul@307 | 26 | return x |
paul@307 | 27 | return c.g() |
paul@307 | 28 | |
paul@307 | 29 | c = C() |
paul@307 | 30 | d = D() |
paul@307 | 31 | e = E() |
paul@307 | 32 | result1_1 = f(c) |
paul@307 | 33 | |
paul@307 | 34 | # vim: tabstop=4 expandtab shiftwidth=4 |