def test_getupper_getlower_unicode_ascii_shortcut(): from rpython.rlib.unicodedata import unicodedb try: rsre_char.set_unicode_db(None) for i in range(128): # works despite not having a unicode db rsre_char.getlower(i, SRE_FLAG_UNICODE) rsre_char.getupper(i, SRE_FLAG_UNICODE) finally: rsre_char.set_unicode_db(unicodedb)
def test_getlower(): assert rsre_char.getlower(ord('A'), 0) == ord('a') assert rsre_char.getlower(ord('2'), 0) == ord('2') assert rsre_char.getlower(10, 0) == 10 assert rsre_char.getlower(UPPER_PI, 0) == UPPER_PI # assert rsre_char.getlower(ord('A'), SRE_FLAG_UNICODE) == ord('a') assert rsre_char.getlower(ord('2'), SRE_FLAG_UNICODE) == ord('2') assert rsre_char.getlower(10, SRE_FLAG_UNICODE) == 10 assert rsre_char.getlower(UPPER_PI, SRE_FLAG_UNICODE) == LOWER_PI # # xxx the following cases are like CPython's. They are obscure. # (iko) that's a nice way to say "broken" assert rsre_char.getlower(UPPER_PI, SRE_FLAG_LOCALE) == UPPER_PI assert rsre_char.getlower(UPPER_PI, SRE_FLAG_LOCALE | SRE_FLAG_UNICODE) \ == UPPER_PI
def lowstr(self, index): c = self.str(index) return rsre_char.getlower(c, self.flags)
def w_getlower(space, char_ord, flags): return space.newint(getlower(char_ord, flags))
def w_getlower(space, char_ord, flags): return space.wrap(getlower(char_ord, flags))