Skip to content

Commit

Permalink
test some illegal ?.
Browse files Browse the repository at this point in the history
  • Loading branch information
icecream17 authored May 16, 2023
1 parent dc432a5 commit 4dde985
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/language-javascript/spec/javascript-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -1966,6 +1966,22 @@ describe "JavaScript grammar", ->
expect(tokens[4]).toEqual value: '?.', scopes: ['source.js', 'meta.delimiter.property.optional.js']
expect(tokens[5]).toEqual value: 'b', scopes: ['source.js', 'variable.other.property.js']
it "detects some illegal uses of the optional chaining operator", ->
{tokens} = grammar.tokenizeLine('new a?.b')
expect(tokens[1]).toEqual value: 'a', scopes: ['source.js', 'meta.class.instance.constructor.js', 'entity.name.type.instance.js']
expect(tokens[2]).toEqual value: '?.', scopes: ['source.js', 'meta.class.instance.constructor.js', 'entity.name.type.instance.js', 'invalid.illegal.meta.delimiter.property.period.js']
expect(tokens[3]).toEqual value: 'b', scopes: ['source.js', 'meta.class.instance.constructor.js', 'entity.name.type.instance.js']
{tokens} = grammar.tokenizeLine('a?.b = function c () {}')
expect(tokens[0]).toEqual value: 'a', scopes: ['source.js', 'variable.other.object.js']
expect(tokens[1]).toEqual value: '?.', scopes: ['source.js', 'meta.function.js', 'invalid.illegal.meta.delimiter.method.period.js']
expect(tokens[2]).toEqual value: 'b', scopes: ['source.js', 'meta.function.js', 'entity.name.function.js']
expect(tokens[4]).toEqual value: '=', scopes: ['source.js', 'meta.function.js', 'keyword.operator.assignment.js']
{tokens} = grammar.tokenizeLine('a?.b = _ => 2')
expect(tokens[0]).toEqual value: 'a', scopes: ['source.js', 'variable.other.object.js']
expect(tokens[1]).toEqual value: '?.', scopes: ['source.js', 'meta.function.arrow.js', 'invalid.illegal.meta.delimiter.method.period.js']
expect(tokens[2]).toEqual value: 'b', scopes: ['source.js', 'meta.function.arrow.js', 'entity.name.function.js']
describe "strings and functions", ->
it "doesn't confuse them", ->
Expand Down

0 comments on commit 4dde985

Please sign in to comment.