2013-01-14 | Paul Boddie | file changeset files shortlog | Moved common logic into a separate method. |
paul@269 | 1 | #!/usr/bin/env python |
paul@269 | 2 | |
paul@269 | 3 | class C: |
paul@269 | 4 | def f(self): |
paul@269 | 5 | return 1 |
paul@269 | 6 | |
paul@269 | 7 | class D: |
paul@269 | 8 | def f(self): |
paul@269 | 9 | return 2 |
paul@269 | 10 | |
paul@269 | 11 | def g(self): |
paul@269 | 12 | return 3 |
paul@269 | 13 | |
paul@275 | 14 | class E: |
paul@275 | 15 | def f(self): |
paul@275 | 16 | return 4 |
paul@275 | 17 | |
paul@275 | 18 | def h(self): |
paul@275 | 19 | return 5 |
paul@275 | 20 | |
paul@279 | 21 | def test_new_conditional(obj, obj2): |
paul@380 | 22 | # obj: f; f, h |
paul@380 | 23 | if obj.f(): |
paul@380 | 24 | obj = obj2 # obj: g |
paul@380 | 25 | obj.g() |
paul@275 | 26 | else: |
paul@380 | 27 | obj.h() |
paul@380 | 28 | |
paul@275 | 29 | return 5 |
paul@269 | 30 | |
paul@269 | 31 | c = C() |
paul@269 | 32 | d = D() |
paul@275 | 33 | e = E() |
paul@279 | 34 | result1_5 = test_new_conditional(e, d) |
paul@269 | 35 | |
paul@269 | 36 | # vim: tabstop=4 expandtab shiftwidth=4 |