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@310 | 1 | #!/usr/bin/env python |
paul@310 | 2 | |
paul@310 | 3 | """ |
paul@310 | 4 | This test illustrates the need for usage to be propagated forward to the |
paul@310 | 5 | assignment within the loop. |
paul@310 | 6 | """ |
paul@310 | 7 | |
paul@310 | 8 | class C: |
paul@310 | 9 | def e(self): # unused |
paul@310 | 10 | return 1 |
paul@310 | 11 | |
paul@310 | 12 | def f(self): |
paul@310 | 13 | return 1 |
paul@310 | 14 | |
paul@310 | 15 | class D: |
paul@310 | 16 | def f(self): |
paul@310 | 17 | return 2 |
paul@310 | 18 | |
paul@310 | 19 | def g(self): |
paul@310 | 20 | return 3 |
paul@310 | 21 | |
paul@310 | 22 | class E: |
paul@310 | 23 | def e(self): |
paul@310 | 24 | return 4 |
paul@310 | 25 | |
paul@310 | 26 | def f(self): |
paul@310 | 27 | return 0 # stops the test loop |
paul@310 | 28 | |
paul@310 | 29 | def g(self): |
paul@310 | 30 | return 5 |
paul@310 | 31 | |
paul@310 | 32 | def test_loop(obj, obj2): |
paul@310 | 33 | while obj.f(): |
paul@310 | 34 | obj.g() |
paul@310 | 35 | obj = obj2 # should support e, f, g |
paul@310 | 36 | obj.e() |
paul@310 | 37 | return obj.f() |
paul@310 | 38 | |
paul@310 | 39 | c = C() |
paul@310 | 40 | d = D() |
paul@310 | 41 | e = E() |
paul@310 | 42 | result1_0 = test_loop(d, e) |
paul@310 | 43 | |
paul@310 | 44 | # vim: tabstop=4 expandtab shiftwidth=4 |