Debian Codegraph @

rhino/testsrc/tests/js1_3/inherit/proto_11.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_11.js';
7
8 /**
9 File Name: proto_11.js
10 Section:
11 Description: Global Information 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 Author: [email protected]
22 Date: 12 november 1997
23 */
24
25 var SECTION = "proto_11";
26 var VERSION = "JS1_3";
27 var TITLE = "Global Information in Constructors";
28
29 startTest();
30 writeHeaderToLog( SECTION + " "+ TITLE);
31
32 var idCounter = 1;
33
34
35 function Employee ( name, dept ) {
36 this.name = name || "";
37 this.dept = dept || "general";
38 this.id = idCounter++;
39 }
40 function Manager () {
41 this.reports = [];
42 }
43 Manager.prototype = new Employee();
44
45 function WorkerBee ( name, dept, projs ) {
46 this.base = Employee;
47 this.base( name, dept)
48 this.projects = projs || new Array();
49 }
50 WorkerBee.prototype = new Employee();
51
52 function SalesPerson () {
53 this.dept = "sales";
54 this.quota = 100;
55 }
56 SalesPerson.prototype = new WorkerBee();
57
58 function Engineer ( name, projs, machine ) {
59 this.base = WorkerBee;
60 this.base( name, "engineering", projs )
61 this.machine = machine || "";
62 }
63 Engineer.prototype = new WorkerBee();
64
65 var pat = new Employee( "Toonces, Pat", "Tech Pubs" )
66 var terry = new Employee( "O'Sherry Terry", "Marketing" );
67
68 var les = new Engineer( "Morris, Les", new Array("JavaScript"), "indy" );
69
70 new TestCase( SECTION,
71 "pat.id",
72 5,
73 pat.id );
74
75 new TestCase( SECTION,
76 "terry.id",
77 6,
78 terry.id );
79
80 new TestCase( SECTION,
81 "les.id",
82 7,
83 les.id );
84
85
86 test();
87