1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tests/attribute_access_type_restriction.py Mon Oct 26 00:26:07 2009 +0100
1.3 @@ -0,0 +1,44 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +class C:
1.7 + def f(self):
1.8 + return 1
1.9 +
1.10 +class D:
1.11 + def f(self):
1.12 + return 2
1.13 +
1.14 + def g(self):
1.15 + return 3
1.16 +
1.17 +def test_one(obj):
1.18 + obj.f()
1.19 + return obj.g()
1.20 +
1.21 +def test_neither(obj, obj2):
1.22 + if obj.f():
1.23 + obj = obj2
1.24 + obj.g()
1.25 + return 2
1.26 +
1.27 +def test_either(obj, obj2):
1.28 + if obj:
1.29 + obj = obj2
1.30 + obj.g()
1.31 + return obj.f()
1.32 +
1.33 +def test_neither2(obj, obj2):
1.34 + if obj:
1.35 + obj.g()
1.36 + else:
1.37 + obj.f()
1.38 + return 4
1.39 +
1.40 +c = C()
1.41 +d = D()
1.42 +result1_3 = test_one(d)
1.43 +result1_2 = test_neither(c, d)
1.44 +result2_2 = test_either(c, d)
1.45 +result1_4 = test_neither2(c, d)
1.46 +
1.47 +# vim: tabstop=4 expandtab shiftwidth=4