mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
prevent crashes in lenient mode when a param tag has an invalid type expression (#451)
This commit is contained in:
parent
01ce3042d1
commit
47fe83de3d
@ -17,7 +17,7 @@ function getNewDoclet(comment, e) {
|
||||
err = new Error( util.format('cannot create a doclet for the comment "%s": %s',
|
||||
comment.replace(/[\r\n]/g, ''), error.message) );
|
||||
require('jsdoc/util/error').handle(err);
|
||||
return new jsdoc.doclet.Doclet('', {});
|
||||
return new jsdoc.doclet.Doclet('', e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
9
test/fixtures/paramtaginvalidtype.js
vendored
Normal file
9
test/fixtures/paramtaginvalidtype.js
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
var Test = function () {};
|
||||
|
||||
/**
|
||||
* @param {string, number} a
|
||||
*/
|
||||
Test.prototype.test = function (a) {};
|
||||
@ -1,3 +1,4 @@
|
||||
/*global describe: true, env: true, expect: true, it: true, jasmine: true, spyOn: true */
|
||||
describe("@param tag", function() {
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/paramtag.js'),
|
||||
find = docSet.getByLongname('find')[0],
|
||||
@ -77,4 +78,28 @@ describe("@param tag", function() {
|
||||
expect(commit.params[0].name).toBe('atomic');
|
||||
});
|
||||
|
||||
it('When a symbol has a @param tag with an invalid type expression, the doclet is generated in lenient mode, and the JSDoc comment is ignored.', function() {
|
||||
var badDocSet;
|
||||
var test;
|
||||
var lenient = !!env.opts.lenient;
|
||||
|
||||
env.opts.lenient = true;
|
||||
spyOn(console, 'log');
|
||||
|
||||
badDocSet = jasmine.getDocSetFromFile('test/fixtures/paramtaginvalidtype.js');
|
||||
test = badDocSet.getByLongname('Test#test')[0];
|
||||
|
||||
expect(test).toBeDefined();
|
||||
expect(typeof test).toBe('object');
|
||||
|
||||
expect(test.meta).toBeDefined();
|
||||
expect(typeof test.meta).toBe('object');
|
||||
|
||||
expect(test.meta.filename).toBeDefined();
|
||||
expect(test.meta.filename).toBe('[[string0]]');
|
||||
|
||||
expect(test.description).not.toBeDefined();
|
||||
|
||||
env.opts.lenient = lenient;
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user