Cython has moved to github.
cython-devel
view tests/run/unicodeliteralsdefault.pyx @ 1622:4f0327bdebc9
test for temp allocation bug in call
| author | Robert Bradshaw <robertwb@math.washington.edu> |
|---|---|
| date | Sat Jan 17 01:25:34 2009 -0800 (3 years ago) |
| parents | 95312b19ee49 |
| children | 24bd77ad030e |
line source
1 ## keep two lines free to make sure PEP 263 does not apply
2 ##
4 ##
6 # This file is written in UTF-8, but it has no encoding declaration,
7 # so it just defaults to UTF-8 (PEP 3120).
9 __doc__ = r"""
10 >>> sa
11 b'abc'
12 >>> ua
13 u'abc'
14 >>> b
15 u'123'
16 >>> c
17 u'S\xf8k ik'
18 >>> d
19 u'\xfc\xd6\xe4'
20 >>> e
21 u'\x03g\xf8\uf8d2S\xf8k ik'
22 >>> f
23 u'\xf8'
24 >>> add
25 u'S\xf8k ik\xfc\xd6\xe4abc'
26 >>> null
27 u'\x00'
28 """.decode(u"ASCII") + """
29 >>> len(sa)
30 3
31 >>> len(ua)
32 3
33 >>> len(b)
34 3
35 >>> len(c)
36 6
37 >>> len(d)
38 3
39 >>> len(e)
40 10
41 >>> len(f)
42 1
43 >>> len(add)
44 12
45 >>> len(null)
46 1
47 """.decode(u"ASCII") + u"""
48 >>> ua == u'abc'
49 True
50 >>> b == u'123'
51 True
52 >>> c == u'Søk ik'
53 True
54 >>> d == u'üÖä'
55 True
56 >>> e == u'\x03\x67\xf8\uf8d2Søk ik' # unescaped by Cython
57 True
58 >>> e == u'\\x03\\x67\\xf8\\uf8d2Søk ik' # unescaped by Python
59 True
60 >>> f == u'\xf8' # unescaped by Cython
61 True
62 >>> f == u'\\xf8' # unescaped by Python
63 True
64 >>> add == u'Søk ik' + u'üÖä' + 'abc'
65 True
66 >>> null == u'\\x00' # unescaped by Python (required by doctest)
67 True
68 """
70 import sys
71 if sys.version_info[0] >= 3:
72 __doc__ = __doc__.replace(u" u'", u" '")
73 else:
74 __doc__ = __doc__.replace(u" b'", u" '")
76 sa = 'abc'
77 ua = u'abc'
79 b = u'123'
80 c = u'Søk ik'
81 d = u'üÖä'
82 e = u'\x03\x67\xf8\uf8d2Søk ik'
83 f = u'\xf8'
85 add = u'Søk ik' + u'üÖä' + u'abc'
86 null = u'\x00'
