Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

add more test cases for lambda tokenization #255

Merged
merged 2 commits into from Apr 24, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion grammars/python.cson
Expand Up @@ -335,7 +335,7 @@
]
}
{
'begin': '\\b(lambda)\\s?+'
'begin': '\\b(lambda)(?=[\\s\\:])'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would something as simple as a word boundary anchor (\b) work here, or do you need the lookahead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That s a very good point! Let me push a new commit

'beginCaptures':
'1':
'name': 'storage.type.function.inline.python'
Expand Down
7 changes: 5 additions & 2 deletions spec/python-spec.coffee
Expand Up @@ -721,7 +721,6 @@ describe "Python grammar", ->
{tokens} = grammar.tokenizeLine "lambda x, z = 4: x * z"

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

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

it "does not tokenizes a variable name starting with lambda as a lambda", ->
{tokens} = grammar.tokenizeLine "lambda_not.foo"
expect(tokens[0]).toEqual value: 'lambda_not', scopes: ['source.python', 'variable.other.object.python']

describe "SQL highlighting", ->
beforeEach ->
waitsForPromise ->
Expand Down