add constant folding test for sliced unicode and bytes literals
authorStefan Behnel <stefan_ml@behnel.de>
Sat, 23 Feb 2013 13:14:04 +0000 (14:14 +0100)
committerStefan Behnel <stefan_ml@behnel.de>
Sat, 23 Feb 2013 13:14:04 +0000 (14:14 +0100)
tests/run/constant_folding_cy.pyx [new file with mode: 0644]

diff --git a/tests/run/constant_folding_cy.pyx b/tests/run/constant_folding_cy.pyx
new file mode 100644 (file)
index 0000000..7c9e35c
--- /dev/null
@@ -0,0 +1,55 @@
+# coding=utf8
+# mode: run
+# tag: constant_folding
+
+cimport cython
+
+
+bstring = b'abc\xE9def'
+ustring = u'abc\xE9def'
+
+
+@cython.test_fail_if_path_exists(
+    "//SliceIndexNode",
+    )
+def bytes_slicing2():
+    """
+    >>> a,b,c,d = bytes_slicing2()
+    >>> a == bstring[:]
+    True
+    >>> b == bstring[2:]
+    True
+    >>> c == bstring[:4]
+    True
+    >>> d == bstring[2:4]
+    True
+    """
+    str0 = b'abc\xE9def'[:]
+    str1 = b'abc\xE9def'[2:]
+    str2 = b'abc\xE9def'[:4]
+    str3 = b'abc\xE9def'[2:4]
+
+    return str0, str1, str2, str3
+
+
+@cython.test_fail_if_path_exists(
+    "//SliceIndexNode",
+    )
+def unicode_slicing2():
+    """
+    >>> a,b,c,d = unicode_slicing2()
+    >>> a == ustring[:]
+    True
+    >>> b == ustring[2:]
+    True
+    >>> c == ustring[:4]
+    True
+    >>> d == ustring[2:4]
+    True
+    """
+    str0 = u'abc\xE9def'[:]
+    str1 = u'abc\xE9def'[2:]
+    str2 = u'abc\xE9def'[:4]
+    str3 = u'abc\xE9def'[2:4]
+
+    return str0, str1, str2, str3