[pypy-svn] r9529 - in pypy/dist/pypy: annotation translator/test
pedronis at codespeak.net
pedronis at codespeak.net
Mon Feb 28 18:12:47 CET 2005
Author: pedronis
Date: Mon Feb 28 18:12:47 2005
New Revision: 9529
Modified:
pypy/dist/pypy/annotation/builtin.py
pypy/dist/pypy/translator/test/snippet.py
pypy/dist/pypy/translator/test/test_annrpython.py
Log:
annotation for zip
& bool
Modified: pypy/dist/pypy/annotation/builtin.py
==============================================================================
--- pypy/dist/pypy/annotation/builtin.py (original)
+++ pypy/dist/pypy/annotation/builtin.py Mon Feb 28 18:12:47 2005
@@ -147,6 +147,14 @@
factory.generalize(s_iter.next())
return factory.create()
+def builtin_zip(s_iterable1, s_iterable2):
+ factory = getbookkeeper().getfactory(ListFactory)
+ s_iter1 = s_iterable1.iter()
+ s_iter2 = s_iterable2.iter()
+ s_tup = SomeTuple((s_iter1.next(),s_iter2.next()))
+ factory.generalize(s_tup)
+ return factory.create()
+
def builtin_apply(*stuff):
print "XXX ignoring apply%r" % (stuff,)
return SomeObject()
@@ -174,6 +182,9 @@
def exception_init(s_self, *args):
s_self.setattr(immutablevalue('args'), SomeTuple(args))
+def builtin_bool(s_obj):
+ return SomeBool()
+
def count(s_obj):
return SomeInteger()
Modified: pypy/dist/pypy/translator/test/snippet.py
==============================================================================
--- pypy/dist/pypy/translator/test/snippet.py (original)
+++ pypy/dist/pypy/translator/test/snippet.py Mon Feb 28 18:12:47 2005
@@ -654,6 +654,9 @@
def simple_iter(x):
return iter(x)
+def simple_zip(x,y):
+ return zip(x,y)
+
def dict_copy(d):
return d.copy()
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 Mon Feb 28 18:12:47 2005
@@ -406,6 +406,17 @@
t = annmodel.SomeDict({}, annmodel.SomeInteger(), annmodel.SomeInteger())
s = a.build_types(snippet.simple_iter, [t])
assert isinstance(s, annmodel.SomeIterator)
+
+
+ def test_simple_zip(self):
+ a = RPythonAnnotator()
+ x = annmodel.SomeList({}, annmodel.SomeInteger())
+ y = annmodel.SomeList({}, annmodel.SomeString())
+ s = a.build_types(snippet.simple_zip, [x,y])
+ assert s.knowntype == list
+ assert s.s_item.knowntype == tuple
+ assert s.s_item.items[0].knowntype == int
+ assert s.s_item.items[1].knowntype == str
def test_dict_copy(self):
a = RPythonAnnotator()
More information about the Pypy-commit
mailing list