Added tests for @class tag.

This commit is contained in:
Michael Mathews 2011-01-16 19:45:59 +00:00
parent a00113b32c
commit 22fc216425
8 changed files with 66 additions and 7 deletions

View File

@ -11,11 +11,12 @@
dictionary.defineTag('access', {
mustHaveValue: true,
onTagged: function(doclet, tag) {
if ( /^(private|protected)$/.test(tag.value) ) {
doclet.access = tag.value;
// only valid values are private and protected, public is default
if ( /^(private|protected)$/i.test(tag.value) ) {
doclet.access = tag.value.toLowerCase();
}
else if (tag.value === 'public') {
delete doclet.access;
else {
delete doclet.access;
}
return true;
@ -313,7 +314,7 @@
dictionary.defineTag('public', {
mustNotHaveValue: true,
onTagged: function(doclet, tag) {
doclet.access = 'public';
delete doclet.access; // public is default
return true;
}

View File

@ -10,4 +10,20 @@ function Thingy() {
/** @access public */
this.pez = 2;
}
// same as...
/** @constructor */
function OtherThingy() {
/** @private */
var foo = 0;
/** @protected */
this._bar = 1;
/** @public */
this.pez = 2;
}

8
test/cases/classtag.js Normal file
View File

@ -0,0 +1,8 @@
/**
This function creates a new Foo.
@constructor
@class The class of Foo represent all those foo things.
*/
function Foo() {
}

View File

@ -4,7 +4,7 @@ function foo() {
}
/** @deprec v1.0.2
/** @deprec since version 2.0
*/
function bar() {

View File

@ -92,6 +92,7 @@ testFile('test/t/cases/alias2.js');
testFile('test/t/cases/augmentstag.js');
testFile('test/t/cases/accesstag.js');
testFile('test/t/cases/authortag.js');
testFile('test/t/cases/classtag.js');
testFile('test/t/cases/copyrighttag.js');
testFile('test/t/cases/deprecatedtag.js');
testFile('test/t/cases/exceptiontag.js');

View File

@ -6,6 +6,24 @@
//dump(docSet.doclets);
test('When a symbol has a @access private tag, the doclet has a access="private" property.', function() {
assert.equal(foo.access, 'private');
});
test('When a symbol has a @access protected tag, the doclet has a access="protected" property.', function() {
assert.equal(_bar.access, 'protected');
});
test('When a symbol has a @access public tag, the doclet has no access property.', function() {
assert.equal(typeof pez.access, 'undefined');
});
// same as...
foo = docSet.getByLongname('OtherThingy~foo')[0];
_bar = docSet.getByLongname('OtherThingy#_bar')[0];
pez = docSet.getByLongname('OtherThingy#pez')[0];
test('When a symbol has a @private tag, the doclet has a access="private" property.', function() {
assert.equal(foo.access, 'private');
});

15
test/t/cases/classtag.js Normal file
View File

@ -0,0 +1,15 @@
(function() {
var docSet = testhelpers.getDocSetFromFile('test/cases/classtag.js'),
foo = docSet.getByLongname('Foo')[0];
//dump(docSet.doclets); exit(0);
test('When a symbol has a @class tag, the doclet has a classdesc property with that value.', function() {
assert.equal(foo.classdesc, 'The class of Foo represent all those foo things.');
});
test('When a symbol has a @class tag, the doclet doclet description is separate from the classdesc.', function() {
assert.equal(foo.description, 'This function creates a new Foo.');
});
})();

View File

@ -10,7 +10,7 @@
});
test('When a symbol has a @deprec tag with a value, the doclet has a deprecated property set to that value.', function() {
assert.equal(bar.deprecated, 'v1.0.2');
assert.equal(bar.deprecated, 'since version 2.0');
});
})();