var SECTION = "proto_6";
var VERSION = "JS1_3";
var TITLE = "Adding properties to the Prototype Object";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = new Array();
function Employee ( name, dept ) {
this.name = name || "";
this.dept = dept || "general";
}
function WorkerBee ( name, dept, projs ) {
this.base = Employee;
this.base( name, dept)
this.projects = projs || new Array();
}
WorkerBee.prototype = new Employee();
function Engineer ( name, projs, machine ) {
this.base = WorkerBee;
this.base( name, "engineering", projs )
this.machine = machine || "";
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}
var pat = new Engineer( "Toonces, Pat",
["SpiderMonkey", "Rhino"],
"indy" );
Employee.prototype.specialty = "none";
testcases[tc++] = new TestCase( SECTION,
"pat.name",
"Toonces, Pat",
pat.name );
testcases[tc++] = new TestCase( SECTION,
"pat.dept",
"engineering",
pat.dept );
testcases[tc++] = new TestCase( SECTION,
"pat.projects.length",
2,
pat.projects.length );
testcases[tc++] = new TestCase( SECTION,
"pat.projects[0]",
"SpiderMonkey",
pat.projects[0] );
testcases[tc++] = new TestCase( SECTION,
"pat.projects[1]",
"Rhino",
pat.projects[1] );
testcases[tc++] = new TestCase( SECTION,
"pat.machine",
"indy",
pat.machine );
testcases[tc++] = new TestCase( SECTION,
"pat.specialty",
void 0,
pat.specialty );
test();