mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
handle object literals whose property names must be escaped in a regexp (#775)
This commit is contained in:
parent
765abd9a10
commit
4eb86a13a2
@ -74,7 +74,7 @@ var REGEXP_LEADING_SCOPE = new RegExp('^(' + REGEXP_SCOPE_PUNC + ')');
|
||||
var REGEXP_TRAILING_SCOPE = new RegExp('(' + REGEXP_SCOPE_PUNC + ')$');
|
||||
|
||||
function nameIsLongname(name, memberof) {
|
||||
var regexp = new RegExp('^' + memberof + REGEXP_SCOPE_PUNC);
|
||||
var regexp = new RegExp('^' + escape(memberof) + REGEXP_SCOPE_PUNC);
|
||||
|
||||
return regexp.test(name);
|
||||
}
|
||||
|
||||
10
test/fixtures/objectlit3.js
vendored
Normal file
10
test/fixtures/objectlit3.js
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
/** Tokens that can appear in the stream. */
|
||||
var tokens = {
|
||||
/** Open parenthesis. */
|
||||
'(': {
|
||||
/** Executed before the token is processed. */
|
||||
before: function(token) {},
|
||||
/** Executed after the token is processed. */
|
||||
after: function(token) {}
|
||||
}
|
||||
};
|
||||
@ -42,4 +42,26 @@ describe('object literals', function() {
|
||||
expect(found[0].scope).toBe('static');
|
||||
});
|
||||
});
|
||||
|
||||
describe('When an object literal\'s property names must be escaped in a regexp', function() {
|
||||
var docSet;
|
||||
var found;
|
||||
|
||||
function loadDocSet() {
|
||||
docSet = jasmine.getDocSetFromFile('test/fixtures/objectlit3.js');
|
||||
found = docSet.getByLongname('tokens.(.before');
|
||||
}
|
||||
|
||||
it('should not throw an error when creating a doclet', function() {
|
||||
expect(loadDocSet).not.toThrow();
|
||||
});
|
||||
|
||||
it('should have a doclet with the correct name', function() {
|
||||
expect(found[0].name).toBe('before');
|
||||
});
|
||||
|
||||
it('should have a doclet with the correct memberof', function() {
|
||||
expect(found[0].memberof).toBe('tokens.(');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user