micropython

tests/abandoned_attribute_usage.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'. Meanwhile, the methods 'D.g' and 'E.h' should be eliminated.     6 """     7      8 class C:     9     def f(self):    10         return 1    11     12 class D:    13     def g(self):    # unused    14         return 2    15     16 class E:    17     def h(self):    # unused    18         return 3    19     20 def f(c):    21     if 1:    22         return c.f()    23     else:    24         return 2    25     26 c = C()    27 d = D()    28 e = E()    29 result1_1 = f(c)    30     31 # vim: tabstop=4 expandtab shiftwidth=4