]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/js1_3/inherit/proto_6.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: Logical OR || in constructors
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 This tests the logical OR opererator || syntax in constructors.
37 Author: christine@netscape.com
38 Date: 12 november 1997
41 var SECTION
= "proto_6";
42 var VERSION
= "JS1_3";
43 var TITLE
= "Logical OR || in constructors";
46 writeHeaderToLog( SECTION
+ " "+ TITLE
);
48 var testcases
= new Array();
50 function Employee ( name
, dept
) {
51 this.name
= name
|| "";
52 this.dept
= dept
|| "general";
57 Manager
.prototype = new Employee();
59 function WorkerBee ( name
, dept
, projs
) {
61 this.base( name
, dept
)
62 this.projects
= projs
|| new Array();
65 WorkerBee
.prototype = new Employee();
67 function SalesPerson () {
71 SalesPerson
.prototype = new WorkerBee();
73 function Engineer ( name
, projs
, machine
) {
74 this.base
= WorkerBee
;
75 this.base( name
, "engineering", projs
)
76 this.machine
= machine
|| "";
78 Engineer
.prototype = new WorkerBee();
81 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
82 testcases
[tc
].passed
= writeTestCaseResult(
85 testcases
[tc
].description
+" = "+
86 testcases
[tc
].actual
);
88 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";
94 var pat
= new Engineer( "Toonces, Pat",
95 ["SpiderMonkey", "Rhino"],
98 var les
= new WorkerBee( "Morris, Les",
102 var terry
= new Employee( "Boomberi, Terry",
107 testcases
[tc
++] = new TestCase( SECTION
,
112 testcases
[tc
++] = new TestCase( SECTION
,
117 testcases
[tc
++] = new TestCase( SECTION
,
118 "pat.projects.length",
120 pat
.projects
.length
);
122 testcases
[tc
++] = new TestCase( SECTION
,
127 testcases
[tc
++] = new TestCase( SECTION
,
132 testcases
[tc
++] = new TestCase( SECTION
,
138 // Les, the WorkerBee
140 testcases
[tc
++] = new TestCase( SECTION
,
145 testcases
[tc
++] = new TestCase( SECTION
,
150 testcases
[tc
++] = new TestCase( SECTION
,
151 "les.projects.length",
153 les
.projects
.length
);
155 testcases
[tc
++] = new TestCase( SECTION
,
160 // Terry, the Employee
161 testcases
[tc
++] = new TestCase( SECTION
,
166 testcases
[tc
++] = new TestCase( SECTION
,