]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/js1_3/inherit/proto_3.js
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: Adding properties to an instance
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_3";
40 var VERSION
= "JS1_3";
41 var TITLE
= "Adding properties to an Instance";
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();
61 WorkerBee
.prototype = new Employee();
63 function SalesPerson () {
67 SalesPerson
.prototype = new WorkerBee();
69 function Engineer () {
70 this.dept
= "engineering";
73 Engineer
.prototype = new WorkerBee();
76 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
77 testcases
[tc
].passed
= writeTestCaseResult(
80 testcases
[tc
].description
+" = "+
81 testcases
[tc
].actual
);
83 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";
88 var jim
= new Employee();
89 var pat
= new Employee();
93 testcases
[tc
++] = new TestCase( SECTION
,
94 "jim = new Employee(); jim.bonus = 300; jim.bonus",
99 testcases
[tc
++] = new TestCase( SECTION
,
100 "pat = new Employee(); pat.bonus",