Commits

Jeremy Thurgood committed 5671340

Proper tests and some oothingies.

Comments (0)

Files changed (2)

rpython/rtyper/ootypesystem/rstr.py

 
 
 class StringIteratorRepr(AbstractStringIteratorRepr):
+    external_item_repr = char_repr
     lowleveltype = ootype.Record({'string': string_repr.lowleveltype,
                                   'index': ootype.Signed})
 
     def __init__(self):
         self.ll_striter = ll_striter
         self.ll_strnext = ll_strnext
+        self.ll_getnextindex = ll_getnextindex
 
 class UnicodeIteratorRepr(AbstractStringIteratorRepr):
+    external_item_repr = unichar_repr
     lowleveltype = ootype.Record({'string': unicode_repr.lowleveltype,
                                   'index': ootype.Signed})
 
     iter.index = index + 1
     return string.ll_stritem_nonneg(index)
 
+def ll_getnextindex(iter):
+    return iter.index
+
 
 StringRepr.string_iterator_repr = StringIteratorRepr()
 UnicodeRepr.string_iterator_repr = UnicodeIteratorRepr()

rpython/rtyper/test/test_rstr.py

         got = self.interpret(f, [7])
         assert self.ll_to_string(got) == 'None'
 
+    def test_enumerate(self):
+        const = self.const
+        def fn(n):
+            s = const('abcde')
+            for i, x in enumerate(s):
+                if i == n:
+                    return x
+            return 'x'
+        res = self.interpret(fn, [2])
+        assert res == 'c'
+
 
 def FIXME_test_str_to_pystringobj():
     def f(n):