# HG changeset patch # User Paul Boddie # Date 1256513167 -3600 # Node ID 9f3f7c6148d8d564c34a88e4710576259350da3c # Parent 066ed6e92f1e57df820464d08ba944029d574ff0 Added a test of attribute usage optimisation. Renamed a failure example. diff -r 066ed6e92f1e -r 9f3f7c6148d8 tests/attribute_access_type_restriction.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/attribute_access_type_restriction.py Mon Oct 26 00:26:07 2009 +0100 @@ -0,0 +1,44 @@ +#!/usr/bin/env python + +class C: + def f(self): + return 1 + +class D: + def f(self): + return 2 + + def g(self): + return 3 + +def test_one(obj): + obj.f() + return obj.g() + +def test_neither(obj, obj2): + if obj.f(): + obj = obj2 + obj.g() + return 2 + +def test_either(obj, obj2): + if obj: + obj = obj2 + obj.g() + return obj.f() + +def test_neither2(obj, obj2): + if obj: + obj.g() + else: + obj.f() + return 4 + +c = C() +d = D() +result1_3 = test_one(d) +result1_2 = test_neither(c, d) +result2_2 = test_either(c, d) +result1_4 = test_neither2(c, d) + +# vim: tabstop=4 expandtab shiftwidth=4 diff -r 066ed6e92f1e -r 9f3f7c6148d8 tests/failure/instance.py --- a/tests/failure/instance.py Mon Oct 26 00:23:36 2009 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -#!/usr/bin/env python - -class C: - pass - -class D: - def __init__(self): - pass - -class E: - def __init__(self, x): - pass - -c = C() -d = D() -e = E() - -# vim: tabstop=4 expandtab shiftwidth=4 diff -r 066ed6e92f1e -r 9f3f7c6148d8 tests/failure/instance_initialisation_incomplete.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/failure/instance_initialisation_incomplete.py Mon Oct 26 00:26:07 2009 +0100 @@ -0,0 +1,18 @@ +#!/usr/bin/env python + +class C: + pass + +class D: + def __init__(self): + pass + +class E: + def __init__(self, x): + pass + +c = C() +d = D() +e = E() + +# vim: tabstop=4 expandtab shiftwidth=4