2013-01-13 | Paul Boddie | file changeset files shortlog | Added some support for classes defined using the same name in the same namespace. |
paul@310 | 1 | #!/usr/bin/env python |
paul@310 | 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@310 | 8 | class C: |
paul@310 | 9 | def f(self): |
paul@310 | 10 | return 1 |
paul@310 | 11 | |
paul@310 | 12 | class D: |
paul@310 | 13 | def f(self): |
paul@310 | 14 | return 2 |
paul@310 | 15 | |
paul@310 | 16 | def g(self): |
paul@310 | 17 | return 3 |
paul@310 | 18 | |
paul@310 | 19 | class E: |
paul@310 | 20 | def f(self): |
paul@310 | 21 | return 4 |
paul@310 | 22 | |
paul@310 | 23 | def h(self): # unused |
paul@310 | 24 | return 5 |
paul@310 | 25 | |
paul@310 | 26 | def test_new(obj, obj2, obj3): |
paul@310 | 27 | # obj should support f |
paul@310 | 28 | if obj.f(): |
paul@310 | 29 | obj = obj2 # should support f, g |
paul@310 | 30 | obj.g() |
paul@310 | 31 | else: |
paul@310 | 32 | obj = obj3 # should support f, g |
paul@310 | 33 | obj.g() |
paul@310 | 34 | return obj.f() |
paul@310 | 35 | |
paul@310 | 36 | c = C() |
paul@310 | 37 | d = D() |
paul@310 | 38 | e = E() |
paul@310 | 39 | result2_2 = test_new(c, d, d) |
paul@310 | 40 | |
paul@310 | 41 | # vim: tabstop=4 expandtab shiftwidth=4 |