Skip to content

Commit d4914e9

Browse files
DimitrisJimStefan Krah
authored andcommitted
Add ELLIPSIS and RARROW. Add tests (#666)
1 parent 9135275 commit d4914e9

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

Lib/test/test_tokenize.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,25 @@ def test_function(self):
407407
OP ')' (1, 22) (1, 23)
408408
OP ':' (1, 23) (1, 24)
409409
NAME 'pass' (1, 25) (1, 29)
410+
""")
411+
self.check_tokenize("def d23(a: str, b: int=3) -> int: pass", """\
412+
NAME 'def' (1, 0) (1, 3)
413+
NAME 'd23' (1, 4) (1, 7)
414+
OP '(' (1, 7) (1, 8)
415+
NAME 'a' (1, 8) (1, 9)
416+
OP ':' (1, 9) (1, 10)
417+
NAME 'str' (1, 11) (1, 14)
418+
OP ',' (1, 14) (1, 15)
419+
NAME 'b' (1, 16) (1, 17)
420+
OP ':' (1, 17) (1, 18)
421+
NAME 'int' (1, 19) (1, 22)
422+
OP '=' (1, 22) (1, 23)
423+
NUMBER '3' (1, 23) (1, 24)
424+
OP ')' (1, 24) (1, 25)
425+
OP '->' (1, 26) (1, 28)
426+
NAME 'int' (1, 29) (1, 32)
427+
OP ':' (1, 32) (1, 33)
428+
NAME 'pass' (1, 34) (1, 38)
410429
""")
411430

412431
def test_comparison(self):
@@ -1371,6 +1390,8 @@ def test_exact_type(self):
13711390
self.assertExactTypeEqual('**=', token.DOUBLESTAREQUAL)
13721391
self.assertExactTypeEqual('//', token.DOUBLESLASH)
13731392
self.assertExactTypeEqual('//=', token.DOUBLESLASHEQUAL)
1393+
self.assertExactTypeEqual('...', token.ELLIPSIS)
1394+
self.assertExactTypeEqual('->', token.RARROW)
13741395
self.assertExactTypeEqual('@', token.AT)
13751396
self.assertExactTypeEqual('@=', token.ATEQUAL)
13761397

Lib/tokenize.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,14 @@
8686
'%=': PERCENTEQUAL,
8787
'&=': AMPEREQUAL,
8888
'|=': VBAREQUAL,
89-
'^=': CIRCUMFLEXEQUAL,
89+
'^=': CIRCUMFLEXEQUAL,
9090
'<<=': LEFTSHIFTEQUAL,
9191
'>>=': RIGHTSHIFTEQUAL,
9292
'**=': DOUBLESTAREQUAL,
9393
'//': DOUBLESLASH,
9494
'//=': DOUBLESLASHEQUAL,
95+
'...': ELLIPSIS,
96+
'->': RARROW,
9597
'@': AT,
9698
'@=': ATEQUAL,
9799
}

0 commit comments

Comments
 (0)