2013-06-29 | Paul Boddie | file changeset files shortlog | Separated handling of getattr attribute usage from normal program unit usage, tracking only newly introduced program constants when evaluating the effects of getattr usage, and thus limiting the amount of work done identifying new program units to investigate on each occasion. | syspython-as-target |
paul@299 | 1 | #!/usr/bin/env python |
paul@299 | 2 | |
paul@310 | 3 | """ |
paul@310 | 4 | This test illustrates the need for propagation of usage to assignments providing |
paul@310 | 5 | active name definitions. |
paul@310 | 6 | """ |
paul@310 | 7 | |
paul@299 | 8 | class C: |
paul@299 | 9 | def f(self): |
paul@299 | 10 | return 1 |
paul@299 | 11 | |
paul@299 | 12 | class D: |
paul@299 | 13 | def f(self): |
paul@299 | 14 | return 2 |
paul@299 | 15 | |
paul@299 | 16 | def g(self): |
paul@299 | 17 | return 3 |
paul@299 | 18 | |
paul@299 | 19 | class E: |
paul@299 | 20 | def f(self): |
paul@299 | 21 | return 4 |
paul@299 | 22 | |
paul@299 | 23 | def h(self): # unused |
paul@299 | 24 | return 5 |
paul@299 | 25 | |
paul@299 | 26 | def test_new(obj, obj2): |
paul@380 | 27 | # obj: f |
paul@310 | 28 | if obj.f(): |
paul@380 | 29 | obj = obj2 # obj: f, g |
paul@310 | 30 | obj.g() |
paul@310 | 31 | return obj.f() |
paul@299 | 32 | |
paul@299 | 33 | c = C() |
paul@299 | 34 | d = D() |
paul@299 | 35 | e = E() |
paul@299 | 36 | result2_2 = test_new(c, d) |
paul@299 | 37 | |
paul@299 | 38 | # vim: tabstop=4 expandtab shiftwidth=4 |