From: Stefan Behnel Date: Wed, 21 Apr 2010 12:01:11 +0000 (+0200) Subject: extended test case for unicode characters in switch statement X-Git-Tag: 0.13.beta0~172 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3164f42f47a01db7af901211883bd599d4061f5c;p=cython.git extended test case for unicode characters in switch statement --- diff --git a/tests/run/inop.pyx b/tests/run/inop.pyx index 97cd7009..846ee905 100644 --- a/tests/run/inop.pyx +++ b/tests/run/inop.pyx @@ -136,6 +136,8 @@ def m_unicode(Py_UNICODE a, unicode unicode_string): 1 >>> m_unicode(ord('X'), py_unicode_string) 0 + >>> m_unicode(ord(py_klingon_character), py_unicode_string) + 1 >>> 'f' in None Traceback (most recent call last): TypeError: argument of type 'NoneType' is not iterable @@ -146,6 +148,9 @@ def m_unicode(Py_UNICODE a, unicode unicode_string): cdef int result = a in unicode_string return result +cdef unicode klingon_character = u'\uF8D2' +py_klingon_character = klingon_character + @cython.test_assert_path_exists("//SwitchStatNode") @cython.test_fail_if_path_exists("//BoolBinopNode", "//PrimaryCmpNode") def m_unicode_literal(Py_UNICODE a): @@ -154,6 +159,8 @@ def m_unicode_literal(Py_UNICODE a): 1 >>> m_unicode_literal(ord('X')) 0 + >>> m_unicode_literal(ord(py_klingon_character)) + 1 """ cdef int result = a in u'abcdefg\u1234\uF8D2' return result diff --git a/tests/run/notinop.pyx b/tests/run/notinop.pyx index bb3a343e..2ec632fb 100644 --- a/tests/run/notinop.pyx +++ b/tests/run/notinop.pyx @@ -121,15 +121,27 @@ def m_bytes_literal(char a): return result cdef unicode unicode_string = u'abcdefg\u1234\uF8D2' +py_unicode_string = unicode_string + +cdef unicode klingon_character = u'\uF8D2' +py_klingon_character = klingon_character @cython.test_assert_path_exists("//PrimaryCmpNode") @cython.test_fail_if_path_exists("//SwitchStatNode", "//BoolBinopNode") -def m_unicode(Py_UNICODE a): +def m_unicode(Py_UNICODE a, unicode unicode_string): """ - >>> m_unicode(ord('f')) + >>> m_unicode(ord('f'), py_unicode_string) 0 - >>> m_unicode(ord('X')) + >>> m_unicode(ord('X'), py_unicode_string) 1 + >>> m_unicode(ord(py_klingon_character), py_unicode_string) + 0 + >>> 'f' in None + Traceback (most recent call last): + TypeError: argument of type 'NoneType' is not iterable + >>> m_unicode(ord('f'), None) + Traceback (most recent call last): + TypeError: argument of type 'NoneType' is not iterable """ cdef int result = a not in unicode_string return result @@ -142,6 +154,8 @@ def m_unicode_literal(Py_UNICODE a): 0 >>> m_unicode_literal(ord('X')) 1 + >>> m_unicode_literal(ord(py_klingon_character)) + 0 """ cdef int result = a not in u'abcdefg\u1234\uF8D2' return result