Debian Codegraph @

rhino/testsrc/tests/js1_3/extensions/proto_5.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_5.js';
7
8 /**
9 File Name: proto_5.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_5";
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 ( projs ) {
44 this.projects = projs || new Array();
45 }
46 WorkerBee.prototype = new Employee();
47
48 function SalesPerson () {
49 this.dept = "sales";
50 this.quota = 100;
51 }
52 SalesPerson.prototype = new WorkerBee();
53
54 function Engineer ( machine ) {
55 this.dept = "engineering";
56 this.machine = machine || "";
57 }
58 Engineer.prototype = new WorkerBee();
59
60
61 var pat = new Engineer( "indy" );
62
63 var les = new Engineer();
64
65 new TestCase( SECTION,
66 "var pat = new Engineer(\"indy\"); pat.name",
67 "",
68 pat.name );
69
70 new TestCase( SECTION,
71 "pat.dept",
72 "engineering",
73 pat.dept );
74
75 new TestCase( SECTION,
76 "pat.projects.length",
77 0,
78 pat.projects.length );
79
80 new TestCase( SECTION,
81 "pat.machine",
82 "indy",
83 pat.machine );
84
85 new TestCase( SECTION,
86 "pat.__proto__ == Engineer.prototype",
87 true,
88 pat.__proto__ == Engineer.prototype );
89
90 new TestCase( SECTION,
91 "var les = new Engineer(); les.name",
92 "",
93 les.name );
94
95 new TestCase( SECTION,
96 "les.dept",
97 "engineering",
98 les.dept );
99
100 new TestCase( SECTION,
101 "les.projects.length",
102 0,
103 les.projects.length );
104
105 new TestCase( SECTION,
106 "les.machine",
107 "",
108 les.machine );
109
110 new TestCase( SECTION,
111 "les.__proto__ == Engineer.prototype",
112 true,
113 les.__proto__ == Engineer.prototype );
114
115
116 test();