Debian Codegraph @

rhino/testsrc/tests/js1_3/extensions/proto_2.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_2.js';
7
8 /**
9 File Name: proto_2.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 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_2";
26 var VERSION = "JS1_3";
27 var TITLE = "new PrototypeObject";
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
60 var employee = new Employee();
61 var manager = new Manager();
62 var workerbee = new WorkerBee();
63 var salesperson = new SalesPerson();
64 var engineer = new Engineer();
65
66 new TestCase( SECTION,
67 "employee.__proto__ == Employee.prototype",
68 true,
69 employee.__proto__ == Employee.prototype );
70
71 new TestCase( SECTION,
72 "manager.__proto__ == Manager.prototype",
73 true,
74 manager.__proto__ == Manager.prototype );
75
76 new TestCase( SECTION,
77 "workerbee.__proto__ == WorkerBee.prototype",
78 true,
79 workerbee.__proto__ == WorkerBee.prototype );
80
81 new TestCase( SECTION,
82 "salesperson.__proto__ == SalesPerson.prototype",
83 true,
84 salesperson.__proto__ == SalesPerson.prototype );
85
86 new TestCase( SECTION,
87 "engineer.__proto__ == Engineer.prototype",
88 true,
89 engineer.__proto__ == Engineer.prototype );
90
91 test();
92