2010-02-14 | Paul Boddie | file changeset files shortlog | Introduced a distinction between speculative attribute usage, which should affect the possible types associated with each name, and coverage-related usage. Added support for the recording of speculative usage as "alternatives" where the expectations of a given name might differ from the consensus due to branches whose usage are never merged back into the general control-flow. |
paul@306 | 1 | #!/usr/bin/env python |
paul@306 | 2 | |
paul@306 | 3 | """ |
paul@306 | 4 | This test attempts to cause the recording of the usage of 'C' in the function |
paul@306 | 5 | 'g', alongside the expectation that 'D' might be used instead. A guard |
paul@306 | 6 | stipulating constraints for all of 'g' cannot therefore be generated. |
paul@306 | 7 | """ |
paul@306 | 8 | |
paul@306 | 9 | class C: |
paul@306 | 10 | def f(self): |
paul@306 | 11 | return 1 |
paul@306 | 12 | |
paul@306 | 13 | class D: |
paul@306 | 14 | def g(self): |
paul@306 | 15 | return 2 |
paul@306 | 16 | |
paul@306 | 17 | def h(self): |
paul@306 | 18 | return 3 |
paul@306 | 19 | |
paul@306 | 20 | def g(c): |
paul@306 | 21 | if 1: |
paul@306 | 22 | c.g() |
paul@306 | 23 | if 1: |
paul@306 | 24 | return c.h() |
paul@306 | 25 | return c.f() |
paul@306 | 26 | |
paul@306 | 27 | c = C() |
paul@306 | 28 | d = D() |
paul@306 | 29 | result1_3 = g(d) |
paul@306 | 30 | |
paul@306 | 31 | # vim: tabstop=4 expandtab shiftwidth=4 |