Commit 3164f42f authored by Stefan Behnel's avatar Stefan Behnel

extended test case for unicode characters in switch statement

parent 2183cbca
...@@ -136,6 +136,8 @@ def m_unicode(Py_UNICODE a, unicode unicode_string): ...@@ -136,6 +136,8 @@ def m_unicode(Py_UNICODE a, unicode unicode_string):
1 1
>>> m_unicode(ord('X'), py_unicode_string) >>> m_unicode(ord('X'), py_unicode_string)
0 0
>>> m_unicode(ord(py_klingon_character), py_unicode_string)
1
>>> 'f' in None >>> 'f' in None
Traceback (most recent call last): Traceback (most recent call last):
TypeError: argument of type 'NoneType' is not iterable TypeError: argument of type 'NoneType' is not iterable
...@@ -146,6 +148,9 @@ def m_unicode(Py_UNICODE a, unicode unicode_string): ...@@ -146,6 +148,9 @@ def m_unicode(Py_UNICODE a, unicode unicode_string):
cdef int result = a in unicode_string cdef int result = a in unicode_string
return result return result
cdef unicode klingon_character = u'\uF8D2'
py_klingon_character = klingon_character
@cython.test_assert_path_exists("//SwitchStatNode") @cython.test_assert_path_exists("//SwitchStatNode")
@cython.test_fail_if_path_exists("//BoolBinopNode", "//PrimaryCmpNode") @cython.test_fail_if_path_exists("//BoolBinopNode", "//PrimaryCmpNode")
def m_unicode_literal(Py_UNICODE a): def m_unicode_literal(Py_UNICODE a):
...@@ -154,6 +159,8 @@ def m_unicode_literal(Py_UNICODE a): ...@@ -154,6 +159,8 @@ def m_unicode_literal(Py_UNICODE a):
1 1
>>> m_unicode_literal(ord('X')) >>> m_unicode_literal(ord('X'))
0 0
>>> m_unicode_literal(ord(py_klingon_character))
1
""" """
cdef int result = a in u'abcdefg\u1234\uF8D2' cdef int result = a in u'abcdefg\u1234\uF8D2'
return result return result
......
...@@ -121,15 +121,27 @@ def m_bytes_literal(char a): ...@@ -121,15 +121,27 @@ def m_bytes_literal(char a):
return result return result
cdef unicode unicode_string = u'abcdefg\u1234\uF8D2' 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_assert_path_exists("//PrimaryCmpNode")
@cython.test_fail_if_path_exists("//SwitchStatNode", "//BoolBinopNode") @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 0
>>> m_unicode(ord('X')) >>> m_unicode(ord('X'), py_unicode_string)
1 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 cdef int result = a not in unicode_string
return result return result
...@@ -142,6 +154,8 @@ def m_unicode_literal(Py_UNICODE a): ...@@ -142,6 +154,8 @@ def m_unicode_literal(Py_UNICODE a):
0 0
>>> m_unicode_literal(ord('X')) >>> m_unicode_literal(ord('X'))
1 1
>>> m_unicode_literal(ord(py_klingon_character))
0
""" """
cdef int result = a not in u'abcdefg\u1234\uF8D2' cdef int result = a not in u'abcdefg\u1234\uF8D2'
return result return result
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment