]> git.saurik.com Git - apple/javascriptcore.git/blame - tests/mozilla/js1_3/inherit/proto_11.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / mozilla / js1_3 / inherit / proto_11.js
CommitLineData
b37bf2e1
A
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_11.js
24 Section:
25 Description: Global Information in Constructors
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 This tests the syntax ObjectName.prototype = new PrototypeObject using the
33 Employee example in the document referenced above.
34
35 Author: christine@netscape.com
36 Date: 12 november 1997
37*/
38
39 var SECTION = "proto_11";
40 var VERSION = "JS1_3";
41 var TITLE = "Global Information in Constructors";
42
43 startTest();
44 writeHeaderToLog( SECTION + " "+ TITLE);
45
46 var testcases = new Array();
47 var idCounter = 1;
48
49
50function Employee ( name, dept ) {
51 this.name = name || "";
52 this.dept = dept || "general";
53 this.id = idCounter++;
54}
55function Manager () {
56 this.reports = [];
57}
58Manager.prototype = new Employee();
59
60function WorkerBee ( name, dept, projs ) {
61 this.base = Employee;
62 this.base( name, dept)
63 this.projects = projs || new Array();
64}
65WorkerBee.prototype = new Employee();
66
67function SalesPerson () {
68 this.dept = "sales";
69 this.quota = 100;
70}
71SalesPerson.prototype = new WorkerBee();
72
73function Engineer ( name, projs, machine ) {
74 this.base = WorkerBee;
75 this.base( name, "engineering", projs )
76 this.machine = machine || "";
77}
78Engineer.prototype = new WorkerBee();
79
80function test() {
81 for ( tc=0; tc < testcases.length; tc++ ) {
82 testcases[tc].passed = writeTestCaseResult(
83 testcases[tc].expect,
84 testcases[tc].actual,
85 testcases[tc].description +" = "+
86 testcases[tc].actual );
87
88 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
89 }
90 stopTest();
91 return ( testcases );
92}
93 var pat = new Employee( "Toonces, Pat", "Tech Pubs" )
94 var terry = new Employee( "O'Sherry Terry", "Marketing" );
95
96 var les = new Engineer( "Morris, Les", new Array("JavaScript"), "indy" );
97
98 testcases[tc++] = new TestCase( SECTION,
99 "pat.id",
100 5,
101 pat.id );
102
103 testcases[tc++] = new TestCase( SECTION,
104 "terry.id",
105 6,
106 terry.id );
107
108 testcases[tc++] = new TestCase( SECTION,
109 "les.id",
110 7,
111 les.id );
112
113
114 test();
115