Debian Codegraph @

rhino/testsrc/tests/js1_3/inherit/proto_12.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_12.js';
7
8 /**
9 File Name: proto_12.js
10 Section:
11 Description: new PrototypeObject
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 No Multiple Inheritance
19
20 Author: [email protected]
21 Date: 12 november 1997
22 */
23
24 var SECTION = "proto_12";
25 var VERSION = "JS1_3";
26 var TITLE = "No Multiple Inheritance";
27
28 startTest();
29 writeHeaderToLog( SECTION + " "+ TITLE);
30
31 function Employee ( name, dept ) {
32 this.name = name || "";
33 this.dept = dept || "general";
34 this.id = idCounter++;
35 }
36 function Manager () {
37 this.reports = [];
38 }
39 Manager.prototype = new Employee();
40
41 function WorkerBee ( name, dept, projs ) {
42 this.base = Employee;
43 this.base( name, dept)
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 Hobbyist( hobby ) {
55 this.hobby = hobby || "yodeling";
56 }
57
58 function Engineer ( name, projs, machine, hobby ) {
59 this.base1 = WorkerBee;
60 this.base1( name, "engineering", projs )
61
62 this.base2 = Hobbyist;
63 this.base2( hobby );
64
65 this.projects = projs || new Array();
66 this.machine = machine || "";
67 }
68 Engineer.prototype = new WorkerBee();
69
70 var idCounter = 1;
71
72 var les = new Engineer( "Morris, Les", new Array("JavaScript"), "indy" );
73
74 Hobbyist.prototype.equipment = [ "horn", "mountain", "goat" ];
75
76 new TestCase( SECTION,
77 "les.name",
78 "Morris, Les",
79 les.name );
80
81 new TestCase( SECTION,
82 "les.dept",
83 "engineering",
84 les.dept );
85
86 Array.prototype.getClass = Object.prototype.toString;
87
88 new TestCase( SECTION,
89 "les.projects.getClass()",
90 "[object Array]",
91 les.projects.getClass() );
92
93 new TestCase( SECTION,
94 "les.projects[0]",
95 "JavaScript",
96 les.projects[0] );
97
98 new TestCase( SECTION,
99 "les.machine",
100 "indy",
101 les.machine );
102
103 new TestCase( SECTION,
104 "les.hobby",
105 "yodeling",
106 les.hobby );
107
108 new TestCase( SECTION,
109 "les.equpment",
110 void 0,
111 les.equipment );
112
113 test();