cython
1# mode: run
2
3def foo():
4"""
5>>> foo()
6"""
7a = 42
8a1 = 0123
9an1 = -0123
10assert a1 == -an1
11a2 = 0xabc
12an2 = -0xabc
13assert a2 == -an2
14a3 = 0xDEF
15an3 = -0xDEF
16assert a3 == -an3
17a4 = 1234567890L
18an4 = -1234567890L
19assert a4 == -an4
20a5 = 0o123
21an5 = -0o123
22assert a5 == -an5
23assert a5 == a1
24a6 = 0b101
25an6 = -0b101
26assert a6 == -an6 == 5
27
28b = 42.88e17
29b0a = 1.
30b0b = .1
31b0c = 1.1
32b0d = 1.e1
33b0e = .1e1
34b0f = 1.1e1
35b0g = 1.1e-1
36b0h = 1e1
37
38b1 = 3j
39b2 = 3.1415J
40
41b3 = c'X'
42c = "spanish inquisition"
43d = "this" "parrot" "is" "resting"
44e = 'single quoted string'
45f = '"this is quoted"'
46g = '''Triple single quoted string.'''
47h = """Triple double quoted string."""
48g1 = '''Two line triple
49single quoted string.'''
50h1 = """Two line triple
51double quoted string."""
52i = 'This string\
53has an ignored newline.'
54j = 'One-char escapes: \'\"\\\a\b\f\n\r\t\v'
55k = b'Oct and hex escapes: \1 \12 \123 \x45 \xaf \xAF'
56l = r'''This is\
57a \three \line
58raw string with some backslashes.'''
59m = 'Three backslashed ordinaries: \c\g\+'
60n = '''Triple single quoted string
61with ' and " quotes'''
62o = """Triple double quoted string
63with ' and " quotes"""
64p = "name_like_string"
65q = "NameLikeString2"
66r = "99_percent_un_namelike"
67s = "Not an \escape"
68t = b'this' b'parrot' b'is' b'resting'
69u = u'this' u'parrot' u'is' u'resting'
70
71
72def test_float(x):
73"""
74>>> test_float(1./3)
75True
76"""
77return x == 1./3
78
79def test_complex(x):
80"""
81>>> test_complex(1j/3)
82True
83"""
84return x == 0.3333333333333333j
85
86def test_large_int(double x):
87"""
88>>> test_large_int(0)
892e+100
90"""
91a = x + 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
92a += 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
93return a
94