[pypy-svn] r25966 - pypy/dist/pypy/translator/c/test

pedronis at codespeak.net pedronis at codespeak.net
Wed Apr 19 01:16:26 CEST 2006


Author: pedronis
Date: Wed Apr 19 01:16:25 2006
New Revision: 25966

Modified:
   pypy/dist/pypy/translator/c/test/test_typed.py
Log:
forgot to check in these genc level tests in the last checkin, about exception propagation out of r_dict ops.



Modified: pypy/dist/pypy/translator/c/test/test_typed.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_typed.py	(original)
+++ pypy/dist/pypy/translator/c/test/test_typed.py	Wed Apr 19 01:16:25 2006
@@ -722,3 +722,48 @@
         fn = self.getcompiled(g)
         assert fn(0) == 1
         assert fn(1) == 42
+
+    def test_r_dict_exceptions(self):
+        from pypy.rpython.objectmodel import r_dict
+        
+        def raising_hash(obj):
+            if obj.startswith("bla"):
+                raise TypeError
+            return 1
+        def eq(obj1, obj2):
+            return obj1 is obj2
+        def f():
+            d1 = r_dict(eq, raising_hash)
+            d1['xxx'] = 1
+            try:
+                x = d1["blabla"]
+            except Exception:
+                return 42
+            return x
+        fn = self.getcompiled(f)    
+        res = fn()
+        assert res == 42
+
+        def f():
+            d1 = r_dict(eq, raising_hash)
+            d1['xxx'] = 1
+            try:
+                x = d1["blabla"]
+            except TypeError:
+                return 42
+            return x
+        fn = self.getcompiled(f)    
+        res = fn()
+        assert res == 42    
+
+        def f():
+            d1 = r_dict(eq, raising_hash)
+            d1['xxx'] = 1
+            try:
+                d1["blabla"] = 2
+            except TypeError:
+                return 42
+            return 0
+        fn = self.getcompiled(f)    
+        res = fn()
+        assert res == 42    



More information about the Pypy-commit mailing list