From d1cc779e34d02159a7bab08224a5fba2078d6994 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Sat, 23 Feb 2013 14:14:04 +0100 Subject: [PATCH] add constant folding test for sliced unicode and bytes literals --- tests/run/constant_folding_cy.pyx | 55 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/run/constant_folding_cy.pyx diff --git a/tests/run/constant_folding_cy.pyx b/tests/run/constant_folding_cy.pyx new file mode 100644 index 0000000..7c9e35c --- /dev/null +++ b/tests/run/constant_folding_cy.pyx @@ -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 -- 2.7.4