cdef int result = a in {1,2,3,4}
return result
-cdef bytes bytes_string = b'abcdefg'
+cdef bytes bytes_string = b'ab\0cde\0f\0g'
py_bytes_string = bytes_string
@cython.test_assert_path_exists("//PrimaryCmpNode")
>>> m_bytes_literal(ord('X'))
0
"""
- cdef int result = a in b'abcdefg'
+ cdef int result = a in b'ab\0cde\0f\0g'
return result
-cdef unicode unicode_string = u'abcdefg\u1234\uF8D2'
+cdef unicode unicode_string = u'abc\0defg\u1234\uF8D2'
py_unicode_string = unicode_string
@cython.test_assert_path_exists("//PrimaryCmpNode")
>>> m_unicode_literal(ord(py_klingon_character))
1
"""
- cdef int result = a in u'abcdefg\u1234\uF8D2'
+ cdef int result = a in u'abc\0defg\u1234\uF8D2'
return result
@cython.test_assert_path_exists("//SwitchStatNode")
"""
return 1 if a in (1,2,3,4) else '2'
+@cython.test_assert_path_exists("//SwitchStatNode")
+@cython.test_fail_if_path_exists("//BoolBinopNode", "//PrimaryCmpNode")
+def conditional_bytes(char a):
+ """
+ >>> conditional_bytes(ord('a'))
+ 1
+ >>> conditional_bytes(ord('X'))
+ '2'
+ >>> conditional_bytes(0)
+ '2'
+ """
+ return 1 if a in b'abc' else '2'
+
+@cython.test_assert_path_exists("//SwitchStatNode")
+@cython.test_fail_if_path_exists("//BoolBinopNode", "//PrimaryCmpNode")
+def conditional_unicode(Py_UNICODE a):
+ """
+ >>> conditional_unicode(ord('a'))
+ 1
+ >>> conditional_unicode(ord('X'))
+ '2'
+ >>> conditional_unicode(0)
+ '2'
+ """
+ return 1 if a in u'abc' else '2'
+
@cython.test_assert_path_exists("//SwitchStatNode")
@cython.test_fail_if_path_exists("//BoolBinopNode", "//PrimaryCmpNode")
def conditional_none(int a):
"""
return 1 if a not in (1,2,3,4) else '2'
+@cython.test_assert_path_exists("//SwitchStatNode")
+@cython.test_fail_if_path_exists("//BoolBinopNode", "//PrimaryCmpNode")
+def conditional_bytes(char a):
+ """
+ >>> conditional_bytes(ord('a'))
+ '2'
+ >>> conditional_bytes(ord('X'))
+ 1
+ >>> conditional_bytes(0)
+ 1
+ """
+ return 1 if a not in b'abc' else '2'
+
+@cython.test_assert_path_exists("//SwitchStatNode")
+@cython.test_fail_if_path_exists("//BoolBinopNode", "//PrimaryCmpNode")
+def conditional_unicode(Py_UNICODE a):
+ """
+ >>> conditional_unicode(ord('a'))
+ '2'
+ >>> conditional_unicode(ord('X'))
+ 1
+ >>> conditional_unicode(0)
+ 1
+ """
+ return 1 if a not in u'abc' else '2'
+
@cython.test_assert_path_exists("//SwitchStatNode")
@cython.test_fail_if_path_exists("//BoolBinopNode", "//PrimaryCmpNode")
def conditional_none(int a):