Investigating leaks in bug 463263, backout bug 453403.
[wine-gecko.git] / js / tests / js1_3 / inherit / proto_4.js
blob40b51e38807c539c8c50795975af2274e62ebdc1
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is Mozilla Communicator client code, released
16 * March 31, 1998.
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1998
21 * the Initial Developer. All Rights Reserved.
23 * Contributor(s):
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 gTestfile = 'proto_4.js';
41 /**
42 File Name: proto_4.js
43 Section:
44 Description: new PrototypeObject
46 This tests Object Hierarchy and Inheritance, as described in the document
47 Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97
48 15:19:34 on http://devedge.netscape.com/. Current URL:
49 http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm
51 This tests the syntax ObjectName.prototype = new PrototypeObject using the
52 Employee example in the document referenced above.
54 If you add a property to an object in the prototype chain, instances of
55 objects that derive from that prototype should inherit that property, even
56 if they were instatiated after the property was added to the prototype object.
59 Author: christine@netscape.com
60 Date: 12 november 1997
63 var SECTION = "proto_3";
64 var VERSION = "JS1_3";
65 var TITLE = "Adding properties to the prototype";
67 startTest();
68 writeHeaderToLog( SECTION + " "+ TITLE);
70 function Employee () {
71 this.name = "";
72 this.dept = "general";
74 function Manager () {
75 this.reports = [];
77 Manager.prototype = new Employee();
79 function WorkerBee () {
80 this.projects = new Array();
83 WorkerBee.prototype = new Employee();
85 function SalesPerson () {
86 this.dept = "sales";
87 this.quota = 100;
89 SalesPerson.prototype = new WorkerBee();
91 function Engineer () {
92 this.dept = "engineering";
93 this.machine = "";
95 Engineer.prototype = new WorkerBee();
97 var jim = new Employee();
98 var terry = new Engineer();
99 var sean = new SalesPerson();
100 var wally = new Manager();
102 Employee.prototype.specialty = "none";
104 var pat = new Employee();
105 var leslie = new Engineer();
106 var bubbles = new SalesPerson();
107 var furry = new Manager();
109 Engineer.prototype.specialty = "code";
111 var chris = new Engineer();
114 new TestCase( SECTION,
115 "jim = new Employee(); jim.specialty",
116 "none",
117 jim.specialty );
119 new TestCase( SECTION,
120 "terry = new Engineer(); terry.specialty",
121 "code",
122 terry.specialty );
124 new TestCase( SECTION,
125 "sean = new SalesPerson(); sean.specialty",
126 "none",
127 sean.specialty );
129 new TestCase( SECTION,
130 "wally = new Manager(); wally.specialty",
131 "none",
132 wally.specialty );
134 new TestCase( SECTION,
135 "furry = new Manager(); furry.specialty",
136 "none",
137 furry.specialty );
139 new TestCase( SECTION,
140 "pat = new Employee(); pat.specialty",
141 "none",
142 pat.specialty );
144 new TestCase( SECTION,
145 "leslie = new Engineer(); leslie.specialty",
146 "code",
147 leslie.specialty );
149 new TestCase( SECTION,
150 "bubbles = new SalesPerson(); bubbles.specialty",
151 "none",
152 bubbles.specialty );
155 new TestCase( SECTION,
156 "chris = new Employee(); chris.specialty",
157 "code",
158 chris.specialty );
159 test();