]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/js1_3/inherit/proto_12.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
23 File Name: proto_12.js
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 No Multiple Inheritance
34 Author: christine@netscape.com
35 Date: 12 november 1997
38 var SECTION
= "proto_12";
39 var VERSION
= "JS1_3";
40 var TITLE
= "No Multiple Inheritance";
43 writeHeaderToLog( SECTION
+ " "+ TITLE
);
45 var testcases
= new Array();
47 function Employee ( name
, dept
) {
48 this.name
= name
|| "";
49 this.dept
= dept
|| "general";
50 this.id
= idCounter
++;
55 Manager
.prototype = new Employee();
57 function WorkerBee ( name
, dept
, projs
) {
59 this.base( name
, dept
)
60 this.projects
= projs
|| new Array();
62 WorkerBee
.prototype = new Employee();
64 function SalesPerson () {
68 SalesPerson
.prototype = new WorkerBee();
70 function Hobbyist( hobby
) {
71 this.hobby
= hobby
|| "yodeling";
74 function Engineer ( name
, projs
, machine
, hobby
) {
75 this.base1
= WorkerBee
;
76 this.base1( name
, "engineering", projs
)
78 this.base2
= Hobbyist
;
81 this.projects
= projs
|| new Array();
82 this.machine
= machine
|| "";
84 Engineer
.prototype = new WorkerBee();
87 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
88 testcases
[tc
].passed
= writeTestCaseResult(
91 testcases
[tc
].description
+" = "+
92 testcases
[tc
].actual
);
94 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";
101 var les
= new Engineer( "Morris, Les", new Array("JavaScript"), "indy" );
103 Hobbyist
.prototype.equipment
= [ "horn", "mountain", "goat" ];
105 testcases
[tc
++] = new TestCase( SECTION
,
110 testcases
[tc
++] = new TestCase( SECTION
,
115 Array
.prototype.getClass
= Object
.prototype.toString
;
117 testcases
[tc
++] = new TestCase( SECTION
,
118 "les.projects.getClass()",
120 les
.projects
.getClass() );
122 testcases
[tc
++] = new TestCase( SECTION
,
127 testcases
[tc
++] = new TestCase( SECTION
,
132 testcases
[tc
++] = new TestCase( SECTION
,
137 testcases
[tc
++] = new TestCase( SECTION
,