[pypy-svn] r66292 - in pypy/trunk/pypy/rlib/rsre: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Thu Jul 16 16:47:29 CEST 2009


Author: cfbolz
Date: Thu Jul 16 16:47:28 2009
New Revision: 66292

Modified:
   pypy/trunk/pypy/rlib/rsre/rsre.py
   pypy/trunk/pypy/rlib/rsre/test/test_rsre.py
Log:
Make rsre more generally useful (patch by Trundle, thanks a lot)


Modified: pypy/trunk/pypy/rlib/rsre/rsre.py
==============================================================================
--- pypy/trunk/pypy/rlib/rsre/rsre.py	(original)
+++ pypy/trunk/pypy/rlib/rsre/rsre.py	Thu Jul 16 16:47:28 2009
@@ -12,6 +12,7 @@
     rsre_core_filename = rsre_core_filename[:-1]
 rsre_core_filename = os.path.abspath(rsre_core_filename)
 del rsre_core
+from pypy.rlib.rsre.rsre_char import getlower
 
 def insert_sre_methods(locals, name):
     """A hack that inserts the SRE entry point methods into the 'locals'
@@ -58,3 +59,6 @@
 
     def get_char_ord(self, p):
         return ord(self.string[p])
+
+    def lower(self, char_ord):
+        return getlower(char_ord, 0)

Modified: pypy/trunk/pypy/rlib/rsre/test/test_rsre.py
==============================================================================
--- pypy/trunk/pypy/rlib/rsre/test/test_rsre.py	(original)
+++ pypy/trunk/pypy/rlib/rsre/test/test_rsre.py	Thu Jul 16 16:47:28 2009
@@ -80,6 +80,11 @@
 def test_getlower():
     assert rsre_char.getlower(ord("A"), 0) == ord("a")
 
+def test_SimpleStringState():
+    state = SimpleStringState("A", 0, -1)
+    assert state.get_char_ord(0) == ord("A")
+    assert state.lower(state.get_char_ord(0)) == ord("a")
+
 def test_get_byte_array():
     if sys.byteorder == "big":
         if rsre_char.CODESIZE == 2:



More information about the Pypy-commit mailing list