1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tests/attribute_access_type_restriction_loop_accumulation.py Thu Feb 25 01:22:21 2010 +0100
1.3 @@ -0,0 +1,44 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +"""
1.7 +This test illustrates the need for usage to be propagated forward to the
1.8 +assignment within the loop.
1.9 +"""
1.10 +
1.11 +class C:
1.12 + def e(self): # unused
1.13 + return 1
1.14 +
1.15 + def f(self):
1.16 + return 1
1.17 +
1.18 +class D:
1.19 + def f(self):
1.20 + return 2
1.21 +
1.22 + def g(self):
1.23 + return 3
1.24 +
1.25 +class E:
1.26 + def e(self):
1.27 + return 4
1.28 +
1.29 + def f(self):
1.30 + return 0 # stops the test loop
1.31 +
1.32 + def g(self):
1.33 + return 5
1.34 +
1.35 +def test_loop(obj, obj2):
1.36 + while obj.f():
1.37 + obj.g()
1.38 + obj = obj2 # should support e, f, g
1.39 + obj.e()
1.40 + return obj.f()
1.41 +
1.42 +c = C()
1.43 +d = D()
1.44 +e = E()
1.45 +result1_0 = test_loop(d, e)
1.46 +
1.47 +# vim: tabstop=4 expandtab shiftwidth=4