1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tests/attribute_access_type_restriction_single_instance.py Sun Feb 07 02:02:15 2010 +0100
1.3 @@ -0,0 +1,36 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +"""
1.7 +This test attempts to guard 'obj' in 'test_one' with only an instance check for
1.8 +D instances. In the process, the unused methods should be discarded.
1.9 +"""
1.10 +
1.11 +class C:
1.12 + def f(self): # unused
1.13 + return 1
1.14 +
1.15 +class D:
1.16 + def f(self):
1.17 + return 2
1.18 +
1.19 + def __init__(self, g):
1.20 + self.g = g
1.21 +
1.22 +class E:
1.23 + def f(self): # unused
1.24 + return 4
1.25 +
1.26 + def h(self): # unused
1.27 + return 5
1.28 +
1.29 +def test_one(obj):
1.30 + # obj: D (f, g)
1.31 + obj.f() # C, D, E (f)
1.32 + return obj.g # D (f, g) - instance only
1.33 +
1.34 +c = C()
1.35 +d = D(4)
1.36 +e = E()
1.37 +result1_4 = test_one(d)
1.38 +
1.39 +# vim: tabstop=4 expandtab shiftwidth=4