[pypy-svn] r74028 - in pypy/branch/rpython-iterator/pypy/rlib: . test
fijal at codespeak.net
fijal at codespeak.net
Fri Apr 23 19:11:23 CEST 2010
Author: fijal
Date: Fri Apr 23 19:11:22 2010
New Revision: 74028
Added:
pypy/branch/rpython-iterator/pypy/rlib/r_iter.py (contents, props changed)
pypy/branch/rpython-iterator/pypy/rlib/test/test_r_iter.py (contents, props changed)
Log:
misssing files
Added: pypy/branch/rpython-iterator/pypy/rlib/r_iter.py
==============================================================================
--- (empty file)
+++ pypy/branch/rpython-iterator/pypy/rlib/r_iter.py Fri Apr 23 19:11:22 2010
@@ -0,0 +1,24 @@
+
+from pypy.rpython.extregistry import ExtRegistryEntry
+
+class r_iter(object):
+ def next(self):
+ raise NotImplementedError("abstract base class")
+
+class list_iter(object):
+ def __init__(self, l):
+ self.l = l
+ self.pos = 0
+
+ def next(self):
+ if self.pos >= len(self.l):
+ raise StopIteration
+ res = self.l[self.pos]
+ self.pos += 1
+ return res
+
+ def __iter__(self):
+ """ NOT_RPYTHON, for untranslated version only
+ """
+ return self
+
Added: pypy/branch/rpython-iterator/pypy/rlib/test/test_r_iter.py
==============================================================================
--- (empty file)
+++ pypy/branch/rpython-iterator/pypy/rlib/test/test_r_iter.py Fri Apr 23 19:11:22 2010
@@ -0,0 +1,19 @@
+
+from pypy.rpython.test.tool import BaseRtypingTest, LLRtypeMixin
+from pypy.rlib.r_iter import list_iter
+
+class AbstractRIterTest(BaseRtypingTest):
+ def test_basic(self):
+ def f():
+ l = [1, 2, 3, 4, 5]
+ a = []
+ for i in list_iter(l):
+ a.append(i)
+ return len(a)
+
+ assert f() == 5
+ res = self.interpret(f, [])
+ assert res == 5
+
+class TestRType(AbstractRIterTest, LLRtypeMixin):
+ pass
More information about the Pypy-commit
mailing list