Cython has moved to github.

cython-devel

view tests/run/unicodeliterals.pyx @ 4256:b816b03ff502

Make __new__ -> __cinit__ into an error, fix compiler crash.
author Robert Bradshaw <robertwb@math.washington.edu>
date Tue Dec 21 02:09:22 2010 -0800 (3 years ago)
parents 856327d768f2
children
line source
1 # -*- coding: utf-8 -*-
3 import sys
5 __doc__ = br"""
6 >>> sa
7 'abc'
8 >>> ua
9 u'abc'
10 >>> b
11 u'123'
12 >>> c
13 u'S\xf8k ik'
14 >>> d
15 u'\xfc\xd6\xe4'
16 >>> e
17 u'\x03g\xf8\uf8d2S\xf8k ik'
18 >>> f
19 u'\xf8'
20 >>> add
21 u'S\xf8k ik\xfc\xd6\xe4abc'
22 >>> null
23 u'\x00'
24 """.decode("ASCII") + b"""
25 >>> len(sa)
26 3
27 >>> len(ua)
28 3
29 >>> len(b)
30 3
31 >>> len(c)
32 6
33 >>> len(d)
34 3
35 >>> len(e)
36 10
37 >>> len(f)
38 1
39 >>> len(add)
40 12
41 >>> len(null)
42 1
43 >>> sys.maxunicode >= 65535
44 True
45 >>> sys.maxunicode == 65535 and 1 or len(wide_literal) # test for wide build
46 1
47 >>> sys.maxunicode > 65535 and 2 or len(wide_literal) # test for narrow build
48 2
49 """.decode("ASCII") + u"""
50 >>> ua == u'abc'
51 True
52 >>> b == u'123'
53 True
54 >>> c == u'Søk ik'
55 True
56 >>> d == u'üÖä'
57 True
58 >>> e == u'\x03\x67\xf8\uf8d2Søk ik' # unescaped by Cython
59 True
60 >>> e == u'\\x03\\x67\\xf8\\uf8d2Søk ik' # unescaped by Python
61 True
62 >>> f == u'\xf8' # unescaped by Cython
63 True
64 >>> f == u'\\xf8' # unescaped by Python
65 True
66 >>> add == u'Søk ik' + u'üÖä' + 'abc'
67 True
68 >>> null == u'\\x00' # unescaped by Python (required by doctest)
69 True
70 >>> wide_literal == u'\\U00101234' # unescaped by Python
71 True
72 """
74 if sys.version_info >= (2,6,5):
75 # this doesn't work well in older Python versions
76 __doc__ += u"""\
77 >>> expected = u'\U00101234' # unescaped by Cython
78 >>> if wide_literal == expected: print(True)
79 ... else: print(repr(wide_literal), repr(expected), sys.maxunicode)
80 True
81 """
83 if sys.version_info[0] >= 3:
84 __doc__ = __doc__.replace(u" u'", u" '")
85 else:
86 __doc__ = __doc__.replace(u" b'", u" '")
88 sa = 'abc'
89 ua = u'abc'
91 b = u'123'
92 c = u'Søk ik'
93 d = u'üÖä'
94 e = u'\x03\x67\xf8\uf8d2Søk ik'
95 f = u'\xf8'
97 add = u'Søk ik' + u'üÖä' + u'abc'
98 null = u'\x00'
100 wide_literal = u'\U00101234'