Refactor continues.

This commit is contained in:
Michael Mathews 2011-01-02 22:09:41 +00:00
parent 568e36449c
commit 46971ae61a
21 changed files with 249 additions and 1893 deletions

0
test/cases/global.js Normal file
View File

7
test/cases/inner.js Normal file
View File

@ -0,0 +1,7 @@
function sendMessage(text) {
/** document me */
var encoding = 'utf8';
/** document me */
function encrypt(){}
}

0
test/cases/memberof.js Normal file
View File

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

@ -0,0 +1,8 @@
/** document me */
var tools = {
/** document me */
serialiser: {
/** document me */
value: ''
}
};

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

@ -0,0 +1,8 @@
/** document me */
var position = {
axis: {
/** document me */
x: 0,
y: 0
}
};

View File

@ -0,0 +1,12 @@
/** @constructor */
function Page(title) {
this.parts = {
title: title,
body: {
/** document me */
heading: '',
main: ''
}
}
}

11
test/cases/this.js Normal file
View File

@ -0,0 +1,11 @@
/**
@constructor
*/
function Singer() {
this.tralala = function() { // method of constructor Singer
/** document me */
this.isSinging = true; // setting a member of constructor Singer
};
}

15
test/cases/this2.js Normal file
View File

@ -0,0 +1,15 @@
/** @constructor */
function TemplateBuilder(templateType) {
/** document me */
this.templateType = templateType;
/** @constructor */
this.Template = function() { // nested constructor of constructor TemplateFactory
/** document me */
this.render = function(data) {
/** document me */
this.rendered = true;
}
};
}

5
test/cases/this3.js Normal file
View File

@ -0,0 +1,5 @@
function setPosition(newP) {
/** document me */
this.position = newP; // sets global property
}

10
test/cases/var.js Normal file
View File

@ -0,0 +1,10 @@
/** document me */
const GREEN = 1,
RED = 0;
/** document me */
var validate = function(){};
var i,
/** document me */
results;

3
test/cases/virtual.js Normal file
View File

@ -0,0 +1,3 @@
/** @name dimensions */
var width = 12

File diff suppressed because it is too large Load Diff

21
test/t/cases/inner.js Normal file
View File

@ -0,0 +1,21 @@
(function() {
var docSet = testhelpers.getDocSetFromFile('test/cases/inner.js'),
found1 = docSet.getByLongname('sendMessage~encoding'),
found2 = docSet.getByLongname('sendMessage~encrypt');
//dump(docSet);
test('When a documented var member is inside a named function.', function() {
assert.equal(found1.length, 1, 'A doclet with the correct longname should be found.');
assert.equal(found1[0].name, 'encoding', 'The short name should be correct.');
assert.equal(found1[0].memberof, 'sendMessage', 'The memberof should be correct.');
assert.equal(found1[0].scope, 'inner', 'The scope should default to "static".');
});
test('When a documented function is inside a named function.', function() {
assert.equal(found2.length, 1, 'A doclet with the correct longname should be found.');
assert.equal(found2[0].name, 'encrypt', 'The short name should be correct.');
assert.equal(found2[0].memberof, 'sendMessage', 'The memberof should be correct.');
assert.equal(found2[0].scope, 'inner', 'The scope should default to "static".');
});
})();

13
test/t/cases/objectlit.js Normal file
View File

@ -0,0 +1,13 @@
(function() {
var docSet = testhelpers.getDocSetFromFile('test/cases/objectlit.js'),
found = docSet.getByLongname('tools.serialiser.value');
//dump(docSet);
test('When a child of an objlit has no @name or @memberof tags.', function() {
assert.equal(found.length, 1, 'A doclet with the correct longname should be found.');
assert.equal(found[0].name, 'value', 'The short name should be correct.');
assert.equal(found[0].memberof, 'tools.serialiser', 'The memberof should be correct.');
assert.equal(found[0].scope, 'static', 'The scope should default to "static".');
});
})();

View File

@ -0,0 +1,13 @@
(function() {
var docSet = testhelpers.getDocSetFromFile('test/cases/objectlit2.js'),
found = docSet.getByLongname('position.axis.x');
//dump(docSet);
test('When a parent of an objlit has no documentation.', function() {
assert.equal(found.length, 1, 'A doclet with the correct longname should be found.');
assert.equal(found[0].name, 'x', 'The short name should be correct.');
assert.equal(found[0].memberof, 'position.axis', 'The memberof should be correct.');
assert.equal(found[0].scope, 'static', 'The scope should default to "static".');
});
})();

View File

@ -0,0 +1,26 @@
/** @constructor */
function Page(title) {
this.parts = {
title: title,
body: {
/** document me */
heading: '',
main: ''
}
}
}
(function() {
var docSet = testhelpers.getDocSetFromFile('test/cases/this-and-objectlit.js'),
found = docSet.getByLongname('Page#parts.body.heading');
//dump(docSet);
test('When a member is nested inside an objectlit this property inside a constructor.', function() {
assert.equal(found.length, 1, 'A this member should be like Constructor#objlit.member.');
assert.equal(found[0].name, 'heading', 'The short name should be correct.');
assert.equal(found[0].memberof, 'Page#parts.body', 'The memberof should be correct.');
assert.equal(found[0].scope, 'static', 'The scope should default to "static".');
});
})();

21
test/t/cases/this.js Normal file
View File

@ -0,0 +1,21 @@
(function() {
var docSet = testhelpers.getDocSetFromFile('test/cases/this.js'),
found1 = docSet.getByLongname('Singer#tralala'),
found2 = docSet.getByLongname('Singer#isSinging');
//dump(docSet);
test('When a member is attached to this in a constructor.', function() {
assert.equal(found1.length, 1, 'The longname should be like Constructor#member.');
assert.equal(found1[0].name, 'tralala', 'The short name should be correct.');
assert.equal(found1[0].memberof, 'Singer', 'The memberof should be correct.');
assert.equal(found1[0].scope, 'instance', 'The scope should default to "static".');
});
test('When a member is attached to this in a method of a constructor.', function() {
assert.equal(found2.length, 1, 'The longname should be like Constructor#member.');
assert.equal(found2[0].name, 'isSinging', 'The short name should be correct.');
assert.equal(found2[0].memberof, 'Singer', 'The memberof should be correct.');
assert.equal(found2[0].scope, 'instance', 'The scope should default to "static".');
});
})();

14
test/t/cases/this2.js Normal file
View File

@ -0,0 +1,14 @@
(function() {
var docSet = testhelpers.getDocSetFromFile('test/cases/this2.js'),
found = docSet.getByLongname('TemplateBuilder#Template#rendered');
//dump(docSet);
test('When a constructor is nested inside another a constructor.', function() {
assert.equal(found.length, 1, 'A this member should be like Constructor#Constructor#member.');
assert.equal(found[0].name, 'rendered', 'The short name should be correct.');
assert.equal(found[0].memberof, 'TemplateBuilder#Template', 'The memberof should be correct.');
assert.equal(found[0].scope, 'instance', 'The scope should default to "static".');
});
})();

13
test/t/cases/this3.js Normal file
View File

@ -0,0 +1,13 @@
(function() {
var docSet = testhelpers.getDocSetFromFile('test/cases/this3.js'),
found = docSet.getByLongname('position');
//dump(docSet);
test('When a this is assigned to inside a non-constructor function.', function() {
assert.equal(found.length, 1, 'The member name should be global, like "member".');
assert.equal(found[0].name, 'position', 'The short name should be correct.');
assert.equal(found[0].memberof, undefined, 'The memberof should be correct.');
});
})();

31
test/t/cases/var.js Normal file
View File

@ -0,0 +1,31 @@
(function() {
var docSet = testhelpers.getDocSetFromFile('test/cases/var.js'),
found = [
docSet.getByLongname('GREEN'),
docSet.getByLongname('RED'),
docSet.getByLongname('validate'),
docSet.getByLongname('i'),
docSet.getByLongname('results')
];
//dump(docSet);
test('When a series of constants are documented.', function() {
assert.equal(found[0].length, 1, 'The first constant should be found');
assert.equal(found[0][0].src, '/** document me */', 'The first constant should get the docs.');
assert.equal(found[0][0].name, 'GREEN', 'The short name should be correct.');
assert.equal(found[0][0].memberof, undefined, 'The memberof should be undefined.');
assert.equal(found[0][0].scope, undefined, 'The scope should be undefined.');
assert.equal(found[1].length, 1, 'The second constant should be found');
assert.equal(found[1][0].undocumented, true, 'The second constant should not get the docs.');
});
test('When member of a series of vars are documented.', function() {
assert.equal(found[4][0].src, '/** document me */', 'The correct var should get the docs.');
assert.equal(found[4][0].name, 'results', 'The short name should be correct.');
assert.equal(found[4][0].memberof, undefined, 'The memberof should be undefined.');
assert.equal(found[4][0].scope, undefined, 'The scope should be undefined.');
});
})();

18
test/t/cases/virtual.js Normal file
View File

@ -0,0 +1,18 @@
(function() {
var docSet = testhelpers.getDocSetFromFile('test/cases/virtual.js'),
found = [
docSet.getByLongname('dimensions'),
docSet.getByLongname('width')
];
//dump(docSet);
test('When a virtual symbol is documented.', function() {
assert.equal(found[0].length, 1, 'The symbol should be documented');
});
test('When an undocumented is after a comment for a virtual symbol is documented.', function() {
assert.equal(found[1].length, 1, 'The symbol should be documented');
});
})();