Cython has moved to github.
cython-devel
view tests/run/str_char_coercion_T412.pyx @ 2507:8d8cc4c9b91b
fix bug 412: str char comparison, refactoring to move comparison coercions closer in the code
| author | Stefan Behnel <scoder@users.berlios.de> |
|---|---|
| date | Sat Oct 17 22:34:28 2009 +0200 (2 years ago) |
| parents | |
| children | 82d312a9f1fc |
line source
1 __doc__ = u"""
2 >>> test_eq()
3 True
4 True
5 True
6 True
8 >>> test_cascaded_eq()
9 True
10 True
11 True
12 True
13 True
14 True
15 True
16 True
18 >>> test_cascaded_ineq()
19 True
20 True
21 True
22 True
23 True
24 True
25 True
26 True
28 >>> test_long_ineq()
29 True
31 >>> test_long_ineq_py()
32 True
33 True
34 """
36 cdef int i = 'x'
37 cdef char c = 'x'
38 cdef char* s = 'x'
40 def test_eq():
41 print i == 'x'
42 print i == c'x'
43 print c == 'x'
44 print c == c'x'
45 # print s == 'x' # error
46 # print s == c'x' # error
48 def test_cascaded_eq():
49 print 'x' == i == 'x'
50 print 'x' == i == c'x'
51 print c'x' == i == 'x'
52 print c'x' == i == c'x'
54 print 'x' == c == 'x'
55 print 'x' == c == c'x'
56 print c'x' == c == 'x'
57 print c'x' == c == c'x'
59 def test_cascaded_ineq():
60 print 'a' <= i <= 'z'
61 print 'a' <= i <= c'z'
62 print c'a' <= i <= 'z'
63 print c'a' <= i <= c'z'
65 print 'a' <= c <= 'z'
66 print 'a' <= c <= c'z'
67 print c'a' <= c <= 'z'
68 print c'a' <= c <= c'z'
70 def test_long_ineq():
71 print 'a' < 'b' < 'c' < 'd' < c < 'y' < 'z'
73 def test_long_ineq_py():
74 print 'abcdef' < 'b' < 'c' < 'd' < 'y' < 'z'
75 print 'a' < 'b' < 'cde' < 'd' < 'y' < 'z'
