micropython

Annotated tests/abandoned_attribute_usage_multiple_candidates.py

685:5f2c0e22fd40
2013-10-08 Paul Boddie Fixed relative import path interpretation to work within package roots. syspython-as-target
paul@304 1
#!/usr/bin/env python
paul@304 2
paul@304 3
"""
paul@304 4
This test attempts to cause the recording of the usage of 'C' in the function
paul@318 5
'f', alongside the expectation that 'D' might be used instead with the function
paul@318 6
'g'. A guard cannot therefore be generated. Meanwhile, the method 'E.h' should
paul@318 7
be eliminated.
paul@304 8
"""
paul@304 9
paul@304 10
class C:
paul@304 11
    def f(self):
paul@304 12
        return 1
paul@304 13
paul@304 14
class D:
paul@304 15
    def g(self):
paul@304 16
        return 2
paul@304 17
paul@304 18
class E:
paul@304 19
    def h(self):    # unused
paul@304 20
        return 3
paul@304 21
paul@304 22
def f(c):
paul@304 23
    if 1:
paul@304 24
        return c.f()
paul@304 25
    return c.g()
paul@304 26
paul@304 27
c = C()
paul@304 28
d = D()
paul@304 29
e = E()
paul@304 30
result1_1 = f(c)
paul@304 31
paul@304 32
# vim: tabstop=4 expandtab shiftwidth=4