1/* The contents of this file are subject to the Netscape Public
2 * License Version 1.1 (the "License"); you may not use this file
3 * except in compliance with the License. You may obtain a copy of
4 * the License at http://www.mozilla.org/NPL/
5 *
6 * Software distributed under the License is distributed on an "AS
7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8 * implied. See the License for the specific language governing
9 * rights and limitations under the License.
10 *
11 * The Original Code is Mozilla Communicator client code, released March
12 * 31, 1998.
13 *
14 * The Initial Developer of the Original Code is Netscape Communications
15 * Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
17 * Rights Reserved.
18 *
19 * Contributor(s):
20 *
21 */
22/**
23    File Name:          proto_12.js
24    Section:
25    Description:        new PrototypeObject
26
27    This tests Object Hierarchy and Inheritance, as described in the document
28    Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97
29    15:19:34 on http://devedge.netscape.com/.  Current URL:
30    http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm
31
32    No Multiple Inheritance
33
34    Author:             christine@netscape.com
35    Date:               12 november 1997
36*/
37
38    var SECTION = "proto_12";
39    var VERSION = "JS1_3";
40    var TITLE   = "No Multiple Inheritance";
41
42    startTest();
43    writeHeaderToLog( SECTION + " "+ TITLE);
44
45    var testcases = new Array();
46
47function Employee ( name, dept ) {
48     this.name = name || "";
49     this.dept = dept || "general";
50     this.id = idCounter++;
51}
52function Manager () {
53     this.reports = [];
54}
55Manager.prototype = new Employee();
56
57function WorkerBee ( name, dept, projs ) {
58    this.base = Employee;
59    this.base( name, dept)
60    this.projects = projs || new Array();
61}
62WorkerBee.prototype = new Employee();
63
64function SalesPerson () {
65    this.dept = "sales";
66    this.quota = 100;
67}
68SalesPerson.prototype = new WorkerBee();
69
70function Hobbyist( hobby ) {
71    this.hobby = hobby || "yodeling";
72}
73
74function Engineer ( name, projs, machine, hobby ) {
75    this.base1 = WorkerBee;
76    this.base1( name, "engineering", projs )
77
78    this.base2 = Hobbyist;
79    this.base2( hobby );
80
81    this.projects = projs || new Array();
82    this.machine = machine || "";
83}
84Engineer.prototype = new WorkerBee();
85
86function test() {
87    for ( tc=0; tc < testcases.length; tc++ ) {
88        testcases[tc].passed = writeTestCaseResult(
89                            testcases[tc].expect,
90                            testcases[tc].actual,
91                            testcases[tc].description +" = "+
92                            testcases[tc].actual );
93
94        testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
95    }
96    stopTest();
97    return ( testcases );
98}
99    var idCounter = 1;
100
101    var les = new Engineer( "Morris, Les",  new Array("JavaScript"), "indy" );
102
103    Hobbyist.prototype.equipment = [ "horn", "mountain", "goat" ];
104
105    testcases[tc++] = new TestCase( SECTION,
106                                    "les.name",
107                                    "Morris, Les",
108                                    les.name );
109
110    testcases[tc++] = new TestCase( SECTION,
111                                    "les.dept",
112                                    "engineering",
113                                    les.dept );
114
115    Array.prototype.getClass = Object.prototype.toString;
116
117    testcases[tc++] = new TestCase( SECTION,
118                                    "les.projects.getClass()",
119                                    "[object Array]",
120                                    les.projects.getClass() );
121
122    testcases[tc++] = new TestCase( SECTION,
123                                    "les.projects[0]",
124                                    "JavaScript",
125                                    les.projects[0] );
126
127    testcases[tc++] = new TestCase( SECTION,
128                                    "les.machine",
129                                    "indy",
130                                    les.machine );
131
132    testcases[tc++] = new TestCase( SECTION,
133                                    "les.hobby",
134                                    "yodeling",
135                                    les.hobby );
136
137    testcases[tc++] = new TestCase( SECTION,
138                                    "les.equpment",
139                                    void 0,
140                                    les.equipment );
141
142    test();
143