micropython

tests/abandoned_attribute_usage_multiple_candidates.py

515:20ea2e9b841d
2012-06-03 Paul Boddie Restricted attribute assignments observed through usage analysis to instance attributes only.
     1 #!/usr/bin/env python     2      3 """     4 This test attempts to cause the recording of the usage of 'C' in the function     5 'f', alongside the expectation that 'D' might be used instead with the function     6 'g'. A guard cannot therefore be generated. Meanwhile, the method 'E.h' should     7 be eliminated.     8 """     9     10 class C:    11     def f(self):    12         return 1    13     14 class D:    15     def g(self):    16         return 2    17     18 class E:    19     def h(self):    # unused    20         return 3    21     22 def f(c):    23     if 1:    24         return c.f()    25     return c.g()    26     27 c = C()    28 d = D()    29 e = E()    30 result1_1 = f(c)    31     32 # vim: tabstop=4 expandtab shiftwidth=4