2012-05-10 | Paul Boddie | file changeset files shortlog | Changed the builtins module loading to use the module search path. This makes it easier to run the test program from another location. Added a note about relative imports. |
paul@318 | 1 | #!/usr/bin/env python |
paul@318 | 2 | |
paul@318 | 3 | class C: |
paul@318 | 4 | def f(self): |
paul@318 | 5 | return 1 |
paul@318 | 6 | |
paul@318 | 7 | class D: |
paul@318 | 8 | def f(self): |
paul@318 | 9 | return 2 |
paul@318 | 10 | |
paul@318 | 11 | def g(self): # unused |
paul@318 | 12 | return 3 |
paul@318 | 13 | |
paul@318 | 14 | class E: |
paul@318 | 15 | def f(self): |
paul@318 | 16 | return 4 |
paul@318 | 17 | |
paul@318 | 18 | def h(self): |
paul@318 | 19 | return 5 |
paul@318 | 20 | |
paul@318 | 21 | def test_new(obj): |
paul@318 | 22 | # obj: C, D, E (f) |
paul@318 | 23 | if obj.f(): # C, D, E (f) |
paul@318 | 24 | obj2 = D() # obj2: E (h) -> conflict! |
paul@318 | 25 | obj2.h() # E (h) |
paul@318 | 26 | # else: |
paul@318 | 27 | # ... # obj: C, D, E (f) |
paul@318 | 28 | # # (f) ^ (f) |
paul@318 | 29 | return obj.f() # C, D, E (f) |
paul@318 | 30 | |
paul@318 | 31 | c = C() |
paul@318 | 32 | d = D() |
paul@318 | 33 | e = E() |
paul@318 | 34 | result2_2 = test_new(c) |
paul@318 | 35 | |
paul@318 | 36 | # vim: tabstop=4 expandtab shiftwidth=4 |