Debian Codegraph @

rhino/testsrc/tests/js1_3/inherit/proto_7.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_7.js';
7
8 /**
9 File Name: proto_7.js
10 Section:
11 Description: Adding Properties to the Prototype Object
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
22
23 Author: [email protected]
24 Date: 12 november 1997
25 */
26
27 var SECTION = "proto_6";
28 var VERSION = "JS1_3";
29 var TITLE = "Adding properties to the Prototype Object";
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 WorkerBee ( name, dept, projs ) {
39 this.base = Employee;
40 this.base( name, dept)
41 this.projects = projs || new Array();
42 }
43 WorkerBee.prototype = new Employee();
44
45 function Engineer ( name, projs, machine ) {
46 this.base = WorkerBee;
47 this.base( name, "engineering", projs )
48 this.machine = machine || "";
49 }
50 // Engineer.prototype = new WorkerBee();
51
52 var pat = new Engineer( "Toonces, Pat",
53 ["SpiderMonkey", "Rhino"],
54 "indy" );
55
56 Employee.prototype.specialty = "none";
57
58
59 // Pat, the Engineer
60
61 new TestCase( SECTION,
62 "pat.name",
63 "Toonces, Pat",
64 pat.name );
65
66 new TestCase( SECTION,
67 "pat.dept",
68 "engineering",
69 pat.dept );
70
71 new TestCase( SECTION,
72 "pat.projects.length",
73 2,
74 pat.projects.length );
75
76 new TestCase( SECTION,
77 "pat.projects[0]",
78 "SpiderMonkey",
79 pat.projects[0] );
80
81 new TestCase( SECTION,
82 "pat.projects[1]",
83 "Rhino",
84 pat.projects[1] );
85
86 new TestCase( SECTION,
87 "pat.machine",
88 "indy",
89 pat.machine );
90
91 new TestCase( SECTION,
92 "pat.specialty",
93 void 0,
94 pat.specialty );
95
96 test();