@@ -634,19 +634,6 @@ describe "Python grammar", ->
634
634
expect (tokens[2 ]).toEqual value : ' def' , scopes : [' source.python' , ' meta.function.python' , ' storage.type.function.python' ]
635
635
expect (tokens[4 ]).toEqual value : ' test' , scopes : [' source.python' , ' meta.function.python' , ' entity.name.function.python' ]
636
636
637
- it " tokenizes functions that are missing parameters" , ->
638
- {tokens } = grammar .tokenizeLine ' def test # whoops'
639
-
640
- expect (tokens[0 ]).toEqual value : ' def' , scopes : [' source.python' , ' meta.function.python' , ' storage.type.function.python' ]
641
- expect (tokens[2 ]).toEqual value : ' test' , scopes : [' source.python' , ' meta.function.python' , ' entity.name.function.python' ]
642
- expect (tokens[3 ]).toEqual value : ' # whoops' , scopes : [' source.python' , ' meta.function.python' , ' invalid.illegal.missing-parameters.python' ]
643
-
644
- {tokens } = grammar .tokenizeLine ' def test:'
645
-
646
- expect (tokens[0 ]).toEqual value : ' def' , scopes : [' source.python' , ' meta.function.python' , ' storage.type.function.python' ]
647
- expect (tokens[2 ]).toEqual value : ' test' , scopes : [' source.python' , ' meta.function.python' , ' entity.name.function.python' ]
648
- expect (tokens[3 ]).toEqual value : ' :' , scopes : [' source.python' , ' meta.function.python' , ' invalid.illegal.missing-parameters.python' ]
649
-
650
637
it " tokenizes comments inside function parameters" , ->
651
638
{tokens } = grammar .tokenizeLine (' def test(arg, # comment' )
652
639
@@ -677,7 +664,27 @@ describe "Python grammar", ->
677
664
expect (tokens[2 ][5 ]).toEqual value : ' comment' , scopes : [' source.python' , ' meta.function.python' , ' meta.function.parameters.python' , ' comment.line.number-sign.python' ]
678
665
expect (tokens[3 ][1 ]).toEqual value : ' config' , scopes : [' source.python' , ' meta.function.python' , ' meta.function.parameters.python' , ' variable.parameter.function.python' ]
679
666
expect (tokens[4 ][0 ]).toEqual value : ' )' , scopes : [' source.python' , ' meta.function.python' , ' punctuation.definition.parameters.end.python' ]
680
- expect (tokens[4 ][1 ]).toEqual value : ' :' , scopes : [' source.python' , ' meta.function.python' , ' punctuation.section.function.begin.python' ]
667
+ expect (tokens[4 ][1 ]).toEqual value : ' :' , scopes : [' source.python' , ' meta.function.python' , ' punctuation.definition.function.begin.python' ]
668
+
669
+ it " tokenizes a function definition with annotations" , ->
670
+ {tokens } = grammar .tokenizeLine ' def f(a: None, b: int = 3) -> int:'
671
+
672
+ expect (tokens[0 ]).toEqual value : ' def' , scopes : [' source.python' , ' meta.function.python' , ' storage.type.function.python' ]
673
+ expect (tokens[2 ]).toEqual value : ' f' , scopes : [' source.python' , ' meta.function.python' , ' entity.name.function.python' ]
674
+ expect (tokens[3 ]).toEqual value : ' (' , scopes : [' source.python' , ' meta.function.python' , ' punctuation.definition.parameters.begin.python' ]
675
+ expect (tokens[4 ]).toEqual value : ' a' , scopes : [' source.python' , ' meta.function.python' , ' meta.function.parameters.python' , ' variable.parameter.function.python' ]
676
+ expect (tokens[5 ]).toEqual value : ' :' , scopes : [' source.python' , ' meta.function.python' , ' meta.function.parameters.python' , ' punctuation.separator.python' ]
677
+ expect (tokens[7 ]).toEqual value : ' None' , scopes : [' source.python' , ' meta.function.python' , ' meta.function.parameters.python' , ' storage.type.python' ]
678
+ expect (tokens[8 ]).toEqual value : ' ,' , scopes : [' source.python' , ' meta.function.python' , ' meta.function.parameters.python' , ' punctuation.separator.parameters.python' ]
679
+ expect (tokens[10 ]).toEqual value : ' b' , scopes : [' source.python' , ' meta.function.python' , ' meta.function.parameters.python' , ' variable.parameter.function.python' ]
680
+ expect (tokens[11 ]).toEqual value : ' :' , scopes : [' source.python' , ' meta.function.python' , ' meta.function.parameters.python' , ' punctuation.separator.python' ]
681
+ expect (tokens[13 ]).toEqual value : ' int' , scopes : [' source.python' , ' meta.function.python' , ' meta.function.parameters.python' , ' storage.type.python' ]
682
+ expect (tokens[15 ]).toEqual value : ' =' , scopes : [' source.python' , ' meta.function.python' , ' meta.function.parameters.python' , ' keyword.operator.assignment.python' ]
683
+ expect (tokens[17 ]).toEqual value : ' 3' , scopes : [' source.python' , ' meta.function.python' , ' meta.function.parameters.python' , ' constant.numeric.integer.decimal.python' ]
684
+ expect (tokens[18 ]).toEqual value : ' )' , scopes : [' source.python' , ' meta.function.python' , ' punctuation.definition.parameters.end.python' ]
685
+ expect (tokens[20 ]).toEqual value : ' ->' , scopes : [' source.python' , ' meta.function.python' , ' keyword.operator.function-annotation.python' ]
686
+ expect (tokens[22 ]).toEqual value : ' int' , scopes : [' source.python' , ' meta.function.python' , ' storage.type.python' ]
687
+ expect (tokens[23 ]).toEqual value : ' :' , scopes : [' source.python' , ' meta.function.python' , ' punctuation.definition.function.begin.python' ]
681
688
682
689
it " tokenizes complex function calls" , ->
683
690
{tokens } = grammar .tokenizeLine " torch.nn.BCELoss()(Variable(bayes_optimal_prob, 1, requires_grad=False), Yvar).data[0]"
@@ -758,7 +765,6 @@ describe "Python grammar", ->
758
765
expect (tokens[9 ][0 ]).toEqual value : delim, scopes : [' source.python' , scope, ' punctuation.definition.string.end.python' ]
759
766
760
767
it " tokenizes SQL inline highlighting on single line with a CTE" , ->
761
-
762
768
{tokens } = grammar .tokenizeLine (' \' WITH example_cte AS (SELECT bar FROM foo) SELECT COUNT(*) FROM example_cte\' ' )
763
769
764
770
expect (tokens[0 ]).toEqual value : ' \' ' , scopes : [' source.python' , ' string.quoted.single.single-line.python' , ' punctuation.definition.string.begin.python' ]
0 commit comments