Skip to content

Commit

Permalink
fix type parser & improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ichiriac committed Jan 8, 2017
1 parent ecbe333 commit f17d295
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,15 +388,13 @@ Parser.prototype.parseListOfTypes = function (charEnd) {
while (this.token === ',') {
this.token = this.lexer.lex(); // eat && continue
indexType = this.parseType();
if (indexType === null) {
break;
} else {
if (indexType !== null) {
result.push(indexType);
}
}
}
if (this.token !== charEnd) {
return null;
if (this.token === charEnd) {
this.token = this.lexer.lex(); // eat && continue
}
}
return result;
Expand Down
30 changes: 30 additions & 0 deletions test/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,4 +290,34 @@ describe('Test parser', function () {
'array'
]);
});

it('test parseListOfTypes', function () {
var ast = doc.parse([
'/**',
' * @return String[Number, Number]',
' * @return Iterable<String, Foo>',
' */'
].join('\n'));
ast.body[0].kind.should.be.exactly('return');
ast.body[0].what.should.be.eql({
index: [
{
fqn: false,
kind: 'type',
name: 'Number'
},
{
fqn: false,
kind: 'type',
name: 'Number'
}
],
kind: 'collection',
value: {
fqn: false,
kind: 'type',
name: 'String'
}
});
});
});

0 comments on commit f17d295

Please sign in to comment.