2013-07-01 | Paul Boddie | file changeset files shortlog | Introduced numbered functions where rebinding occurs in namespaces. Added an original name attribute to classes and functions, revised the check for usage of functions when generating code or reports, and added rebinding statements to module "main program" syspython output. Fixed the attribute operation generated by syspython when acquiring module attributes for a "from" statement. | syspython-as-target |
paul@288 | 1 | #!/usr/bin/env python |
paul@288 | 2 | |
paul@323 | 3 | """ |
paul@549 | 4 | This test attempts to record the usage of 'C', 'D' or 'E' in 'test_conditional' |
paul@549 | 5 | since 'f' and 'g' might be used, but only 'f' is actually required. Although |
paul@549 | 6 | only 'D' provides both attributes, classes 'C' and 'E' provide 'f'. |
paul@323 | 7 | """ |
paul@323 | 8 | |
paul@288 | 9 | class C: |
paul@549 | 10 | def f(self): # unused but retained |
paul@288 | 11 | return 1 |
paul@288 | 12 | |
paul@288 | 13 | class D: |
paul@288 | 14 | def f(self): |
paul@288 | 15 | return 2 |
paul@288 | 16 | |
paul@288 | 17 | def g(self): |
paul@288 | 18 | return 3 |
paul@288 | 19 | |
paul@288 | 20 | class E: |
paul@549 | 21 | def f(self): # unused but retained |
paul@288 | 22 | return 4 |
paul@288 | 23 | |
paul@323 | 24 | def h(self): # unused |
paul@288 | 25 | return 5 |
paul@288 | 26 | |
paul@288 | 27 | def test_conditional(obj): |
paul@380 | 28 | # obj: f, g; f |
paul@323 | 29 | if obj.f(): |
paul@323 | 30 | obj.g() |
paul@288 | 31 | return 2 |
paul@288 | 32 | |
paul@288 | 33 | c = C() |
paul@288 | 34 | d = D() |
paul@288 | 35 | e = E() |
paul@288 | 36 | result1_2 = test_conditional(d) |
paul@288 | 37 | |
paul@288 | 38 | # vim: tabstop=4 expandtab shiftwidth=4 |