var SECTION = "proto_11";
var VERSION = "JS1_3";
var TITLE = "Global Information in Constructors";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = new Array();
var idCounter = 1;
function Employee ( name, dept ) {
this.name = name || "";
this.dept = dept || "general";
this.id = idCounter++;
}
function Manager () {
this.reports = [];
}
Manager.prototype = new Employee();
function WorkerBee ( name, dept, projs ) {
this.base = Employee;
this.base( name, dept)
this.projects = projs || new Array();
}
WorkerBee.prototype = new Employee();
function SalesPerson () {
this.dept = "sales";
this.quota = 100;
}
SalesPerson.prototype = new WorkerBee();
function Engineer ( name, projs, machine ) {
this.base = WorkerBee;
this.base( name, "engineering", projs )
this.machine = machine || "";
}
Engineer.prototype = new WorkerBee();
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 Employee( "Toonces, Pat", "Tech Pubs" )
var terry = new Employee( "O'Sherry Terry", "Marketing" );
var les = new Engineer( "Morris, Les", new Array("JavaScript"), "indy" );
testcases[tc++] = new TestCase( SECTION,
"pat.id",
5,
pat.id );
testcases[tc++] = new TestCase( SECTION,
"terry.id",
6,
terry.id );
testcases[tc++] = new TestCase( SECTION,
"les.id",
7,
les.id );
test();