[pypy-svn] r26470 - pypy/dist/pypy/translator/cl/test

sanxiyn at codespeak.net sanxiyn at codespeak.net
Fri Apr 28 02:48:43 CEST 2006


Author: sanxiyn
Date: Fri Apr 28 02:48:38 2006
New Revision: 26470

Modified:
   pypy/dist/pypy/translator/cl/test/test_oo.py
Log:
Add a test failing with null instance


Modified: pypy/dist/pypy/translator/cl/test/test_oo.py
==============================================================================
--- pypy/dist/pypy/translator/cl/test/test_oo.py	(original)
+++ pypy/dist/pypy/translator/cl/test/test_oo.py	Fri Apr 28 02:48:38 2006
@@ -112,3 +112,22 @@
     cl_dynamic_instance = make_cl_func(dynamic_instance, [bool])
     assert cl_dynamic_instance(True) == 1
     assert cl_dynamic_instance(False) == 2
+
+def test_nullable():
+    py.test.skip("fails with null inst")
+    class Foo:
+        def __init__(self, value):
+            self.value = value
+    def maybe_foo(flag):
+        if flag:
+            return Foo(1)
+        else:
+            return None
+    def maybe_one(flag):
+        obj = maybe_foo(flag)
+        if obj is None:
+            obj = Foo(2)
+        return obj.value
+    cl_maybe_one = make_cl_func(maybe_one, [bool])
+    assert cl_maybe_one(True) == 1
+    assert cl_maybe_one(False) == 2



More information about the Pypy-commit mailing list