Debian Codegraph @

rhino/testsrc/tests/js1_3/inherit/proto_3.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_3.js';
7
8 /**
9 File Name: proto_3.js
10 Section:
11 Description: Adding properties to an instance
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_3";
26 var VERSION = "JS1_3";
27 var TITLE = "Adding properties to an Instance";
28
29 startTest();
30 writeHeaderToLog( SECTION + " "+ TITLE);
31
32 function Employee () {
33 this.name = "";
34 this.dept = "general";
35 }
36 function Manager () {
37 this.reports = [];
38 }
39 Manager.prototype = new Employee();
40
41 function WorkerBee () {
42 this.projects = new Array();
43 }
44
45 WorkerBee.prototype = new Employee();
46
47 function SalesPerson () {
48 this.dept = "sales";
49 this.quota = 100;
50 }
51 SalesPerson.prototype = new WorkerBee();
52
53 function Engineer () {
54 this.dept = "engineering";
55 this.machine = "";
56 }
57 Engineer.prototype = new WorkerBee();
58
59 var jim = new Employee();
60 var pat = new Employee();
61
62 jim.bonus = 300;
63
64 new TestCase( SECTION,
65 "jim = new Employee(); jim.bonus = 300; jim.bonus",
66 300,
67 jim.bonus );
68
69
70 new TestCase( SECTION,
71 "pat = new Employee(); pat.bonus",
72 void 0,
73 pat.bonus );
74 test();