Move some tests into function docstrings.
[cython.git] / tests / run / literals.pyx
1 def foo():
2     """
3     >>> foo()
4     """
5     a = 42
6     a1 = 0123
7     a2 = 0xabc
8     a3 = 0xDEF
9     a4 = 1234567890L
10     b = 42.88e17
11     b0a = 1.
12     b0b = .1
13     b0c = 1.1
14     b0d = 1.e1
15     b0e = .1e1
16     b0f = 1.1e1
17     b0g = 1.1e-1
18     b0h = 1e1
19     b1 = 3j
20     b2 = 3.1415J
21     b3 = c'X'
22     c = "spanish inquisition"
23     d = "this" "parrot" "is" "resting"
24     e = 'single quoted string'
25     f = '"this is quoted"'
26     g = '''Triple single quoted string.'''
27     h = """Triple double quoted string."""
28     g1 = '''Two line triple
29 single quoted string.'''
30     h1 = """Two line triple
31 double quoted string."""
32     i = 'This string\
33  has an ignored newline.'
34     j = 'One-char escapes: \'\"\\\a\b\f\n\r\t\v'
35     k = b'Oct and hex escapes: \1 \12 \123 \x45 \xaf \xAF'
36     l = r'''This is\
37 a \three \line
38 raw string with some backslashes.'''
39     m = 'Three backslashed ordinaries: \c\g\+'
40     n = '''Triple single quoted string 
41 with ' and " quotes'''
42     o = """Triple double quoted string 
43 with ' and " quotes"""
44     p = "name_like_string"
45     q = "NameLikeString2"
46     r = "99_percent_un_namelike"
47     s = "Not an \escape"
48     t = b'this' b'parrot' b'is' b'resting'
49     u = u'this' u'parrot' u'is' u'resting'
50
51
52 def test_float(x):
53     """
54     >>> test_float(1./3)
55     True
56     """
57     return x == 1./3
58
59 def test_complex(x):
60     """
61     >>> test_complex(1j/3)
62     True
63     """
64     return x == 0.3333333333333333j