@@ -247,19 +247,33 @@ describe "Python grammar", ->
247
247
expect (tokens[0 ][2 ].scopes ).toEqual [' source.python' ]
248
248
249
249
it " tokenizes comments inside function parameters" , ->
250
- tokens = grammar .tokenizeLines (' def test(arg, # comment' )
251
- expect (tokens[0 ].length ).toBe 10
252
- expect (tokens[0 ][0 ].value ).toBe ' def'
253
- expect (tokens[0 ][0 ].scopes ).toEqual [' source.python' , ' meta.function.python' , ' storage.type.function.python' ]
254
- expect (tokens[0 ][2 ].value ).toBe ' test'
255
- expect (tokens[0 ][2 ].scopes ).toEqual [' source.python' , ' meta.function.python' , ' entity.name.function.python' ]
256
- expect (tokens[0 ][3 ].value ).toBe ' ('
257
- expect (tokens[0 ][3 ].scopes ).toEqual [' source.python' , ' meta.function.python' , ' punctuation.definition.parameters.begin.python' ]
258
- expect (tokens[0 ][4 ].value ).toBe ' arg'
259
- expect (tokens[0 ][4 ].scopes ).toEqual [' source.python' , ' meta.function.python' , ' meta.function.parameters.python' , ' variable.parameter.function.python' ]
260
- expect (tokens[0 ][5 ].value ).toBe ' ,'
261
- expect (tokens[0 ][5 ].scopes ).toEqual [' source.python' , ' meta.function.python' , ' meta.function.parameters.python' , ' punctuation.separator.parameters.python' ]
262
- expect (tokens[0 ][7 ].value ).toBe ' #'
263
- expect (tokens[0 ][7 ].scopes ).toEqual [' source.python' , ' meta.function.python' , ' meta.function.parameters.python' , ' comment.line.number-sign.python' , ' punctuation.definition.comment.python' ]
264
- expect (tokens[0 ][8 ].value ).toBe ' comment'
265
- expect (tokens[0 ][8 ].scopes ).toEqual [' source.python' , ' meta.function.python' , ' meta.function.parameters.python' , ' comment.line.number-sign.python' ]
250
+ {tokens } = grammar .tokenizeLine (' def test(arg, # comment' )
251
+ expect (tokens .length ).toBe 10
252
+ expect (tokens[0 ]).toEqual value : ' def' , scopes : [' source.python' , ' meta.function.python' , ' storage.type.function.python' ]
253
+ expect (tokens[2 ]).toEqual value : ' test' , scopes : [' source.python' , ' meta.function.python' , ' entity.name.function.python' ]
254
+ expect (tokens[3 ]).toEqual value : ' (' , scopes : [' source.python' , ' meta.function.python' , ' punctuation.definition.parameters.begin.python' ]
255
+ expect (tokens[4 ]).toEqual value : ' arg' , scopes : [' source.python' , ' meta.function.python' , ' meta.function.parameters.python' , ' variable.parameter.function.python' ]
256
+ expect (tokens[5 ]).toEqual value : ' ,' , scopes : [' source.python' , ' meta.function.python' , ' meta.function.parameters.python' , ' punctuation.separator.parameters.python' ]
257
+ expect (tokens[7 ]).toEqual value : ' #' , scopes : [' source.python' , ' meta.function.python' , ' meta.function.parameters.python' , ' comment.line.number-sign.python' , ' punctuation.definition.comment.python' ]
258
+ expect (tokens[8 ]).toEqual value : ' comment' , scopes : [' source.python' , ' meta.function.python' , ' meta.function.parameters.python' , ' comment.line.number-sign.python' ]
259
+
260
+ tokens = grammar .tokenizeLines ("""
261
+ def __init__(
262
+ self,
263
+ codec, # comment
264
+ config
265
+ ):
266
+ """ )
267
+ expect (tokens[0 ][0 ]).toEqual value : ' def' , scopes : [' source.python' , ' meta.function.python' , ' storage.type.function.python' ]
268
+ expect (tokens[0 ][2 ]).toEqual value : ' __init__' , scopes : [' source.python' , ' meta.function.python' , ' entity.name.function.python' , ' support.function.magic.python' ]
269
+ expect (tokens[0 ][3 ]).toEqual value : ' (' , scopes : [' source.python' , ' meta.function.python' , ' punctuation.definition.parameters.begin.python' ]
270
+ expect (tokens[1 ][1 ]).toEqual value : ' self' , scopes : [' source.python' , ' meta.function.python' , ' meta.function.parameters.python' , ' variable.parameter.function.python' ]
271
+ expect (tokens[1 ][2 ]).toEqual value : ' ,' , scopes : [' source.python' , ' meta.function.python' , ' meta.function.parameters.python' , ' punctuation.separator.parameters.python' ]
272
+ expect (tokens[2 ][1 ]).toEqual value : ' codec' , scopes : [' source.python' , ' meta.function.python' , ' meta.function.parameters.python' , ' variable.parameter.function.python' ]
273
+ expect (tokens[2 ][2 ]).toEqual value : ' ,' , scopes : [' source.python' , ' meta.function.python' , ' meta.function.parameters.python' , ' punctuation.separator.parameters.python' ]
274
+ expect (tokens[2 ][4 ]).toEqual value : ' #' , scopes : [' source.python' , ' meta.function.python' , ' meta.function.parameters.python' , ' comment.line.number-sign.python' , ' punctuation.definition.comment.python' ]
275
+ expect (tokens[2 ][5 ]).toEqual value : ' comment' , scopes : [' source.python' , ' meta.function.python' , ' meta.function.parameters.python' , ' comment.line.number-sign.python' ]
276
+ expect (tokens[3 ][1 ]).toEqual value : ' config' , scopes : [' source.python' , ' meta.function.python' , ' meta.function.parameters.python' , ' variable.parameter.function.python' ]
277
+ expect (tokens[4 ][0 ]).toEqual value : ' )' , scopes : [' source.python' , ' meta.function.python' , ' punctuation.definition.parameters.end.python' ]
278
+ expect (tokens[4 ][1 ]).toEqual value : ' :' , scopes : [' source.python' , ' meta.function.python' , ' punctuation.section.function.begin.python' ]
279
+
0 commit comments