[pypy-svn] r8571 - in pypy/dist/pypy: annotation translator/test

adim at codespeak.net adim at codespeak.net
Tue Jan 25 16:04:37 CET 2005


Author: adim
Date: Tue Jan 25 16:04:37 2005
New Revision: 8571

Modified:
   pypy/dist/pypy/annotation/unaryop.py
   pypy/dist/pypy/translator/test/snippet.py
   pypy/dist/pypy/translator/test/test_annrpython.py
Log:
added SomeDict.items() operation (+ tests)


Modified: pypy/dist/pypy/annotation/unaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/unaryop.py	(original)
+++ pypy/dist/pypy/annotation/unaryop.py	Tue Jan 25 16:04:37 2005
@@ -128,6 +128,12 @@
         factory.generalize(dct.s_value)
         return factory.create()
 
+    def method_items(dct):
+        factory = getbookkeeper().getfactory(ListFactory)
+        factory.generalize(SomeTuple((dct.s_key, dct.s_value)))
+        return factory.create()
+        
+
         
 class __extend__(SomeString):
 

Modified: pypy/dist/pypy/translator/test/snippet.py
==============================================================================
--- pypy/dist/pypy/translator/test/snippet.py	(original)
+++ pypy/dist/pypy/translator/test/snippet.py	Tue Jan 25 16:04:37 2005
@@ -690,3 +690,7 @@
     d[1] = 12
     return values
 
+def dict_items():
+    d = {'a' : 1}
+    return d.items()
+

Modified: pypy/dist/pypy/translator/test/test_annrpython.py
==============================================================================
--- pypy/dist/pypy/translator/test/test_annrpython.py	(original)
+++ pypy/dist/pypy/translator/test/test_annrpython.py	Tue Jan 25 16:04:37 2005
@@ -453,7 +453,16 @@
         s = a.build_types(snippet.dict_values2, [])
         assert isinstance(s, annmodel.SomeList)
         assert not isinstance(s.s_item, annmodel.SomeString)
-    
+
+    def test_dict_items(self):
+        a = RPythonAnnotator()
+        s = a.build_types(snippet.dict_items, [])
+        assert isinstance(s, annmodel.SomeList)
+        assert isinstance(s.s_item, annmodel.SomeTuple)
+        s_key, s_value = s.s_item.items
+        assert isinstance(s_key, annmodel.SomeString)
+        assert isinstance(s_value, annmodel.SomeInteger)
+        
         
 
 def g(n):



More information about the Pypy-commit mailing list