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/
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.
11
* The Original Code is Mozilla Communicator client code, released March
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
25
Description: new PrototypeObject
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
32
This tests the syntax ObjectName.prototype = new PrototypeObject using the
33
Employee example in the document referenced above.
35
Author: christine@netscape.com
36
Date: 12 november 1997
39
var SECTION = "proto_1";
40
var VERSION = "JS1_3";
41
var TITLE = "new PrototypeObject";
44
writeHeaderToLog( SECTION + " "+ TITLE);
46
var testcases = new Array();
48
function Employee () {
50
this.dept = "general";
55
Manager.prototype = new Employee();
57
function WorkerBee () {
58
this.projects = new Array();
60
WorkerBee.prototype = new Employee();
62
function SalesPerson () {
66
SalesPerson.prototype = new WorkerBee();
68
function Engineer () {
69
this.dept = "engineering";
72
Engineer.prototype = new WorkerBee();
75
for ( tc=0; tc < testcases.length; tc++ ) {
76
testcases[tc].passed = writeTestCaseResult(
79
testcases[tc].description +" = "+
80
testcases[tc].actual );
82
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
87
var jim = new Employee();
89
testcases[tc++] = new TestCase( SECTION,
90
"jim = new Employee(); jim.name",
95
testcases[tc++] = new TestCase( SECTION,
96
"jim = new Employee(); jim.dept",
100
var sally = new Manager();
102
testcases[tc++] = new TestCase( SECTION,
103
"sally = new Manager(); sally.name",
106
testcases[tc++] = new TestCase( SECTION,
107
"sally = new Manager(); sally.dept",
111
testcases[tc++] = new TestCase( SECTION,
112
"sally = new Manager(); sally.reports.length",
114
sally.reports.length );
116
testcases[tc++] = new TestCase( SECTION,
117
"sally = new Manager(); typeof sally.reports",
119
typeof sally.reports );
121
var fred = new SalesPerson();
123
testcases[tc++] = new TestCase( SECTION,
124
"fred = new SalesPerson(); fred.name",
128
testcases[tc++] = new TestCase( SECTION,
129
"fred = new SalesPerson(); fred.dept",
133
testcases[tc++] = new TestCase( SECTION,
134
"fred = new SalesPerson(); fred.quota",
138
testcases[tc++] = new TestCase( SECTION,
139
"fred = new SalesPerson(); fred.projects.length",
141
fred.projects.length );
143
var jane = new Engineer();
145
testcases[tc++] = new TestCase( SECTION,
146
"jane = new Engineer(); jane.name",
150
testcases[tc++] = new TestCase( SECTION,
151
"jane = new Engineer(); jane.dept",
155
testcases[tc++] = new TestCase( SECTION,
156
"jane = new Engineer(); jane.projects.length",
158
jane.projects.length );
160
testcases[tc++] = new TestCase( SECTION,
161
"jane = new Engineer(); jane.machine",
b'\\ No newline at end of file'