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

Commit e193c21

Browse files
committed
✅ Add specs for prefixes/suffixes on function type params for JSDoc
1 parent 01d21ed commit e193c21

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

spec/javascript-spec.coffee

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2037,6 +2037,36 @@ describe "JavaScript grammar", ->
20372037
expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
20382038
expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
20392039
2040+
{tokens} = grammar.tokenizeLine('/** @param {function(...string)} variable this is the description */')
2041+
expect(tokens[4]).toEqual value: '{function(...string)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
2042+
expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
2043+
expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
2044+
2045+
{tokens} = grammar.tokenizeLine('/** @param {function(string, ...number)} variable this is the description */')
2046+
expect(tokens[4]).toEqual value: '{function(string, ...number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
2047+
expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
2048+
expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
2049+
2050+
{tokens} = grammar.tokenizeLine('/** @param {function(string, ...number)} variable this is the description */')
2051+
expect(tokens[4]).toEqual value: '{function(string, ...number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
2052+
expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
2053+
expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
2054+
2055+
{tokens} = grammar.tokenizeLine('/** @param {function(!string)} variable this is the description */')
2056+
expect(tokens[4]).toEqual value: '{function(!string)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
2057+
expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
2058+
expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
2059+
2060+
{tokens} = grammar.tokenizeLine('/** @param {function(?string, !number)} variable this is the description */')
2061+
expect(tokens[4]).toEqual value: '{function(?string, !number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
2062+
expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
2063+
expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
2064+
2065+
{tokens} = grammar.tokenizeLine('/** @param {function(string[], number=)} variable this is the description */')
2066+
expect(tokens[4]).toEqual value: '{function(string[], number=)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
2067+
expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
2068+
expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
2069+
20402070
{tokens} = grammar.tokenizeLine('/** @param {function():number} variable this is the description */')
20412071
expect(tokens[4]).toEqual value: '{function():number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
20422072
expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
@@ -2092,6 +2122,30 @@ describe "JavaScript grammar", ->
20922122
expect(tokens[4]).toEqual value: '{function(string, number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
20932123
expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
20942124
2125+
{tokens} = grammar.tokenizeLine('/** @return {function(...string)} this is the description */')
2126+
expect(tokens[4]).toEqual value: '{function(...string)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
2127+
expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
2128+
2129+
{tokens} = grammar.tokenizeLine('/** @return {function(string, ...number)} this is the description */')
2130+
expect(tokens[4]).toEqual value: '{function(string, ...number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
2131+
expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
2132+
2133+
{tokens} = grammar.tokenizeLine('/** @return {function(string, ...number)} this is the description */')
2134+
expect(tokens[4]).toEqual value: '{function(string, ...number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
2135+
expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
2136+
2137+
{tokens} = grammar.tokenizeLine('/** @return {function(!string)} this is the description */')
2138+
expect(tokens[4]).toEqual value: '{function(!string)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
2139+
expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
2140+
2141+
{tokens} = grammar.tokenizeLine('/** @return {function(?string, !number)} this is the description */')
2142+
expect(tokens[4]).toEqual value: '{function(?string, !number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
2143+
expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
2144+
2145+
{tokens} = grammar.tokenizeLine('/** @return {function(string[], number=)} this is the description */')
2146+
expect(tokens[4]).toEqual value: '{function(string[], number=)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
2147+
expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
2148+
20952149
{tokens} = grammar.tokenizeLine('/** @return {function():number} this is the description */')
20962150
expect(tokens[4]).toEqual value: '{function():number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
20972151
expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']

0 commit comments

Comments
 (0)