cython

Форк
0
/
literals.pyx 
93 строки · 2.0 Кб
1
# mode: run
2

3
def foo():
4
    """
5
    >>> foo()
6
    """
7
    a = 42
8
    a1 = 0123
9
    an1 = -0123
10
    assert a1 == -an1
11
    a2 = 0xabc
12
    an2 = -0xabc
13
    assert a2 == -an2
14
    a3 = 0xDEF
15
    an3 = -0xDEF
16
    assert a3 == -an3
17
    a4 = 1234567890L
18
    an4 = -1234567890L
19
    assert a4 == -an4
20
    a5 = 0o123
21
    an5 = -0o123
22
    assert a5 == -an5
23
    assert a5 == a1
24
    a6 = 0b101
25
    an6 = -0b101
26
    assert a6 == -an6 == 5
27

28
    b = 42.88e17
29
    b0a = 1.
30
    b0b = .1
31
    b0c = 1.1
32
    b0d = 1.e1
33
    b0e = .1e1
34
    b0f = 1.1e1
35
    b0g = 1.1e-1
36
    b0h = 1e1
37

38
    b1 = 3j
39
    b2 = 3.1415J
40

41
    b3 = c'X'
42
    c = "spanish inquisition"
43
    d = "this" "parrot" "is" "resting"
44
    e = 'single quoted string'
45
    f = '"this is quoted"'
46
    g = '''Triple single quoted string.'''
47
    h = """Triple double quoted string."""
48
    g1 = '''Two line triple
49
single quoted string.'''
50
    h1 = """Two line triple
51
double quoted string."""
52
    i = 'This string\
53
 has an ignored newline.'
54
    j = 'One-char escapes: \'\"\\\a\b\f\n\r\t\v'
55
    k = b'Oct and hex escapes: \1 \12 \123 \x45 \xaf \xAF'
56
    l = r'''This is\
57
a \three \line
58
raw string with some backslashes.'''
59
    m = 'Three backslashed ordinaries: \c\g\+'
60
    n = '''Triple single quoted string
61
with ' and " quotes'''
62
    o = """Triple double quoted string
63
with ' and " quotes"""
64
    p = "name_like_string"
65
    q = "NameLikeString2"
66
    r = "99_percent_un_namelike"
67
    s = "Not an \escape"
68
    t = b'this' b'parrot' b'is' b'resting'
69
    u = u'this' u'parrot' u'is' u'resting'
70

71

72
def test_float(x):
73
    """
74
    >>> test_float(1./3)
75
    True
76
    """
77
    return x == 1./3
78

79
def test_complex(x):
80
    """
81
    >>> test_complex(1j/3)
82
    True
83
    """
84
    return x == 0.3333333333333333j
85

86
def test_large_int(double x):
87
    """
88
    >>> test_large_int(0)
89
    2e+100
90
    """
91
    a = x + 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
92
    a += 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
93
    return a
94

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.