1.1 --- a/tests/attribute_access_type_restriction.py Tue Oct 27 00:23:28 2009 +0100
1.2 +++ b/tests/attribute_access_type_restriction.py Mon Nov 02 01:06:38 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_neither(obj, obj2):
1.22 - if obj.f():
1.23 +def test_two(obj, obj2):
1.24 + if obj.f(): # C, D, E (f)
1.25 + obj.g() # D (f, g)
1.26 + # else:
1.27 + # ... # obj: C, D, E (f)
1.28 + # # (f, g) ^ (f)
1.29 + return 2
1.30 + # obj: C, D, E (f)
1.31 +
1.32 +def test_new(obj, obj2):
1.33 + if obj.f(): # C, D, E (f)
1.34 obj = obj2
1.35 - obj.g()
1.36 - return 2
1.37 -
1.38 -def test_either(obj, obj2):
1.39 - if obj:
1.40 - obj = obj2
1.41 - obj.g()
1.42 - return obj.f()
1.43 + obj.g() # D (g)
1.44 + # else:
1.45 + # ... # obj: C, D, E (f)
1.46 + # # (g) ^ (f)
1.47 + return obj.f() # C, D, E (f)
1.48 + # obj: C, D, E (f)
1.49
1.50 def test_neither2(obj, obj2):
1.51 - if obj:
1.52 - obj.g()
1.53 + if 0:
1.54 + obj.g() # D (g)
1.55 else:
1.56 - obj.f()
1.57 + obj.f() # C, D, E (f)
1.58 + # # (g) ^ (f)
1.59 return 4
1.60 + # obj:
1.61 +
1.62 +def test_three(obj, obj2):
1.63 + if obj.f(): # C, D, E (f)
1.64 + obj = obj2
1.65 + obj.g() # D (g)
1.66 + else:
1.67 + obj.h() # E (f, h)
1.68 + # # (g) ^ (f, h)
1.69 + return 5
1.70 + # obj:
1.71
1.72 c = C()
1.73 d = D()
1.74 +e = E()
1.75 result1_3 = test_one(d)
1.76 -result1_2 = test_neither(c, d)
1.77 -result2_2 = test_either(c, d)
1.78 +result1_2 = test_two(c, d)
1.79 +result2_2 = test_new(c, d)
1.80 result1_4 = test_neither2(c, d)
1.81 +result1_5 = test_three(e, d)
1.82
1.83 # vim: tabstop=4 expandtab shiftwidth=4