Debian Codegraph @

rhino/testsrc/tests/js1_3/inherit/proto_6.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 gTestfile = 'proto_6.js';
7
8 /**
9 File Name: proto_6.js
10 Section:
11 Description: Logical OR || in constructors
12
13 This tests Object Hierarchy and Inheritance, as described in the document
14 Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97
15 15:19:34 on http://devedge.netscape.com/. Current URL:
16 http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm
17
18 This tests the syntax ObjectName.prototype = new PrototypeObject using the
19 Employee example in the document referenced above.
20
21 This tests the logical OR opererator || syntax in constructors.
22
23 Author: [email protected]
24 Date: 12 november 1997
25 */
26
27 var SECTION = "proto_6";
28 var VERSION = "JS1_3";
29 var TITLE = "Logical OR || in constructors";
30
31 startTest();
32 writeHeaderToLog( SECTION + " "+ TITLE);
33
34 function Employee ( name, dept ) {
35 this.name = name || "";
36 this.dept = dept || "general";
37 }
38 function Manager () {
39 this.reports = [];
40 }
41 Manager.prototype = new Employee();
42
43 function WorkerBee ( name, dept, projs ) {
44 this.base = Employee;
45 this.base( name, dept)
46 this.projects = projs || new Array();
47 }
48
49 WorkerBee.prototype = new Employee();
50
51 function SalesPerson () {
52 this.dept = "sales";
53 this.quota = 100;
54 }
55 SalesPerson.prototype = new WorkerBee();
56
57 function Engineer ( name, projs, machine ) {
58 this.base = WorkerBee;
59 this.base( name, "engineering", projs )
60 this.machine = machine || "";
61 }
62 Engineer.prototype = new WorkerBee();
63
64 var pat = new Engineer( "Toonces, Pat",
65 ["SpiderMonkey", "Rhino"],
66 "indy" );
67
68 var les = new WorkerBee( "Morris, Les",
69 "Training",
70 ["Hippo"] )
71
72 var terry = new Employee( "Boomberi, Terry",
73 "Marketing" );
74
75 // Pat, the Engineer
76
77 new TestCase( SECTION,
78 "pat.name",
79 "Toonces, Pat",
80 pat.name );
81
82 new TestCase( SECTION,
83 "pat.dept",
84 "engineering",
85 pat.dept );
86
87 new TestCase( SECTION,
88 "pat.projects.length",
89 2,
90 pat.projects.length );
91
92 new TestCase( SECTION,
93 "pat.projects[0]",
94 "SpiderMonkey",
95 pat.projects[0] );
96
97 new TestCase( SECTION,
98 "pat.projects[1]",
99 "Rhino",
100 pat.projects[1] );
101
102 new TestCase( SECTION,
103 "pat.machine",
104 "indy",
105 pat.machine );
106
107
108 // Les, the WorkerBee
109
110 new TestCase( SECTION,
111 "les.name",
112 "Morris, Les",
113 les.name );
114
115 new TestCase( SECTION,
116 "les.dept",
117 "Training",
118 les.dept );
119
120 new TestCase( SECTION,
121 "les.projects.length",
122 1,
123 les.projects.length );
124
125 new TestCase( SECTION,
126 "les.projects[0]",
127 "Hippo",
128 les.projects[0] );
129
130 // Terry, the Employee
131 new TestCase( SECTION,
132 "terry.name",
133 "Boomberi, Terry",
134 terry.name );
135
136 new TestCase( SECTION,
137 "terry.dept",
138 "Marketing",
139 terry.dept );
140 test();
141