[pypy-svn] r26738 - in pypy/dist/pypy/translator/cl: . test

dialtone at codespeak.net dialtone at codespeak.net
Wed May 3 21:37:57 CEST 2006


Author: dialtone
Date: Wed May  3 21:37:35 2006
New Revision: 26738

Modified:
   pypy/dist/pypy/translator/cl/opformatter.py
   pypy/dist/pypy/translator/cl/test/test_dict.py
Log:
add stubs for DictItemsIteratorImpl, add a failing dict_iter test

Modified: pypy/dist/pypy/translator/cl/opformatter.py
==============================================================================
--- pypy/dist/pypy/translator/cl/opformatter.py	(original)
+++ pypy/dist/pypy/translator/cl/opformatter.py	Wed May  3 21:37:35 2006
@@ -1,4 +1,5 @@
 from pypy.rpython.ootypesystem.ootype import List, Dict, Record, Instance
+from pypy.rpython.ootypesystem.ootype import DictItemsIterator
 from pypy.translator.cl.clrepr import clrepr
 
 class OpFormatter:
@@ -117,6 +118,10 @@
             impl = DictImpl(selfvar)
             code = getattr(impl, method)(*args)
             yield "(setf %s %s)" % (result, code)
+        elif isinstance(cls, DictItemsIterator):
+            impl = DictItemsIteratorImpl(selfvar)
+            code = getattr(impl, method)(*args)
+            yield "(setf %s %s)" % (result, code)
         elif isinstance(cls, Instance):
             name = clrepr(method, symbol=True)
             funcall = " ".join((name, selfvar) + args)
@@ -193,3 +198,18 @@
 
     def ll_set(self, key, value):
         return "(setf (gethash %s %s) %s)" % (key, self.obj, value)
+
+    def ll_get_items_iterator(self):
+        raise NotImplementedError()
+
+class DictItemsIteratorImpl:
+
+    def __init__(self, obj):
+        self.obj = obj
+
+    def ll_go_next(self):
+        raise NotImplementedError()
+
+    def ll_current_key(self):
+        raise NotImplementedError()
+

Modified: pypy/dist/pypy/translator/cl/test/test_dict.py
==============================================================================
--- pypy/dist/pypy/translator/cl/test/test_dict.py	(original)
+++ pypy/dist/pypy/translator/cl/test/test_dict.py	Wed May  3 21:37:35 2006
@@ -13,3 +13,14 @@
         return dic[number]
     cl_dict_get = make_cl_func(dict_get, [int])
     assert cl_dict_get(42) == 43
+
+def test_dict_iter():
+    py.test.skip("not supported yet")
+    def dict_iter():
+        dic = {1:2, 3:4, 5:6}
+        i = 0
+        for key in dic:
+            i = i + dic[key]
+        return i
+    cl_dict_iter = make_cl_func(dict_iter, [])
+    assert cl_dict_iter() == 12
\ No newline at end of file



More information about the Pypy-commit mailing list