1# Tests for the 'tokenize' module.
2# Large bits stolen from test_grammar.py. 
3
4# Comments
5"#"
6#'
7#"
8#\
9       #
10    # abc
11'''#
12#'''
13
14x = 1  #
15
16# Balancing continuation
17
18a = (3, 4,
19  5, 6)
20y = [3, 4,
21  5]
22z = {'a':5,
23  'b':6}
24x = (len(repr(y)) + 5*x - a[
25   3 ]
26   - x + len({
27   }
28    )
29  )
30
31# Backslash means line continuation:
32x = 1 \
33+ 1
34
35# Backslash does not means continuation in comments :\
36x = 0
37
38# Ordinary integers
390xff != 255
400o377 != 255
412147483647   != 0o17777777777
42-2147483647-1 != 0o20000000000
430o37777777777 != -1
440xffffffff != -1; 0o37777777777 != -1; -0o1234567 == 0O001234567; 0b10101 == 0B00010101
45
46# Long integers
47x = 0
48x = 0
49x = 0xffffffffffffffff
50x = 0xffffffffffffffff
51x = 0o77777777777777777
52x = 0B11101010111111111
53x = 123456789012345678901234567890
54x = 123456789012345678901234567890
55
56# Floating-point numbers
57x = 3.14
58x = 314.
59x = 0.314
60# XXX x = 000.314
61x = .314
62x = 3e14
63x = 3E14
64x = 3e-14
65x = 3e+14
66x = 3.e14
67x = .3e14
68x = 3.1e4
69
70# String literals
71x = ''; y = "";
72x = '\''; y = "'";
73x = '"'; y = "\"";
74x = "doesn't \"shrink\" does it"
75y = 'doesn\'t "shrink" does it'
76x = "does \"shrink\" doesn't it"
77y = 'does "shrink" doesn\'t it'
78x = """
79The "quick"
80brown fox
81jumps over
82the 'lazy' dog.
83"""
84y = '\nThe "quick"\nbrown fox\njumps over\nthe \'lazy\' dog.\n'
85y = '''
86The "quick"
87brown fox
88jumps over
89the 'lazy' dog.
90''';
91y = "\n\
92The \"quick\"\n\
93brown fox\n\
94jumps over\n\
95the 'lazy' dog.\n\
96";
97y = '\n\
98The \"quick\"\n\
99brown fox\n\
100jumps over\n\
101the \'lazy\' dog.\n\
102';
103x = r'\\' + R'\\'
104x = r'\'' + ''
105y = r'''
106foo bar \\
107baz''' + R'''
108foo'''
109y = r"""foo
110bar \\ baz
111""" + R'''spam
112'''
113x = b'abc' + B'ABC'
114y = b"abc" + B"ABC"
115x = br'abc' + Br'ABC' + bR'ABC' + BR'ABC'
116y = br"abc" + Br"ABC" + bR"ABC" + BR"ABC"
117x = rb'abc' + rB'ABC' + Rb'ABC' + RB'ABC'
118y = rb"abc" + rB"ABC" + Rb"ABC" + RB"ABC"
119x = br'\\' + BR'\\'
120x = rb'\\' + RB'\\'
121x = br'\'' + ''
122x = rb'\'' + ''
123y = br'''
124foo bar \\
125baz''' + BR'''
126foo'''
127y = Br"""foo
128bar \\ baz
129""" + bR'''spam
130'''
131y = rB"""foo
132bar \\ baz
133""" + Rb'''spam
134'''
135
136# Indentation
137if 1:
138    x = 2
139if 1:
140        x = 2
141if 1:
142    while 0:
143     if 0:
144           x = 2
145     x = 2
146if 0:
147  if 2:
148   while 0:
149        if 1:
150          x = 2
151
152# Operators
153
154def d22(a, b, c=1, d=2): pass
155def d01v(a=1, *restt, **restd): pass
156
157(x, y) != ({'a':1}, {'b':2})
158
159# comparison
160if 1 < 1 > 1 == 1 >= 1 <= 1 != 1 != 1 in 1 not in 1 is 1 is not 1: pass
161
162# binary
163x = 1 & 1
164x = 1 ^ 1
165x = 1 | 1
166
167# shift
168x = 1 << 1 >> 1
169
170# additive
171x = 1 - 1 + 1 - 1 + 1
172
173# multiplicative
174x = 1 / 1 * 1 % 1
175
176# unary
177x = ~1 ^ 1 & 1 | 1 & 1 ^ -1
178x = -1*1/1 + 1*1 - ---1*1
179
180# selector
181import sys, time
182x = sys.modules['time'].time()
183
184@staticmethod
185def foo(): pass
186
187@staticmethod
188def foo(x:1)->1: pass
189
190