2010-08-07 | Paul Boddie | file changeset files shortlog | Added some support for HTML reports of program modules, separating the program finalisation out into a separate method of the Program class, in order to avoid obtaining an actual program image, yet removing unneeded parts of a program. Moved code to test for the usage of program sections into the common module, since this is also useful when generating reports. Added AST node annotation documentation. |
paul@288 | 1 | #!/usr/bin/env python |
paul@288 | 2 | |
paul@323 | 3 | """ |
paul@323 | 4 | This test attempts to record the usage of 'D' in 'test_conditional' since 'f' |
paul@323 | 5 | and 'g' are both normally required, and only 'D' provides these attributes. |
paul@323 | 6 | Classes 'C' and 'E' should lose their methods, even 'E.f'. |
paul@323 | 7 | """ |
paul@323 | 8 | |
paul@288 | 9 | class C: |
paul@323 | 10 | def f(self): # unused |
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@323 | 21 | def f(self): # unused |
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@323 | 28 | if obj.f(): |
paul@323 | 29 | obj.g() |
paul@288 | 30 | return 2 |
paul@288 | 31 | |
paul@288 | 32 | c = C() |
paul@288 | 33 | d = D() |
paul@288 | 34 | e = E() |
paul@288 | 35 | result1_2 = test_conditional(d) |
paul@288 | 36 | |
paul@288 | 37 | # vim: tabstop=4 expandtab shiftwidth=4 |