Skip to content

Commit

Permalink
Additional tests for @borrows.
Browse files Browse the repository at this point in the history
  • Loading branch information
micmath committed Jan 30, 2011
1 parent bf7b667 commit 2facb89
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion modules/jsdoc/doclet.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
*/
exports.Doclet.prototype.borrow = function(source, target) {
if (!this.borrowed) { this.borrowed = []; }
this.borrowed.push( {from: source, as: (target||'this')} );
this.borrowed.push( {from: source, as: (target||source)} );
}

exports.Doclet.prototype.augment = function(base) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jsdoc",
"version": "3.0.0beta1",
"revision": "2011-01-24-2242",
"revision": "2011-01-30-1553",
"description": "An automatic documentation generator for javascript.",
"keywords": [ "documentation", "javascript" ],
"licenses": [
Expand Down
14 changes: 14 additions & 0 deletions test/cases/borrowstag2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/** @namespace
@borrows rtrim
*/
var str = {
rtrim: rtrim
};

/**
Remove whitespace from the right side of a string.
@param {string} str
*/
function rtrim(str) {
}

1 change: 1 addition & 0 deletions test/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ testFile('test/t/cases/alias3.js');
testFile('test/t/cases/augmentstag.js');
testFile('test/t/cases/authortag.js');
testFile('test/t/cases/borrowstag.js');
testFile('test/t/cases/borrowstag2.js');
testFile('test/t/cases/classtag.js');
testFile('test/t/cases/constructstag.js');
testFile('test/t/cases/constructstag2.js');
Expand Down
2 changes: 1 addition & 1 deletion test/t/cases/borrowstag.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

//dump(found);

test('When a symbol has a @borrows tag, that is added to the symbol\'s "borrowed" property.', function() {
test('When a symbol has a @borrows-as tag, that is added to the symbol\'s "borrowed" property.', function() {
assert.equal(util.borrowed.length, 1);
assert.equal(util.borrowed[0].from, 'trstr');
assert.equal(util.borrowed[0].as, 'trim');
Expand Down
14 changes: 14 additions & 0 deletions test/t/cases/borrowstag2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(function() {
var docSet = testhelpers.getDocSetFromFile('test/cases/borrowstag2.js'),
str = docSet.getByLongname('str').filter(function($) {
return ! $.undocumented;
})[0];

//dump(found);

test('When a symbol has a @borrows tag, that is added to the symbol\'s "borrowed" property and the from is the same as the as property.', function() {
assert.equal(str.borrowed.length, 1);
assert.equal(str.borrowed[0].from, 'rtrim');
assert.equal(str.borrowed[0].as, str.borrowed[0].from);
});
})();

0 comments on commit 2facb89

Please sign in to comment.