Skip to content

Commit 9efeb2a

Browse files
author
Max Brunsfeld
authored
Merge pull request atom#255 from falcondai/fix-lambda
add more test cases for lambda tokenization
2 parents 239d7cd + abe1168 commit 9efeb2a

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

grammars/python.cson

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@
335335
]
336336
}
337337
{
338-
'begin': '\\b(lambda)\\s?+'
338+
'begin': '\\b(lambda)\\b'
339339
'beginCaptures':
340340
'1':
341341
'name': 'storage.type.function.inline.python'

spec/python-spec.coffee

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,6 @@ describe "Python grammar", ->
721721
{tokens} = grammar.tokenizeLine "lambda x, z = 4: x * z"
722722

723723
expect(tokens[0]).toEqual value: 'lambda', scopes: ['source.python', 'meta.function.inline.python', 'storage.type.function.inline.python']
724-
expect(tokens[1]).toEqual value: ' ', scopes: ['source.python', 'meta.function.inline.python']
725724
expect(tokens[2]).toEqual value: 'x', scopes: ['source.python', 'meta.function.inline.python', 'meta.function.inline.parameters.python', 'variable.parameter.function.python']
726725
expect(tokens[3]).toEqual value: ',', scopes: ['source.python', 'meta.function.inline.python', 'meta.function.inline.parameters.python', 'punctuation.separator.parameters.python']
727726
expect(tokens[5]).toEqual value: 'z', scopes: ['source.python', 'meta.function.inline.python', 'meta.function.inline.parameters.python', 'variable.parameter.function.python']
@@ -735,10 +734,14 @@ describe "Python grammar", ->
735734
expect(tokens[0]).toEqual value: 'lambda', scopes: ['source.python', 'meta.function.inline.python', 'storage.type.function.inline.python']
736735
expect(tokens[1]).toEqual value: ':', scopes: ['source.python', 'meta.function.inline.python', 'punctuation.definition.function.begin.python']
737736

738-
it "does not tokenizes a variable name containing lambda as a lambda", ->
737+
it "does not tokenizes a variable name ending with lambda as a lambda", ->
739738
{tokens} = grammar.tokenizeLine "not_a_lambda.foo"
740739
expect(tokens[0]).toEqual value: 'not_a_lambda', scopes: ['source.python', 'variable.other.object.python']
741740

741+
it "does not tokenizes a variable name starting with lambda as a lambda", ->
742+
{tokens} = grammar.tokenizeLine "lambda_not.foo"
743+
expect(tokens[0]).toEqual value: 'lambda_not', scopes: ['source.python', 'variable.other.object.python']
744+
742745
describe "SQL highlighting", ->
743746
beforeEach ->
744747
waitsForPromise ->

0 commit comments

Comments
 (0)