Skip to content

Commit

Permalink
implement semver parser & deprecated block + test
Browse files Browse the repository at this point in the history
  • Loading branch information
ichiriac committed Jan 8, 2017
1 parent ca58ab2 commit afedeff
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var Lexer = function (tokens) {

// breaking symbols
var lexerSymbols = [
',', '=', ':', '(', ')', '[', ']', '{', '}', '@', '"', '\'', '\\', '<', '>', '$'
',', '=', ':', '(', ')', '[', ']', '{', '}', '@', '"', '\'', '\\', '<', '>', '$', '-'
];

// whitespace chars
Expand Down
8 changes: 4 additions & 4 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,12 +475,12 @@ Parser.prototype.parseVersion = function () {
}

// READ THE VERSION
v = v.split('\\.');
version.major = v[0];
v = v.split('.');
version.major = parseInt(v[0], 10);
if (v.length > 1) {
version.minor = v[1];
version.minor = parseInt(v[1], 10);
if (v.length > 2) {
version.patch = v[2];
version.patch = parseInt(v[2], 10);
}
}
return version;
Expand Down
13 changes: 13 additions & 0 deletions test/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,17 @@ describe('Test parser', function () {
should.equal(ast.body[0].name, null);
ast.body[0].description.should.be.exactly('Foo is Bar');
});

it('test deprecated', function () {
var ast = doc.parse([
'/**',
' * @deprecated 13.223.314-beta.5',
' */'
].join('\n'));
ast.body[0].kind.should.be.exactly('deprecated');
ast.body[0].version.major.should.be.exactly(13);
ast.body[0].version.minor.should.be.exactly(223);
ast.body[0].version.patch.should.be.exactly(314);
ast.body[0].version.label.should.be.exactly('beta.5');
});
});

0 comments on commit afedeff

Please sign in to comment.