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

Commit

Permalink
SQL: Add tests for new behaviours
Browse files Browse the repository at this point in the history
- Check for case insensitivity which will allow for `Select`, `select` and sPoNgebOB notation keyword starters
- Check for starting round brackets as it may also be used at times
  • Loading branch information
keevan committed Feb 10, 2022
1 parent b82f751 commit 169b9a4
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions spec/php-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2948,6 +2948,24 @@ describe 'PHP grammar', ->
expect(tokens[2]).toEqual value: ' something', scopes: ['source.php', scope, 'source.sql.embedded.php']
expect(tokens[3]).toEqual value: delim, scopes: ['source.php', scope, 'punctuation.definition.string.end.php']

{tokens} = grammar.tokenizeLine "#{delim}sEleCT something#{delim}"

# Case insensitive
expect(tokens[0]).toEqual value: delim, scopes: ['source.php', scope, 'punctuation.definition.string.begin.php']
expect(tokens[1]).toEqual value: 'sEleCT', scopes: ['source.php', scope, 'source.sql.embedded.php', 'keyword.other.DML.sql']
expect(tokens[2]).toEqual value: ' something', scopes: ['source.php', scope, 'source.sql.embedded.php']
expect(tokens[3]).toEqual value: delim, scopes: ['source.php', scope, 'punctuation.definition.string.end.php']

{tokens} = grammar.tokenizeLine "#{delim}(select something)#{delim}"

# Surrounded by brackets
expect(tokens[0]).toEqual value: delim, scopes: ['source.php', scope, 'punctuation.definition.string.begin.php']
expect(tokens[1]).toEqual value: '(', scopes: ['source.php', scope, 'source.sql.embedded.php', 'punctuation.definition.section.bracket.round.begin.sql']
expect(tokens[2]).toEqual value: 'select', scopes: ['source.php', scope, 'source.sql.embedded.php', 'keyword.other.DML.sql']
expect(tokens[3]).toEqual value: ' something', scopes: ['source.php', scope, 'source.sql.embedded.php']
expect(tokens[4]).toEqual value: ')', scopes: ['source.php', scope, 'source.sql.embedded.php', 'punctuation.definition.section.bracket.round.end.sql']
expect(tokens[5]).toEqual value: delim, scopes: ['source.php', scope, 'punctuation.definition.string.end.php']

lines = grammar.tokenizeLines """
#{delim}SELECT something
-- uh oh a comment SELECT#{delim}
Expand Down

0 comments on commit 169b9a4

Please sign in to comment.