1.1 --- a/tests/attribute_access_type_restriction.py Fri Nov 06 01:07:48 2009 +0100
1.2 +++ b/tests/attribute_access_type_restriction.py Fri Nov 06 01:17:07 2009 +0100
1.3 @@ -11,34 +11,63 @@
1.4 def g(self):
1.5 return 3
1.6
1.7 +class E:
1.8 + def f(self):
1.9 + return 4
1.10 +
1.11 + def h(self):
1.12 + return 5
1.13 +
1.14 def test_one(obj):
1.15 - obj.f()
1.16 - return obj.g()
1.17 + obj.f() # C, D, E -> D
1.18 + return obj.g() # D
1.19 + # obj: D
1.20 +
1.21 +def test_two(obj, obj2):
1.22 + if obj.f(): # C, D, E (f)
1.23 + obj.g() # D (f, g)
1.24 + # else:
1.25 + # ... # obj: C, D, E (f)
1.26 + # # (f, g) ^ (f)
1.27 + return 2
1.28 + # obj: C, D, E (f)
1.29 +
1.30 +def test_new(obj, obj2):
1.31 + if obj.f(): # C, D, E (f)
1.32 + obj = obj2
1.33 + obj.g() # D (g)
1.34 + # else:
1.35 + # ... # obj: C, D, E (f)
1.36 + # # (g) ^ (f)
1.37 + return obj.f() # C, D, E (f)
1.38 + # obj: C, D, E (f)
1.39
1.40 def test_neither(obj, obj2):
1.41 - if obj.f():
1.42 - obj = obj2
1.43 - obj.g()
1.44 - return 2
1.45 + if 0:
1.46 + obj.g() # D (g)
1.47 + else:
1.48 + obj.f() # C, D, E (f)
1.49 + # # (g) ^ (f)
1.50 + return 4
1.51 + # obj:
1.52
1.53 -def test_either(obj, obj2):
1.54 - if obj:
1.55 +def test_three(obj, obj2):
1.56 + if obj.f(): # C, D, E (f)
1.57 obj = obj2
1.58 - obj.g()
1.59 - return obj.f()
1.60 -
1.61 -def test_neither2(obj, obj2):
1.62 - if obj:
1.63 - obj.g()
1.64 + obj.g() # D (g)
1.65 else:
1.66 - obj.f()
1.67 - return 4
1.68 + obj.h() # E (f, h)
1.69 + # # (g) ^ (f, h)
1.70 + return 5
1.71 + # obj:
1.72
1.73 c = C()
1.74 d = D()
1.75 +e = E()
1.76 result1_3 = test_one(d)
1.77 -result1_2 = test_neither(c, d)
1.78 -result2_2 = test_either(c, d)
1.79 -result1_4 = test_neither2(c, d)
1.80 +result1_2 = test_two(c, d)
1.81 +result2_2 = test_new(c, d)
1.82 +result1_4 = test_neither(c, d)
1.83 +result1_5 = test_three(e, d)
1.84
1.85 # vim: tabstop=4 expandtab shiftwidth=4